/* Database.c generated by valac 0.56.19, the Vala compiler
 * generated from Database.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 <sqlite3.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.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  {
	SERVICES_DATABASE_0_PROPERTY,
	SERVICES_DATABASE_IS_OPENED_PROPERTY,
	SERVICES_DATABASE_NUM_PROPERTIES
};
static GParamSpec* services_database_properties[SERVICES_DATABASE_NUM_PROPERTIES];
#define _sqlite3_close0(var) ((var == NULL) ? NULL : (var = (sqlite3_close (var), NULL)))
#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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
enum  {
	SERVICES_DATABASE_OPENED_SIGNAL,
	SERVICES_DATABASE_RESET_SIGNAL,
	SERVICES_DATABASE_NUM_SIGNALS
};
static guint services_database_signals[SERVICES_DATABASE_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ServicesDatabasePrivate {
	sqlite3* db;
	gchar* db_path;
	gchar* errormsg;
	gchar* sql;
	GeeHashMap* table_columns;
	gboolean _is_opened;
	JsonParser* parser;
};

static gint ServicesDatabase_private_offset;
static gpointer services_database_parent_class = NULL;
static ServicesDatabase* services_database__instance;
static ServicesDatabase* services_database__instance = NULL;

static void services_database_create_tables (ServicesDatabase* self);
static void services_database_create_triggers (ServicesDatabase* self);
static void services_database_patch_database (ServicesDatabase* self);
static void services_database_migrate_foreign_keys_on_update_cascade (ServicesDatabase* self);
static gboolean services_database_table_exists (ServicesDatabase* self,
                                         const gchar* table_name);
static gboolean services_database_table_columns_exists (ServicesDatabase* self,
                                                 const gchar* table,
                                                 GeeArrayList* columns);
static ObjectsSource* _services_database_fill_source (ServicesDatabase* self,
                                               sqlite3_stmt* stmt);
static gboolean services_database_get_parameter_bool (ServicesDatabase* self,
                                               sqlite3_stmt* stmt,
                                               gint col);
static void services_database_set_parameter_str (ServicesDatabase* self,
                                          sqlite3_stmt* stmt,
                                          const gchar* par,
                                          const gchar* val);
static void services_database_set_parameter_bool (ServicesDatabase* self,
                                           sqlite3_stmt* stmt,
                                           const gchar* par,
                                           gboolean* val);
static void services_database_set_parameter_int (ServicesDatabase* self,
                                          sqlite3_stmt* stmt,
                                          const gchar* par,
                                          gint* val);
static void services_database_set_parameter_int64 (ServicesDatabase* self,
                                            sqlite3_stmt* stmt,
                                            const gchar* par,
                                            gint64* val);
static gboolean services_database_table_has_on_update_cascade (ServicesDatabase* self,
                                                        const gchar* table);
static gboolean services_database_rebuild_table (ServicesDatabase* self,
                                          const gchar* table,
                                          const gchar* create_new_sql,
                                          const gchar* columns);
static GObject * services_database_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void services_database_finalize (GObject * obj);
static GType services_database_get_type_once (void);
static void _vala_services_database_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_services_database_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
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 inline gpointer
services_database_get_instance_private (ServicesDatabase* self)
{
	return G_STRUCT_MEMBER_P (self, ServicesDatabase_private_offset);
}

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

ServicesDatabase*
services_database_get_default (void)
{
	ServicesDatabase* _tmp0_;
	ServicesDatabase* _tmp2_;
	ServicesDatabase* _tmp3_;
	ServicesDatabase* result;
	_tmp0_ = services_database__instance;
	if (_tmp0_ == NULL) {
		ServicesDatabase* _tmp1_;
		_tmp1_ = services_database_new ();
		_g_object_unref0 (services_database__instance);
		services_database__instance = _tmp1_;
	}
	_tmp2_ = services_database__instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

void
services_database_init_database (ServicesDatabase* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	sqlite3* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_get_user_data_dir ();
	_tmp1_ = g_strconcat (_tmp0_, "/io.github.alainm23.planify/database.db", NULL);
	_g_free0 (self->priv->db_path);
	self->priv->db_path = _tmp1_;
	_tmp2_ = self->priv->db_path;
	sqlite3_open (_tmp2_, &_tmp3_);
	_sqlite3_close0 (self->priv->db);
	self->priv->db = _tmp3_;
	services_database_create_tables (self);
	services_database_create_triggers (self);
	services_database_patch_database (self);
	g_signal_emit (self, services_database_signals[SERVICES_DATABASE_OPENED_SIGNAL], 0);
	services_database_set_is_opened (self, TRUE);
}

static gint
_sqlite3_exec (sqlite3* self,
               const gchar* sql,
               sqlite3_callback callback,
               gpointer callback_target,
               gchar** errmsg)
{
	gchar* _vala_errmsg = NULL;
	const gchar* sqlite_errmsg = NULL;
	gint ec = 0;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_;
	const gchar* _tmp4_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (sql != NULL, -1);
	_tmp1_ = sqlite3_exec (self, sql, callback, callback_target, (char**) (&_tmp0_));
	sqlite_errmsg = _tmp0_;
	ec = _tmp1_;
	if ((&_vala_errmsg) != NULL) {
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = sqlite_errmsg;
		_tmp3_ = g_strdup (_tmp2_);
		_g_free0 (_vala_errmsg);
		_vala_errmsg = _tmp3_;
	} else {
		_g_free0 (_vala_errmsg);
		_vala_errmsg = NULL;
	}
	_tmp4_ = sqlite_errmsg;
	sqlite3_free ((void*) _tmp4_);
	result = ec;
	if (errmsg) {
		*errmsg = _vala_errmsg;
	} else {
		_g_free0 (_vala_errmsg);
	}
	return result;
}

static void
services_database_create_tables (ServicesDatabase* self)
{
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gint _tmp4_;
	gchar* _tmp6_;
	sqlite3* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_ = NULL;
	gint _tmp10_;
	gchar* _tmp12_;
	sqlite3* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gint _tmp16_;
	gchar* _tmp18_;
	sqlite3* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_ = NULL;
	gint _tmp22_;
	gchar* _tmp24_;
	sqlite3* _tmp25_;
	const gchar* _tmp26_;
	gchar* _tmp27_ = NULL;
	gint _tmp28_;
	gchar* _tmp30_;
	sqlite3* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gint _tmp34_;
	gchar* _tmp36_;
	sqlite3* _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_ = NULL;
	gint _tmp40_;
	gchar* _tmp42_;
	sqlite3* _tmp43_;
	const gchar* _tmp44_;
	gchar* _tmp45_ = NULL;
	gint _tmp46_;
	gchar* _tmp48_;
	sqlite3* _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_ = NULL;
	gint _tmp52_;
	gchar* _tmp54_;
	sqlite3* _tmp55_;
	const gchar* _tmp56_;
	gchar* _tmp57_ = NULL;
	gint _tmp58_;
	gchar* _tmp60_;
	sqlite3* _tmp61_;
	const gchar* _tmp62_;
	gchar* _tmp63_ = NULL;
	gint _tmp64_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Labels (\n" \
"                id              TEXT PRIMARY KEY,\n" \
"                name            TEXT,\n" \
"                color           TEXT,\n" \
"                item_order      INTEGER,\n" \
"                is_deleted      INTEGER,\n" \
"                is_favorite     INTEGER,\n" \
"                backend_type    TEXT,\n" \
"                source_id       TEXT,\n" \
"                CONSTRAINT unique_label UNIQUE (name)\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp4_ = _sqlite3_exec (_tmp1_, _tmp2_, NULL, NULL, &_tmp3_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp3_;
	if (_tmp4_ != SQLITE_OK) {
		const gchar* _tmp5_;
		_tmp5_ = self->priv->errormsg;
		g_warning ("Database.vala:208: %s", _tmp5_);
	}
	_tmp6_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Projects (\n" \
"                id                      TEXT PRIMARY KEY,\n" \
"                name                    TEXT NOT NULL,\n" \
"                color                   TEXT,\n" \
"                backend_type            TEXT,\n" \
"                inbox_project           INTEGER,\n" \
"                team_inbox              INTEGER,\n" \
"                child_order             INTEGER,\n" \
"                is_deleted              INTEGER,\n" \
"                is_archived             INTEGER,\n" \
"                is_favorite             INTEGER,\n" \
"                shared                  INTEGER,\n" \
"                view_style              TEXT,\n" \
"                sort_order              INTEGER,\n" \
"                parent_id               TEXT,\n" \
"                collapsed               INTEGER,\n" \
"                icon_style              TEXT,\n" \
"                emoji                   TEXT,\n" \
"                show_completed          INTEGER,\n" \
"                description             TEXT,\n" \
"                due_date                TEXT,\n" \
"                inbox_section_hidded    INTEGER,\n" \
"                sync_id                 TEXT,\n" \
"                source_id               TEXT,\n" \
"                calendar_url            TEXT,\n" \
"                sorted_by               TEXT,\n" \
"                calendar_source_uid     TEXT,\n" \
"                markdown_setting        TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp6_;
	_tmp7_ = self->priv->db;
	_tmp8_ = self->priv->sql;
	_tmp10_ = _sqlite3_exec (_tmp7_, _tmp8_, NULL, NULL, &_tmp9_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp9_;
	if (_tmp10_ != SQLITE_OK) {
		const gchar* _tmp11_;
		_tmp11_ = self->priv->errormsg;
		g_warning ("Database.vala:244: %s", _tmp11_);
	}
	_tmp12_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Sections (\n" \
"                id              TEXT PRIMARY KEY,\n" \
"                name            TEXT,\n" \
"                archived_at     TEXT,\n" \
"                added_at        TEXT,\n" \
"                project_id      TEXT,\n" \
"                section_order   INTEGER,\n" \
"                collapsed       INTEGER,\n" \
"                is_deleted      INTEGER,\n" \
"                is_archived     INTEGER,\n" \
"                color           TEXT,\n" \
"                description     TEXT,\n" \
"                hidded          INTEGER,\n" \
"                FOREIGN KEY (project_id) REFERENCES Projects (id) ON D" \
"ELETE CASCADE ON UPDATE CASCADE\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp12_;
	_tmp13_ = self->priv->db;
	_tmp14_ = self->priv->sql;
	_tmp16_ = _sqlite3_exec (_tmp13_, _tmp14_, NULL, NULL, &_tmp15_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp15_;
	if (_tmp16_ != SQLITE_OK) {
		const gchar* _tmp17_;
		_tmp17_ = self->priv->errormsg;
		g_warning ("Database.vala:266: %s", _tmp17_);
	}
	_tmp18_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Items (\n" \
"                id                  TEXT PRIMARY KEY,\n" \
"                content             TEXT NOT NULL,\n" \
"                description         TEXT,\n" \
"                due                 TEXT,\n" \
"                added_at            TEXT,\n" \
"                completed_at        TEXT,\n" \
"                updated_at          TEXT,\n" \
"                section_id          TEXT,\n" \
"                project_id          TEXT,\n" \
"                parent_id           TEXT,\n" \
"                priority            INTEGER,\n" \
"                child_order         INTEGER,\n" \
"                checked             INTEGER,\n" \
"                is_deleted          INTEGER,\n" \
"                day_order           INTEGER,\n" \
"                collapsed           INTEGER,\n" \
"                pinned              INTEGER,\n" \
"                labels              TEXT,\n" \
"                extra_data          TEXT,\n" \
"                item_type           TEXT,\n" \
"                calendar_event_uid  TEXT,\n" \
"                deadline_date       TEXT,\n" \
"                responsible_uid     TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp18_;
	_tmp19_ = self->priv->db;
	_tmp20_ = self->priv->sql;
	_tmp22_ = _sqlite3_exec (_tmp19_, _tmp20_, NULL, NULL, &_tmp21_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp21_;
	if (_tmp22_ != SQLITE_OK) {
		const gchar* _tmp23_;
		_tmp23_ = self->priv->errormsg;
		g_warning ("Database.vala:298: %s", _tmp23_);
	}
	_tmp24_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Reminders (\n" \
"                id                  TEXT PRIMARY KEY,\n" \
"                notify_uid          INTEGER,\n" \
"                item_id             TEXT,\n" \
"                service             TEXT,\n" \
"                type                TEXT,\n" \
"                due                 TEXT,\n" \
"                mm_offset           INTEGER,\n" \
"                is_deleted          INTEGER,\n" \
"                FOREIGN KEY (item_id) REFERENCES Items (id) ON DELETE " \
"CASCADE ON UPDATE CASCADE\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp24_;
	_tmp25_ = self->priv->db;
	_tmp26_ = self->priv->sql;
	_tmp28_ = _sqlite3_exec (_tmp25_, _tmp26_, NULL, NULL, &_tmp27_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp27_;
	if (_tmp28_ != SQLITE_OK) {
		const gchar* _tmp29_;
		_tmp29_ = self->priv->errormsg;
		g_warning ("Database.vala:316: %s", _tmp29_);
	}
	_tmp30_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Queue (\n" \
"                uuid       TEXT PRIMARY KEY,\n" \
"                object_id  TEXT,\n" \
"                query      TEXT,\n" \
"                temp_id    TEXT,\n" \
"                args       TEXT,\n" \
"                source_id  TEXT,\n" \
"                date_added TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp30_;
	_tmp31_ = self->priv->db;
	_tmp32_ = self->priv->sql;
	_tmp34_ = _sqlite3_exec (_tmp31_, _tmp32_, NULL, NULL, &_tmp33_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp33_;
	if (_tmp34_ != SQLITE_OK) {
		const gchar* _tmp35_;
		_tmp35_ = self->priv->errormsg;
		g_warning ("Database.vala:332: %s", _tmp35_);
	}
	_tmp36_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS CurTempIds (\n" \
"                id          TEXT PRIMARY KEY,\n" \
"                temp_id     TEXT,\n" \
"                object      TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp36_;
	_tmp37_ = self->priv->db;
	_tmp38_ = self->priv->sql;
	_tmp40_ = _sqlite3_exec (_tmp37_, _tmp38_, NULL, NULL, &_tmp39_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp39_;
	if (_tmp40_ != SQLITE_OK) {
		const gchar* _tmp41_;
		_tmp41_ = self->priv->errormsg;
		g_warning ("Database.vala:344: %s", _tmp41_);
	}
	_tmp42_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Attachments (\n" \
"                id              TEXT PRIMARY KEY,\n" \
"                item_id         TEXT,\n" \
"                file_type       TEXT,\n" \
"                file_name       TEXT,\n" \
"                file_size       TEXT,\n" \
"                file_path       TEXT,\n" \
"                FOREIGN KEY (item_id) REFERENCES Items (id) ON DELETE " \
"CASCADE ON UPDATE CASCADE\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp42_;
	_tmp43_ = self->priv->db;
	_tmp44_ = self->priv->sql;
	_tmp46_ = _sqlite3_exec (_tmp43_, _tmp44_, NULL, NULL, &_tmp45_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp45_;
	if (_tmp46_ != SQLITE_OK) {
		const gchar* _tmp47_;
		_tmp47_ = self->priv->errormsg;
		g_warning ("Database.vala:360: %s", _tmp47_);
	}
	_tmp48_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS OEvents (\n" \
"                id                  INTEGER PRIMARY KEY AUTOINCREMENT," \
"\n" \
"                event_type          TEXT,\n" \
"                event_date          DATETIME DEFAULT (datetime('now','" \
"localtime')),\n" \
"                object_id           TEXT,\n" \
"                object_type         TEXT,\n" \
"                object_key          TEXT,\n" \
"                object_old_value    TEXT,\n" \
"                object_new_value    TEXT,\n" \
"                parent_item_id      TEXT,\n" \
"                parent_project_id   TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp48_;
	_tmp49_ = self->priv->db;
	_tmp50_ = self->priv->sql;
	_tmp52_ = _sqlite3_exec (_tmp49_, _tmp50_, NULL, NULL, &_tmp51_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp51_;
	if (_tmp52_ != SQLITE_OK) {
		const gchar* _tmp53_;
		_tmp53_ = self->priv->errormsg;
		g_warning ("Database.vala:379: %s", _tmp53_);
	}
	_tmp54_ = g_strdup ("\n" \
"            CREATE TABLE IF NOT EXISTS Sources (\n" \
"                id                  TEXT PRIMARY KEY,\n" \
"                source_type         TEXT NOT NULL,\n" \
"                display_name        TEXT,\n" \
"                added_at            TEXT,\n" \
"                updated_at          TEXT,\n" \
"                is_visible          INTEGER,\n" \
"                child_order         INTEGER,\n" \
"                sync_server         INTEGER,\n" \
"                last_sync           TEXT,\n" \
"                data                TEXT\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp54_;
	_tmp55_ = self->priv->db;
	_tmp56_ = self->priv->sql;
	_tmp58_ = _sqlite3_exec (_tmp55_, _tmp56_, NULL, NULL, &_tmp57_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp57_;
	if (_tmp58_ != SQLITE_OK) {
		const gchar* _tmp59_;
		_tmp59_ = self->priv->errormsg;
		g_warning ("Database.vala:398: %s", _tmp59_);
	}
	_tmp60_ = g_strdup ("PRAGMA foreign_keys = ON;");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp60_;
	_tmp61_ = self->priv->db;
	_tmp62_ = self->priv->sql;
	_tmp64_ = _sqlite3_exec (_tmp61_, _tmp62_, NULL, NULL, &_tmp63_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp63_;
	if (_tmp64_ != SQLITE_OK) {
		const gchar* _tmp65_;
		_tmp65_ = self->priv->errormsg;
		g_warning ("Database.vala:404: %s", _tmp65_);
	}
}

static void
services_database_create_triggers (ServicesDatabase* self)
{
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gint _tmp4_;
	gchar* _tmp6_;
	sqlite3* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_ = NULL;
	gint _tmp10_;
	gchar* _tmp12_;
	sqlite3* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gint _tmp16_;
	gchar* _tmp18_;
	sqlite3* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_ = NULL;
	gint _tmp22_;
	gchar* _tmp24_;
	sqlite3* _tmp25_;
	const gchar* _tmp26_;
	gchar* _tmp27_ = NULL;
	gint _tmp28_;
	gchar* _tmp30_;
	sqlite3* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_ = NULL;
	gint _tmp34_;
	gchar* _tmp36_;
	sqlite3* _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_ = NULL;
	gint _tmp40_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	sqlite3* _tmp44_;
	const gchar* _tmp45_;
	gchar* _tmp46_ = NULL;
	gint _tmp47_;
	gchar* _tmp49_;
	sqlite3* _tmp50_;
	const gchar* _tmp51_;
	gchar* _tmp52_ = NULL;
	gint _tmp53_;
	gchar* _tmp55_;
	sqlite3* _tmp56_;
	const gchar* _tmp57_;
	gchar* _tmp58_ = NULL;
	gint _tmp59_;
	gchar* _tmp61_;
	sqlite3* _tmp62_;
	const gchar* _tmp63_;
	gchar* _tmp64_ = NULL;
	gint _tmp65_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_insert_item\n" \
"            AFTER INSERT ON Items\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('insert', NEW.id, 'item', 'content', NEW.conte" \
"nt,\n" \
"                    NEW.content, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp4_ = _sqlite3_exec (_tmp1_, _tmp2_, NULL, NULL, &_tmp3_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp3_;
	if (_tmp4_ != SQLITE_OK) {
		const gchar* _tmp5_;
		_tmp5_ = self->priv->errormsg;
		g_warning ("Database.vala:421: %s", _tmp5_);
	}
	_tmp6_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_content_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.content != OLD.content\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'content', OLD.conte" \
"nt,\n" \
"                    NEW.content, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp6_;
	_tmp7_ = self->priv->db;
	_tmp8_ = self->priv->sql;
	_tmp10_ = _sqlite3_exec (_tmp7_, _tmp8_, NULL, NULL, &_tmp9_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp9_;
	if (_tmp10_ != SQLITE_OK) {
		const gchar* _tmp11_;
		_tmp11_ = self->priv->errormsg;
		g_warning ("Database.vala:438: %s", _tmp11_);
	}
	_tmp12_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_description_item" \
"\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.description != OLD.description\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'description', OLD.d" \
"escription,\n" \
"                    NEW.description, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp12_;
	_tmp13_ = self->priv->db;
	_tmp14_ = self->priv->sql;
	_tmp16_ = _sqlite3_exec (_tmp13_, _tmp14_, NULL, NULL, &_tmp15_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp15_;
	if (_tmp16_ != SQLITE_OK) {
		const gchar* _tmp17_;
		_tmp17_ = self->priv->errormsg;
		g_warning ("Database.vala:455: %s", _tmp17_);
	}
	_tmp18_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_due_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.due != OLD.due\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'due', OLD.due,\n" \
"                    NEW.due, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp18_;
	_tmp19_ = self->priv->db;
	_tmp20_ = self->priv->sql;
	_tmp22_ = _sqlite3_exec (_tmp19_, _tmp20_, NULL, NULL, &_tmp21_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp21_;
	if (_tmp22_ != SQLITE_OK) {
		const gchar* _tmp23_;
		_tmp23_ = self->priv->errormsg;
		g_warning ("Database.vala:472: %s", _tmp23_);
	}
	_tmp24_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_priority_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.priority != OLD.priority\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'priority', OLD.prio" \
"rity,\n" \
"                    NEW.priority, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp24_;
	_tmp25_ = self->priv->db;
	_tmp26_ = self->priv->sql;
	_tmp28_ = _sqlite3_exec (_tmp25_, _tmp26_, NULL, NULL, &_tmp27_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp27_;
	if (_tmp28_ != SQLITE_OK) {
		const gchar* _tmp29_;
		_tmp29_ = self->priv->errormsg;
		g_warning ("Database.vala:489: %s", _tmp29_);
	}
	_tmp30_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_labels_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.labels != OLD.labels\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'labels', OLD.labels" \
",\n" \
"                    NEW.labels, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp30_;
	_tmp31_ = self->priv->db;
	_tmp32_ = self->priv->sql;
	_tmp34_ = _sqlite3_exec (_tmp31_, _tmp32_, NULL, NULL, &_tmp33_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp33_;
	if (_tmp34_ != SQLITE_OK) {
		const gchar* _tmp35_;
		_tmp35_ = self->priv->errormsg;
		g_warning ("Database.vala:506: %s", _tmp35_);
	}
	_tmp36_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_pinned_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.pinned != OLD.pinned\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'pinned', OLD.pinned" \
",\n" \
"                    NEW.pinned, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp36_;
	_tmp37_ = self->priv->db;
	_tmp38_ = self->priv->sql;
	_tmp40_ = _sqlite3_exec (_tmp37_, _tmp38_, NULL, NULL, &_tmp39_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp39_;
	if (_tmp40_ != SQLITE_OK) {
		const gchar* _tmp41_;
		_tmp41_ = self->priv->errormsg;
		g_warning ("Database.vala:523: %s", _tmp41_);
	}
	_tmp42_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_checked_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.checked != OLD.checked\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'checked', OLD.check" \
"ed,\n" \
"                    NEW.checked, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp42_;
	_tmp43_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_section_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.section_id != OLD.section_id\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'section', OLD.secti" \
"on_id,\n" \
"                    NEW.section_id, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp43_;
	_tmp44_ = self->priv->db;
	_tmp45_ = self->priv->sql;
	_tmp47_ = _sqlite3_exec (_tmp44_, _tmp45_, NULL, NULL, &_tmp46_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp46_;
	if (_tmp47_ != SQLITE_OK) {
		const gchar* _tmp48_;
		_tmp48_ = self->priv->errormsg;
		g_warning ("Database.vala:553: %s", _tmp48_);
	}
	_tmp49_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_project_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.project_id != OLD.project_id\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'project', OLD.proje" \
"ct_id,\n" \
"                    NEW.project_id, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp49_;
	_tmp50_ = self->priv->db;
	_tmp51_ = self->priv->sql;
	_tmp53_ = _sqlite3_exec (_tmp50_, _tmp51_, NULL, NULL, &_tmp52_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp52_;
	if (_tmp53_ != SQLITE_OK) {
		const gchar* _tmp54_;
		_tmp54_ = self->priv->errormsg;
		g_warning ("Database.vala:570: %s", _tmp54_);
	}
	_tmp55_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_deadline_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.deadline_date != OLD.deadline_date\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'deadline', OLD.dead" \
"line_date,\n" \
"                    NEW.deadline_date, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp55_;
	_tmp56_ = self->priv->db;
	_tmp57_ = self->priv->sql;
	_tmp59_ = _sqlite3_exec (_tmp56_, _tmp57_, NULL, NULL, &_tmp58_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp58_;
	if (_tmp59_ != SQLITE_OK) {
		const gchar* _tmp60_;
		_tmp60_ = self->priv->errormsg;
		g_warning ("Database.vala:587: %s", _tmp60_);
	}
	_tmp61_ = g_strdup ("\n" \
"            CREATE TRIGGER IF NOT EXISTS after_update_parent_item\n" \
"            AFTER UPDATE ON Items\n" \
"            FOR EACH ROW\n" \
"            WHEN NEW.parent_id != OLD.parent_id\n" \
"            BEGIN\n" \
"                INSERT OR IGNORE INTO OEvents (event_type, object_id,\n" \
"                    object_type, object_key, object_old_value, object_" \
"new_value, parent_project_id)\n" \
"                VALUES ('update', NEW.id, 'item', 'parent', OLD.parent" \
"_id,\n" \
"                    NEW.parent_id, NEW.project_id);\n" \
"            END;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp61_;
	_tmp62_ = self->priv->db;
	_tmp63_ = self->priv->sql;
	_tmp65_ = _sqlite3_exec (_tmp62_, _tmp63_, NULL, NULL, &_tmp64_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp64_;
	if (_tmp65_ != SQLITE_OK) {
		const gchar* _tmp66_;
		_tmp66_ = self->priv->errormsg;
		g_warning ("Database.vala:604: %s", _tmp66_);
	}
}

static void
services_database_patch_database (ServicesDatabase* self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	services_database_add_int_column (self, "Items", "pinned", 0);
	services_database_add_int_column (self, "Projects", "show_completed", 0);
	services_database_add_text_column (self, "Projects", "description", "");
	services_database_add_item_label_column (self);
	services_database_add_text_column (self, "Sections", "color", "blue");
	services_database_add_text_column (self, "Sections", "description", "");
	services_database_add_text_column (self, "Items", "extra_data", "");
	services_database_add_int_column (self, "Sections", "hidded", 0);
	services_database_add_int_column (self, "Projects", "inbox_section_hidded", 0);
	services_database_add_text_column (self, "Projects", "sync_id", "");
	_tmp0_ = item_type_to_string (ITEM_TYPE_TASK);
	_tmp1_ = _tmp0_;
	services_database_add_text_column (self, "Items", "item_type", _tmp1_);
	_g_free0 (_tmp1_);
	services_database_add_project_labels_source_id (self);
	services_database_add_calendar_url_to_project (self);
	_tmp2_ = sorted_by_type_to_string (SORTED_BY_TYPE_MANUAL);
	_tmp3_ = _tmp2_;
	services_database_add_text_column (self, "Projects", "sorted_by", _tmp3_);
	_g_free0 (_tmp3_);
	services_database_add_text_column (self, "Projects", "calendar_source_uid", "");
	services_database_add_text_column (self, "Items", "calendar_event_uid", "");
	services_database_add_text_column (self, "Items", "deadline_date", "");
	services_database_add_text_column (self, "Items", "responsible_uid", "");
	_tmp4_ = markdown_setting_to_string (MARKDOWN_SETTING_GLOBAL_DEFAULT);
	_tmp5_ = _tmp4_;
	services_database_add_text_column (self, "Projects", "markdown_setting", _tmp5_);
	_g_free0 (_tmp5_);
	services_database_add_text_column (self, "Sections", "extra_data", "");
	services_database_add_text_column (self, "Queue", "source_id", "");
	services_database_migrate_foreign_keys_on_update_cascade (self);
}

void
services_database_clear_database (ServicesDatabase* self)
{
	gchar* db_path = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GFile* db_file = NULL;
	const gchar* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_get_user_data_dir ();
	_tmp1_ = g_strconcat (_tmp0_, "/io.github.alainm23.planify/database.db", NULL);
	db_path = _tmp1_;
	_tmp2_ = db_path;
	_tmp3_ = g_file_new_for_path (_tmp2_);
	db_file = _tmp3_;
	_tmp4_ = db_file;
	if (g_file_query_exists (_tmp4_, NULL)) {
		{
			GFile* _tmp5_;
			_tmp5_ = db_file;
			g_file_delete (_tmp5_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GError* _tmp6_;
			const gchar* _tmp7_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp6_ = err;
			_tmp7_ = _tmp6_->message;
			g_warning ("Database.vala:715: %s", _tmp7_);
			_g_error_free0 (err);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (db_file);
			_g_free0 (db_path);
			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;
		}
	}
	_g_object_unref0 (db_file);
	_g_free0 (db_path);
}

gboolean
services_database_verify_integrity (ServicesDatabase* self)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gchar** tables = NULL;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar** _tmp20_;
	gint tables_length1;
	gint _tables_size_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            PRAGMA integrity_check;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	if (sqlite3_step (_tmp7_) == SQLITE_ROW) {
		sqlite3_stmt* _tmp8_;
		const gchar* _tmp9_;
		_tmp8_ = stmt;
		_tmp9_ = (const gchar*) sqlite3_column_text (_tmp8_, 0);
		if (g_strcmp0 (_tmp9_, "ok") != 0) {
			result = FALSE;
			_sqlite3_finalize0 (stmt);
			return result;
		}
	}
	_tmp10_ = g_strdup ("Attachments");
	_tmp11_ = g_strdup ("CurTempIds");
	_tmp12_ = g_strdup ("Items");
	_tmp13_ = g_strdup ("Labels");
	_tmp14_ = g_strdup ("OEvents");
	_tmp15_ = g_strdup ("Projects");
	_tmp16_ = g_strdup ("Queue");
	_tmp17_ = g_strdup ("Reminders");
	_tmp18_ = g_strdup ("Sections");
	_tmp19_ = g_strdup ("Sources");
	_tmp20_ = g_new0 (gchar*, 10 + 1);
	_tmp20_[0] = _tmp10_;
	_tmp20_[1] = _tmp11_;
	_tmp20_[2] = _tmp12_;
	_tmp20_[3] = _tmp13_;
	_tmp20_[4] = _tmp14_;
	_tmp20_[5] = _tmp15_;
	_tmp20_[6] = _tmp16_;
	_tmp20_[7] = _tmp17_;
	_tmp20_[8] = _tmp18_;
	_tmp20_[9] = _tmp19_;
	tables = _tmp20_;
	tables_length1 = 10;
	_tables_size_ = tables_length1;
	_tmp21_ = tables;
	_tmp21__length1 = tables_length1;
	{
		gchar** table_name_collection = NULL;
		gint table_name_collection_length1 = 0;
		gint _table_name_collection_size_ = 0;
		gint table_name_it = 0;
		table_name_collection = _tmp21_;
		table_name_collection_length1 = _tmp21__length1;
		for (table_name_it = 0; table_name_it < table_name_collection_length1; table_name_it = table_name_it + 1) {
			gchar* _tmp22_;
			gchar* table_name = NULL;
			_tmp22_ = g_strdup (table_name_collection[table_name_it]);
			table_name = _tmp22_;
			{
				const gchar* _tmp23_;
				_tmp23_ = table_name;
				if (!services_database_table_exists (self, _tmp23_)) {
					result = FALSE;
					_g_free0 (table_name);
					tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), NULL);
					_sqlite3_finalize0 (stmt);
					return result;
				}
				_g_free0 (table_name);
			}
		}
	}
	{
		GeeIterator* _table_it = NULL;
		GeeHashMap* _tmp24_;
		GeeSet* _tmp25_;
		GeeSet* _tmp26_;
		GeeSet* _tmp27_;
		GeeIterator* _tmp28_;
		GeeIterator* _tmp29_;
		_tmp24_ = self->priv->table_columns;
		_tmp25_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp24_);
		_tmp26_ = _tmp25_;
		_tmp27_ = _tmp26_;
		_tmp28_ = gee_iterable_iterator ((GeeIterable*) _tmp27_);
		_tmp29_ = _tmp28_;
		_g_object_unref0 (_tmp27_);
		_table_it = _tmp29_;
		while (TRUE) {
			GeeIterator* _tmp30_;
			gchar* table = NULL;
			GeeIterator* _tmp31_;
			gpointer _tmp32_;
			const gchar* _tmp33_;
			GeeHashMap* _tmp34_;
			const gchar* _tmp35_;
			gpointer _tmp36_;
			GeeArrayList* _tmp37_;
			gboolean _tmp38_;
			_tmp30_ = _table_it;
			if (!gee_iterator_next (_tmp30_)) {
				break;
			}
			_tmp31_ = _table_it;
			_tmp32_ = gee_iterator_get (_tmp31_);
			table = (gchar*) _tmp32_;
			_tmp33_ = table;
			_tmp34_ = self->priv->table_columns;
			_tmp35_ = table;
			_tmp36_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp34_, _tmp35_);
			_tmp37_ = (GeeArrayList*) _tmp36_;
			_tmp38_ = !services_database_table_columns_exists (self, _tmp33_, _tmp37_);
			_g_object_unref0 (_tmp37_);
			if (_tmp38_) {
				result = FALSE;
				_g_free0 (table);
				_g_object_unref0 (_table_it);
				tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), NULL);
				_sqlite3_finalize0 (stmt);
				return result;
			}
			_g_free0 (table);
		}
		_g_object_unref0 (_table_it);
	}
	result = TRUE;
	tables = (_vala_array_free (tables, tables_length1, (GDestroyNotify) g_free), NULL);
	_sqlite3_finalize0 (stmt);
	return result;
}

static gboolean
services_database_table_exists (ServicesDatabase* self,
                                const gchar* table_name)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (table_name != NULL, FALSE);
	_tmp0_ = g_strdup_printf ("\n" \
"            SELECT name FROM sqlite_master WHERE type='table' AND name" \
"='%s';\n" \
"        ", table_name);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	result = sqlite3_step (stmt) == SQLITE_ROW;
	_sqlite3_finalize0 (stmt);
	return result;
}

static gboolean
services_database_table_columns_exists (ServicesDatabase* self,
                                        const gchar* table,
                                        GeeArrayList* columns)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (table != NULL, FALSE);
	g_return_val_if_fail (columns != NULL, FALSE);
	_tmp0_ = g_strdup_printf ("\n            PRAGMA table_info(%s);\n        ", table);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	sqlite3_step (_tmp7_);
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		sqlite3_stmt* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = stmt;
		_tmp10_ = (const gchar*) sqlite3_column_text (_tmp9_, 1);
		if (!gee_abstract_collection_contains ((GeeAbstractCollection*) columns, _tmp10_)) {
			result = FALSE;
			_sqlite3_finalize0 (stmt);
			return result;
		}
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_sources_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_SOURCE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n            SELECT * FROM Sources ORDER BY child_order;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsSource* _tmp11_;
		ObjectsSource* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_source (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

static ObjectsSource*
_services_database_fill_source (ServicesDatabase* self,
                                sqlite3_stmt* stmt)
{
	ObjectsSource* return_value = NULL;
	ObjectsSource* _tmp0_;
	ObjectsSource* _tmp1_;
	const gchar* _tmp2_;
	ObjectsSource* _tmp3_;
	const gchar* _tmp4_;
	ObjectsSource* _tmp5_;
	const gchar* _tmp6_;
	ObjectsSource* _tmp7_;
	const gchar* _tmp8_;
	ObjectsSource* _tmp9_;
	const gchar* _tmp10_;
	ObjectsSource* _tmp11_;
	ObjectsSource* _tmp12_;
	ObjectsSource* _tmp13_;
	ObjectsSource* _tmp14_;
	const gchar* _tmp15_;
	ObjectsSource* _tmp16_;
	SourceType _tmp17_;
	SourceType _tmp18_;
	ObjectsSource* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_source_new ();
	return_value = _tmp0_;
	_tmp1_ = return_value;
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) _tmp1_, _tmp2_);
	_tmp3_ = return_value;
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_source_set_source_type (_tmp3_, source_type_parse (_tmp4_));
	_tmp5_ = return_value;
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_source_set_display_name (_tmp5_, _tmp6_);
	_tmp7_ = return_value;
	_tmp8_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_source_set_added_at (_tmp7_, _tmp8_);
	_tmp9_ = return_value;
	_tmp10_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_source_set_updated_at (_tmp9_, _tmp10_);
	_tmp11_ = return_value;
	objects_source_set_is_visible (_tmp11_, services_database_get_parameter_bool (self, stmt, 5));
	_tmp12_ = return_value;
	objects_source_set_child_order (_tmp12_, sqlite3_column_int (stmt, 6));
	_tmp13_ = return_value;
	objects_source_set_sync_server (_tmp13_, services_database_get_parameter_bool (self, stmt, 7));
	_tmp14_ = return_value;
	_tmp15_ = (const gchar*) sqlite3_column_text (stmt, 8);
	objects_source_set_last_sync (_tmp14_, _tmp15_);
	_tmp16_ = return_value;
	_tmp17_ = objects_source_get_source_type (_tmp16_);
	_tmp18_ = _tmp17_;
	if (_tmp18_ == SOURCE_TYPE_TODOIST) {
		ObjectsSource* _tmp19_;
		const gchar* _tmp20_;
		ObjectsSourceTodoistData* _tmp21_;
		ObjectsSourceTodoistData* _tmp22_;
		_tmp19_ = return_value;
		_tmp20_ = (const gchar*) sqlite3_column_text (stmt, 9);
		_tmp21_ = objects_source_todoist_data_new_from_json (_tmp20_);
		_tmp22_ = _tmp21_;
		objects_source_set_data (_tmp19_, (ObjectsSourceData*) _tmp22_);
		_g_object_unref0 (_tmp22_);
	} else {
		ObjectsSource* _tmp23_;
		SourceType _tmp24_;
		SourceType _tmp25_;
		_tmp23_ = return_value;
		_tmp24_ = objects_source_get_source_type (_tmp23_);
		_tmp25_ = _tmp24_;
		if (_tmp25_ == SOURCE_TYPE_CALDAV) {
			ObjectsSource* _tmp26_;
			const gchar* _tmp27_;
			ObjectsSourceCalDAVData* _tmp28_;
			ObjectsSourceCalDAVData* _tmp29_;
			_tmp26_ = return_value;
			_tmp27_ = (const gchar*) sqlite3_column_text (stmt, 9);
			_tmp28_ = objects_source_cal_dav_data_new_from_json (_tmp27_);
			_tmp29_ = _tmp28_;
			objects_source_set_data (_tmp26_, (ObjectsSourceData*) _tmp29_);
			_g_object_unref0 (_tmp29_);
		}
	}
	result = return_value;
	return result;
}

gboolean
services_database_insert_source (ServicesDatabase* self,
                                 ObjectsSource* source)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	SourceType _tmp11_;
	SourceType _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	sqlite3_stmt* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	sqlite3_stmt* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	sqlite3_stmt* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	sqlite3_stmt* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	sqlite3_stmt* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	sqlite3_stmt* _tmp30_;
	gboolean _tmp31_;
	gboolean _tmp32_;
	sqlite3_stmt* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	sqlite3_stmt* _tmp36_;
	ObjectsSourceData* _tmp37_;
	ObjectsSourceData* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp41_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Sources (id, source_type, display_na" \
"me, added_at,\n" \
"                updated_at, is_visible, child_order, sync_server, last" \
"_sync, data)\n" \
"            VALUES ($id, $source_type, $display_name, $added_at,\n" \
"                $updated_at, $is_visible, $child_order, $sync_server, " \
"$last_sync, $data);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) source);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_source_get_source_type (source);
	_tmp12_ = _tmp11_;
	_tmp13_ = source_type_to_string (_tmp12_);
	_tmp14_ = _tmp13_;
	services_database_set_parameter_str (self, _tmp10_, "$source_type", _tmp14_);
	_g_free0 (_tmp14_);
	_tmp15_ = stmt;
	_tmp16_ = objects_source_get_display_name (source);
	_tmp17_ = _tmp16_;
	services_database_set_parameter_str (self, _tmp15_, "$display_name", _tmp17_);
	_tmp18_ = stmt;
	_tmp19_ = objects_source_get_added_at (source);
	_tmp20_ = _tmp19_;
	services_database_set_parameter_str (self, _tmp18_, "$added_at", _tmp20_);
	_tmp21_ = stmt;
	_tmp22_ = objects_source_get_updated_at (source);
	_tmp23_ = _tmp22_;
	services_database_set_parameter_str (self, _tmp21_, "$updated_at", _tmp23_);
	_tmp24_ = stmt;
	_tmp25_ = objects_source_get_is_visible (source);
	_tmp26_ = _tmp25_;
	services_database_set_parameter_bool (self, _tmp24_, "$is_visible", &_tmp26_);
	_tmp27_ = stmt;
	_tmp28_ = objects_source_get_child_order (source);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_int (self, _tmp27_, "$child_order", &_tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_source_get_sync_server (source);
	_tmp32_ = _tmp31_;
	services_database_set_parameter_bool (self, _tmp30_, "$sync_server", &_tmp32_);
	_tmp33_ = stmt;
	_tmp34_ = objects_source_get_last_sync (source);
	_tmp35_ = _tmp34_;
	services_database_set_parameter_str (self, _tmp33_, "$last_sync", _tmp35_);
	_tmp36_ = stmt;
	_tmp37_ = objects_source_get_data (source);
	_tmp38_ = _tmp37_;
	_tmp39_ = objects_source_data_to_json (_tmp38_);
	_tmp40_ = _tmp39_;
	services_database_set_parameter_str (self, _tmp36_, "$data", _tmp40_);
	_g_free0 (_tmp40_);
	_tmp41_ = stmt;
	_result_ = sqlite3_step (_tmp41_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp42_;
		sqlite3* _tmp43_;
		const gchar* _tmp44_;
		_tmp42_ = self->priv->db;
		_tmp43_ = self->priv->db;
		_tmp44_ = sqlite3_errmsg (_tmp43_);
		g_warning ("Database.vala:855: Error: %d: %s", sqlite3_errcode (_tmp42_), _tmp44_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_delete_source (ServicesDatabase* self,
                                 ObjectsSource* source)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Sources WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) source);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:874: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_source (ServicesDatabase* self,
                                 ObjectsSource* source)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	SourceType _tmp8_;
	SourceType _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	sqlite3_stmt* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	sqlite3_stmt* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	sqlite3_stmt* _tmp18_;
	gboolean _tmp19_;
	gboolean _tmp20_;
	sqlite3_stmt* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	sqlite3_stmt* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	sqlite3_stmt* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	sqlite3_stmt* _tmp30_;
	ObjectsSourceData* _tmp31_;
	ObjectsSourceData* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	sqlite3_stmt* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp38_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Sources SET\n" \
"                source_type=$source_type,\n" \
"                display_name=$display_name,\n" \
"                updated_at=$updated_at,\n" \
"                is_visible=$is_visible,\n" \
"                child_order=$child_order,\n" \
"                sync_server=$sync_server,\n" \
"                last_sync=$last_sync,\n" \
"                data=$data\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_source_get_source_type (source);
	_tmp9_ = _tmp8_;
	_tmp10_ = source_type_to_string (_tmp9_);
	_tmp11_ = _tmp10_;
	services_database_set_parameter_str (self, _tmp7_, "$source_type", _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = stmt;
	_tmp13_ = objects_source_get_display_name (source);
	_tmp14_ = _tmp13_;
	services_database_set_parameter_str (self, _tmp12_, "$display_name", _tmp14_);
	_tmp15_ = stmt;
	_tmp16_ = objects_source_get_updated_at (source);
	_tmp17_ = _tmp16_;
	services_database_set_parameter_str (self, _tmp15_, "$updated_at", _tmp17_);
	_tmp18_ = stmt;
	_tmp19_ = objects_source_get_is_visible (source);
	_tmp20_ = _tmp19_;
	services_database_set_parameter_bool (self, _tmp18_, "$is_visible", &_tmp20_);
	_tmp21_ = stmt;
	_tmp22_ = objects_source_get_child_order (source);
	_tmp23_ = _tmp22_;
	services_database_set_parameter_int (self, _tmp21_, "$child_order", &_tmp23_);
	_tmp24_ = stmt;
	_tmp25_ = objects_source_get_sync_server (source);
	_tmp26_ = _tmp25_;
	services_database_set_parameter_bool (self, _tmp24_, "$sync_server", &_tmp26_);
	_tmp27_ = stmt;
	_tmp28_ = objects_source_get_last_sync (source);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_str (self, _tmp27_, "$last_sync", _tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_source_get_data (source);
	_tmp32_ = _tmp31_;
	_tmp33_ = objects_source_data_to_json (_tmp32_);
	_tmp34_ = _tmp33_;
	services_database_set_parameter_str (self, _tmp30_, "$data", _tmp34_);
	_g_free0 (_tmp34_);
	_tmp35_ = stmt;
	_tmp36_ = objects_base_object_get_id ((ObjectsBaseObject*) source);
	_tmp37_ = _tmp36_;
	services_database_set_parameter_str (self, _tmp35_, "$id", _tmp37_);
	_tmp38_ = stmt;
	_result_ = sqlite3_step (_tmp38_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp39_;
		sqlite3* _tmp40_;
		const gchar* _tmp41_;
		_tmp39_ = self->priv->db;
		_tmp40_ = self->priv->db;
		_tmp41_ = sqlite3_errmsg (_tmp40_);
		g_warning ("Database.vala:910: Error: %d: %s", sqlite3_errcode (_tmp39_), _tmp41_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_projects_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_PROJECT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n" \
"            SELECT * FROM Projects WHERE is_deleted = 0 ORDER BY child" \
"_order;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsProject* _tmp11_;
		ObjectsProject* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_project (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsProject*
_services_database_fill_project (ServicesDatabase* self,
                                 sqlite3_stmt* stmt)
{
	ObjectsProject* return_value = NULL;
	ObjectsProject* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	ObjectsProject* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_project_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_base_object_set_name ((ObjectsBaseObject*) return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_base_object_set_color ((ObjectsBaseObject*) return_value, _tmp3_);
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_project_set_backend_type (return_value, source_type_parse (_tmp4_));
	objects_project_set_inbox_project (return_value, services_database_get_parameter_bool (self, stmt, 4));
	objects_project_set_team_inbox (return_value, services_database_get_parameter_bool (self, stmt, 5));
	objects_project_set_child_order (return_value, sqlite3_column_int (stmt, 6));
	objects_project_set_is_deleted (return_value, services_database_get_parameter_bool (self, stmt, 7));
	objects_project_set_is_archived (return_value, services_database_get_parameter_bool (self, stmt, 8));
	objects_project_set_is_favorite (return_value, services_database_get_parameter_bool (self, stmt, 9));
	objects_project_set_shared (return_value, services_database_get_parameter_bool (self, stmt, 10));
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 11);
	objects_project_set_view_style (return_value, project_view_style_parse (_tmp5_));
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 12);
	objects_project_set_sort_order (return_value, sort_order_type_parse (_tmp6_));
	_tmp7_ = (const gchar*) sqlite3_column_text (stmt, 13);
	objects_project_set_parent_id (return_value, _tmp7_);
	objects_project_set_collapsed (return_value, services_database_get_parameter_bool (self, stmt, 14));
	_tmp8_ = (const gchar*) sqlite3_column_text (stmt, 15);
	objects_project_set_icon_style (return_value, project_icon_style_parse (_tmp8_));
	_tmp9_ = (const gchar*) sqlite3_column_text (stmt, 16);
	objects_project_set_emoji (return_value, _tmp9_);
	objects_project_set_show_completed (return_value, services_database_get_parameter_bool (self, stmt, 17));
	_tmp10_ = (const gchar*) sqlite3_column_text (stmt, 18);
	objects_project_set_description (return_value, _tmp10_);
	_tmp11_ = (const gchar*) sqlite3_column_text (stmt, 19);
	objects_project_set_due_date (return_value, _tmp11_);
	objects_project_set_inbox_section_hidded (return_value, services_database_get_parameter_bool (self, stmt, 20));
	_tmp12_ = (const gchar*) sqlite3_column_text (stmt, 21);
	objects_project_set_sync_id (return_value, _tmp12_);
	_tmp13_ = (const gchar*) sqlite3_column_text (stmt, 22);
	objects_project_set_source_id (return_value, _tmp13_);
	_tmp14_ = (const gchar*) sqlite3_column_text (stmt, 23);
	objects_project_set_calendar_url (return_value, _tmp14_);
	_tmp15_ = (const gchar*) sqlite3_column_text (stmt, 24);
	objects_project_set_sorted_by (return_value, sorted_by_type_parse (_tmp15_));
	_tmp16_ = (const gchar*) sqlite3_column_text (stmt, 25);
	objects_project_set_calendar_source_uid (return_value, _tmp16_);
	_tmp17_ = (const gchar*) sqlite3_column_text (stmt, 26);
	objects_project_set_markdown_setting (return_value, markdown_setting_parse (_tmp17_));
	result = return_value;
	return result;
}

gboolean
services_database_insert_project (ServicesDatabase* self,
                                  ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	SourceType _tmp17_;
	SourceType _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	sqlite3_stmt* _tmp21_;
	gboolean _tmp22_;
	gboolean _tmp23_;
	sqlite3_stmt* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	sqlite3_stmt* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	sqlite3_stmt* _tmp30_;
	gboolean _tmp31_;
	gboolean _tmp32_;
	sqlite3_stmt* _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp35_;
	sqlite3_stmt* _tmp36_;
	gboolean _tmp37_;
	gboolean _tmp38_;
	sqlite3_stmt* _tmp39_;
	gboolean _tmp40_;
	gboolean _tmp41_;
	sqlite3_stmt* _tmp42_;
	ProjectViewStyle _tmp43_;
	ProjectViewStyle _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	sqlite3_stmt* _tmp47_;
	SortOrderType _tmp48_;
	SortOrderType _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	sqlite3_stmt* _tmp52_;
	const gchar* _tmp53_;
	const gchar* _tmp54_;
	sqlite3_stmt* _tmp55_;
	gboolean _tmp56_;
	gboolean _tmp57_;
	sqlite3_stmt* _tmp58_;
	ProjectIconStyle _tmp59_;
	ProjectIconStyle _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	sqlite3_stmt* _tmp63_;
	const gchar* _tmp64_;
	const gchar* _tmp65_;
	sqlite3_stmt* _tmp66_;
	gboolean _tmp67_;
	gboolean _tmp68_;
	sqlite3_stmt* _tmp69_;
	const gchar* _tmp70_;
	const gchar* _tmp71_;
	sqlite3_stmt* _tmp72_;
	const gchar* _tmp73_;
	const gchar* _tmp74_;
	sqlite3_stmt* _tmp75_;
	gboolean _tmp76_;
	gboolean _tmp77_;
	sqlite3_stmt* _tmp78_;
	const gchar* _tmp79_;
	const gchar* _tmp80_;
	sqlite3_stmt* _tmp81_;
	const gchar* _tmp82_;
	const gchar* _tmp83_;
	sqlite3_stmt* _tmp84_;
	const gchar* _tmp85_;
	const gchar* _tmp86_;
	sqlite3_stmt* _tmp87_;
	SortedByType _tmp88_;
	SortedByType _tmp89_;
	gchar* _tmp90_;
	gchar* _tmp91_;
	sqlite3_stmt* _tmp92_;
	const gchar* _tmp93_;
	const gchar* _tmp94_;
	sqlite3_stmt* _tmp95_;
	MarkdownSetting _tmp96_;
	MarkdownSetting _tmp97_;
	gchar* _tmp98_;
	gchar* _tmp99_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp100_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (project != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Projects (id, name, color, backend_t" \
"ype, inbox_project,\n" \
"                team_inbox, child_order, is_deleted, is_archived, is_f" \
"avorite, shared, view_style,\n" \
"                sort_order, parent_id, collapsed, icon_style, emoji, s" \
"how_completed, description, due_date,\n" \
"                inbox_section_hidded, sync_id, source_id, calendar_url" \
", sorted_by, calendar_source_uid, markdown_setting)\n" \
"            VALUES ($id, $name, $color, $backend_type, $inbox_project," \
" $team_inbox,\n" \
"                $child_order, $is_deleted, $is_archived, $is_favorite," \
" $shared, $view_style,\n" \
"                $sort_order, $parent_id, $collapsed, $icon_style, $emo" \
"ji, $show_completed, $description, $due_date,\n" \
"                $inbox_section_hidded, $sync_id, $source_id, $calendar" \
"_url, $sorted_by, $calendar_source_uid, $markdown_setting);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_name ((ObjectsBaseObject*) project);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$name", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_base_object_get_color ((ObjectsBaseObject*) project);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$color", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_project_get_backend_type (project);
	_tmp18_ = _tmp17_;
	_tmp19_ = source_type_to_string (_tmp18_);
	_tmp20_ = _tmp19_;
	services_database_set_parameter_str (self, _tmp16_, "$backend_type", _tmp20_);
	_g_free0 (_tmp20_);
	_tmp21_ = stmt;
	_tmp22_ = objects_project_get_inbox_project (project);
	_tmp23_ = _tmp22_;
	services_database_set_parameter_bool (self, _tmp21_, "$inbox_project", &_tmp23_);
	_tmp24_ = stmt;
	_tmp25_ = objects_project_get_team_inbox (project);
	_tmp26_ = _tmp25_;
	services_database_set_parameter_bool (self, _tmp24_, "$team_inbox", &_tmp26_);
	_tmp27_ = stmt;
	_tmp28_ = objects_project_get_child_order (project);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_int (self, _tmp27_, "$child_order", &_tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_project_get_is_deleted (project);
	_tmp32_ = _tmp31_;
	services_database_set_parameter_bool (self, _tmp30_, "$is_deleted", &_tmp32_);
	_tmp33_ = stmt;
	_tmp34_ = objects_project_get_is_archived (project);
	_tmp35_ = _tmp34_;
	services_database_set_parameter_bool (self, _tmp33_, "$is_archived", &_tmp35_);
	_tmp36_ = stmt;
	_tmp37_ = objects_project_get_is_favorite (project);
	_tmp38_ = _tmp37_;
	services_database_set_parameter_bool (self, _tmp36_, "$is_favorite", &_tmp38_);
	_tmp39_ = stmt;
	_tmp40_ = objects_project_get_shared (project);
	_tmp41_ = _tmp40_;
	services_database_set_parameter_bool (self, _tmp39_, "$shared", &_tmp41_);
	_tmp42_ = stmt;
	_tmp43_ = objects_project_get_view_style (project);
	_tmp44_ = _tmp43_;
	_tmp45_ = project_view_style_to_string (_tmp44_);
	_tmp46_ = _tmp45_;
	services_database_set_parameter_str (self, _tmp42_, "$view_style", _tmp46_);
	_g_free0 (_tmp46_);
	_tmp47_ = stmt;
	_tmp48_ = objects_project_get_sort_order (project);
	_tmp49_ = _tmp48_;
	_tmp50_ = sort_order_type_to_string (_tmp49_);
	_tmp51_ = _tmp50_;
	services_database_set_parameter_str (self, _tmp47_, "$sort_order", _tmp51_);
	_g_free0 (_tmp51_);
	_tmp52_ = stmt;
	_tmp53_ = objects_project_get_parent_id (project);
	_tmp54_ = _tmp53_;
	services_database_set_parameter_str (self, _tmp52_, "$parent_id", _tmp54_);
	_tmp55_ = stmt;
	_tmp56_ = objects_project_get_collapsed (project);
	_tmp57_ = _tmp56_;
	services_database_set_parameter_bool (self, _tmp55_, "$collapsed", &_tmp57_);
	_tmp58_ = stmt;
	_tmp59_ = objects_project_get_icon_style (project);
	_tmp60_ = _tmp59_;
	_tmp61_ = project_icon_style_to_string (_tmp60_);
	_tmp62_ = _tmp61_;
	services_database_set_parameter_str (self, _tmp58_, "$icon_style", _tmp62_);
	_g_free0 (_tmp62_);
	_tmp63_ = stmt;
	_tmp64_ = objects_project_get_emoji (project);
	_tmp65_ = _tmp64_;
	services_database_set_parameter_str (self, _tmp63_, "$emoji", _tmp65_);
	_tmp66_ = stmt;
	_tmp67_ = objects_project_get_show_completed (project);
	_tmp68_ = _tmp67_;
	services_database_set_parameter_bool (self, _tmp66_, "$show_completed", &_tmp68_);
	_tmp69_ = stmt;
	_tmp70_ = objects_project_get_description (project);
	_tmp71_ = _tmp70_;
	services_database_set_parameter_str (self, _tmp69_, "$description", _tmp71_);
	_tmp72_ = stmt;
	_tmp73_ = objects_project_get_due_date (project);
	_tmp74_ = _tmp73_;
	services_database_set_parameter_str (self, _tmp72_, "$due_date", _tmp74_);
	_tmp75_ = stmt;
	_tmp76_ = objects_project_get_inbox_section_hidded (project);
	_tmp77_ = _tmp76_;
	services_database_set_parameter_bool (self, _tmp75_, "$inbox_section_hidded", &_tmp77_);
	_tmp78_ = stmt;
	_tmp79_ = objects_project_get_sync_id (project);
	_tmp80_ = _tmp79_;
	services_database_set_parameter_str (self, _tmp78_, "$sync_id", _tmp80_);
	_tmp81_ = stmt;
	_tmp82_ = objects_project_get_source_id (project);
	_tmp83_ = _tmp82_;
	services_database_set_parameter_str (self, _tmp81_, "$source_id", _tmp83_);
	_tmp84_ = stmt;
	_tmp85_ = objects_project_get_calendar_url (project);
	_tmp86_ = _tmp85_;
	services_database_set_parameter_str (self, _tmp84_, "$calendar_url", _tmp86_);
	_tmp87_ = stmt;
	_tmp88_ = objects_project_get_sorted_by (project);
	_tmp89_ = _tmp88_;
	_tmp90_ = sorted_by_type_to_string (_tmp89_);
	_tmp91_ = _tmp90_;
	services_database_set_parameter_str (self, _tmp87_, "$sorted_by", _tmp91_);
	_g_free0 (_tmp91_);
	_tmp92_ = stmt;
	_tmp93_ = objects_project_get_calendar_source_uid (project);
	_tmp94_ = _tmp93_;
	services_database_set_parameter_str (self, _tmp92_, "$calendar_source_uid", _tmp94_);
	_tmp95_ = stmt;
	_tmp96_ = objects_project_get_markdown_setting (project);
	_tmp97_ = _tmp96_;
	_tmp98_ = markdown_setting_to_string (_tmp97_);
	_tmp99_ = _tmp98_;
	services_database_set_parameter_str (self, _tmp95_, "$markdown_setting", _tmp99_);
	_g_free0 (_tmp99_);
	_tmp100_ = stmt;
	_result_ = sqlite3_step (_tmp100_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp101_;
		sqlite3* _tmp102_;
		const gchar* _tmp103_;
		_tmp101_ = self->priv->db;
		_tmp102_ = self->priv->db;
		_tmp103_ = sqlite3_errmsg (_tmp102_);
		g_warning ("Database.vala:1016: Error: %d: %s", sqlite3_errcode (_tmp101_), _tmp103_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_delete_project (ServicesDatabase* self,
                                  ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (project != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Projects WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1035: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

void
services_database_delete_project_db (ServicesDatabase* self,
                                     ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (project != NULL);
	_tmp0_ = g_strdup ("\n" \
"            DELETE FROM Projects WHERE id=$id;\n" \
"            DELETE FROM Items WHERE project_id=$item_project_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$section_project_id", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$item_project_id", _tmp15_);
	_tmp16_ = stmt;
	if (sqlite3_step (_tmp16_) != SQLITE_DONE) {
		sqlite3* _tmp17_;
		sqlite3* _tmp18_;
		const gchar* _tmp19_;
		_tmp17_ = self->priv->db;
		_tmp18_ = self->priv->db;
		_tmp19_ = sqlite3_errmsg (_tmp18_);
		g_warning ("Database.vala:1056: Error: %d: %s", sqlite3_errcode (_tmp17_), _tmp19_);
	}
	_sqlite3_finalize0 (stmt);
}

gboolean
services_database_update_project (ServicesDatabase* self,
                                  ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	SourceType _tmp14_;
	SourceType _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	sqlite3_stmt* _tmp18_;
	gboolean _tmp19_;
	gboolean _tmp20_;
	sqlite3_stmt* _tmp21_;
	gboolean _tmp22_;
	gboolean _tmp23_;
	sqlite3_stmt* _tmp24_;
	gint _tmp25_;
	gint _tmp26_;
	sqlite3_stmt* _tmp27_;
	gboolean _tmp28_;
	gboolean _tmp29_;
	sqlite3_stmt* _tmp30_;
	gboolean _tmp31_;
	gboolean _tmp32_;
	sqlite3_stmt* _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp35_;
	sqlite3_stmt* _tmp36_;
	gboolean _tmp37_;
	gboolean _tmp38_;
	sqlite3_stmt* _tmp39_;
	ProjectViewStyle _tmp40_;
	ProjectViewStyle _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	sqlite3_stmt* _tmp44_;
	SortOrderType _tmp45_;
	SortOrderType _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	sqlite3_stmt* _tmp49_;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	sqlite3_stmt* _tmp52_;
	gboolean _tmp53_;
	gboolean _tmp54_;
	sqlite3_stmt* _tmp55_;
	ProjectIconStyle _tmp56_;
	ProjectIconStyle _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	sqlite3_stmt* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	sqlite3_stmt* _tmp63_;
	gboolean _tmp64_;
	gboolean _tmp65_;
	sqlite3_stmt* _tmp66_;
	const gchar* _tmp67_;
	const gchar* _tmp68_;
	sqlite3_stmt* _tmp69_;
	const gchar* _tmp70_;
	const gchar* _tmp71_;
	sqlite3_stmt* _tmp72_;
	gboolean _tmp73_;
	gboolean _tmp74_;
	const gchar* _tmp75_;
	const gchar* _tmp76_;
	sqlite3_stmt* _tmp80_;
	const gchar* _tmp81_;
	const gchar* _tmp82_;
	sqlite3_stmt* _tmp83_;
	const gchar* _tmp84_;
	const gchar* _tmp85_;
	sqlite3_stmt* _tmp86_;
	SortedByType _tmp87_;
	SortedByType _tmp88_;
	gchar* _tmp89_;
	gchar* _tmp90_;
	sqlite3_stmt* _tmp91_;
	const gchar* _tmp92_;
	const gchar* _tmp93_;
	sqlite3_stmt* _tmp94_;
	MarkdownSetting _tmp95_;
	MarkdownSetting _tmp96_;
	gchar* _tmp97_;
	gchar* _tmp98_;
	sqlite3_stmt* _tmp99_;
	const gchar* _tmp100_;
	const gchar* _tmp101_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp102_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (project != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Projects SET\n" \
"                name=$name,\n" \
"                color=$color,\n" \
"                backend_type=$backend_type,\n" \
"                inbox_project=$inbox_project,\n" \
"                team_inbox=$team_inbox,\n" \
"                child_order=$child_order,\n" \
"                is_deleted=$is_deleted,\n" \
"                is_archived=$is_archived,\n" \
"                is_favorite=$is_favorite,\n" \
"                shared=$shared,\n" \
"                view_style=$view_style,\n" \
"                sort_order=$sort_order,\n" \
"                parent_id=$parent_id,\n" \
"                collapsed=$collapsed,\n" \
"                icon_style=$icon_style,\n" \
"                emoji=$emoji,\n" \
"                show_completed=$show_completed,\n" \
"                description=$description,\n" \
"                due_date=$due_date,\n" \
"                inbox_section_hidded=$inbox_section_hidded,\n" \
"                sync_id=$sync_id,\n" \
"                source_id=$source_id,\n" \
"                calendar_url=$calendar_url,\n" \
"                sorted_by=$sorted_by,\n" \
"                calendar_source_uid=$calendar_source_uid,\n" \
"                markdown_setting=$markdown_setting\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_name ((ObjectsBaseObject*) project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$name", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_color ((ObjectsBaseObject*) project);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$color", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_project_get_backend_type (project);
	_tmp15_ = _tmp14_;
	_tmp16_ = source_type_to_string (_tmp15_);
	_tmp17_ = _tmp16_;
	services_database_set_parameter_str (self, _tmp13_, "$backend_type", _tmp17_);
	_g_free0 (_tmp17_);
	_tmp18_ = stmt;
	_tmp19_ = objects_project_get_inbox_project (project);
	_tmp20_ = _tmp19_;
	services_database_set_parameter_bool (self, _tmp18_, "$inbox_project", &_tmp20_);
	_tmp21_ = stmt;
	_tmp22_ = objects_project_get_team_inbox (project);
	_tmp23_ = _tmp22_;
	services_database_set_parameter_bool (self, _tmp21_, "$team_inbox", &_tmp23_);
	_tmp24_ = stmt;
	_tmp25_ = objects_project_get_child_order (project);
	_tmp26_ = _tmp25_;
	services_database_set_parameter_int (self, _tmp24_, "$child_order", &_tmp26_);
	_tmp27_ = stmt;
	_tmp28_ = objects_project_get_is_deleted (project);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_bool (self, _tmp27_, "$is_deleted", &_tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_project_get_is_archived (project);
	_tmp32_ = _tmp31_;
	services_database_set_parameter_bool (self, _tmp30_, "$is_archived", &_tmp32_);
	_tmp33_ = stmt;
	_tmp34_ = objects_project_get_is_favorite (project);
	_tmp35_ = _tmp34_;
	services_database_set_parameter_bool (self, _tmp33_, "$is_favorite", &_tmp35_);
	_tmp36_ = stmt;
	_tmp37_ = objects_project_get_shared (project);
	_tmp38_ = _tmp37_;
	services_database_set_parameter_bool (self, _tmp36_, "$shared", &_tmp38_);
	_tmp39_ = stmt;
	_tmp40_ = objects_project_get_view_style (project);
	_tmp41_ = _tmp40_;
	_tmp42_ = project_view_style_to_string (_tmp41_);
	_tmp43_ = _tmp42_;
	services_database_set_parameter_str (self, _tmp39_, "$view_style", _tmp43_);
	_g_free0 (_tmp43_);
	_tmp44_ = stmt;
	_tmp45_ = objects_project_get_sort_order (project);
	_tmp46_ = _tmp45_;
	_tmp47_ = sort_order_type_to_string (_tmp46_);
	_tmp48_ = _tmp47_;
	services_database_set_parameter_str (self, _tmp44_, "$sort_order", _tmp48_);
	_g_free0 (_tmp48_);
	_tmp49_ = stmt;
	_tmp50_ = objects_project_get_parent_id (project);
	_tmp51_ = _tmp50_;
	services_database_set_parameter_str (self, _tmp49_, "$parent_id", _tmp51_);
	_tmp52_ = stmt;
	_tmp53_ = objects_project_get_collapsed (project);
	_tmp54_ = _tmp53_;
	services_database_set_parameter_bool (self, _tmp52_, "$collapsed", &_tmp54_);
	_tmp55_ = stmt;
	_tmp56_ = objects_project_get_icon_style (project);
	_tmp57_ = _tmp56_;
	_tmp58_ = project_icon_style_to_string (_tmp57_);
	_tmp59_ = _tmp58_;
	services_database_set_parameter_str (self, _tmp55_, "$icon_style", _tmp59_);
	_g_free0 (_tmp59_);
	_tmp60_ = stmt;
	_tmp61_ = objects_project_get_emoji (project);
	_tmp62_ = _tmp61_;
	services_database_set_parameter_str (self, _tmp60_, "$emoji", _tmp62_);
	_tmp63_ = stmt;
	_tmp64_ = objects_project_get_show_completed (project);
	_tmp65_ = _tmp64_;
	services_database_set_parameter_bool (self, _tmp63_, "$show_completed", &_tmp65_);
	_tmp66_ = stmt;
	_tmp67_ = objects_project_get_description (project);
	_tmp68_ = _tmp67_;
	services_database_set_parameter_str (self, _tmp66_, "$description", _tmp68_);
	_tmp69_ = stmt;
	_tmp70_ = objects_project_get_due_date (project);
	_tmp71_ = _tmp70_;
	services_database_set_parameter_str (self, _tmp69_, "$due_date", _tmp71_);
	_tmp72_ = stmt;
	_tmp73_ = objects_project_get_inbox_section_hidded (project);
	_tmp74_ = _tmp73_;
	services_database_set_parameter_bool (self, _tmp72_, "$inbox_section_hidded", &_tmp74_);
	_tmp75_ = objects_project_get_sync_id (project);
	_tmp76_ = _tmp75_;
	if (_tmp76_ != NULL) {
		sqlite3_stmt* _tmp77_;
		const gchar* _tmp78_;
		const gchar* _tmp79_;
		_tmp77_ = stmt;
		_tmp78_ = objects_project_get_sync_id (project);
		_tmp79_ = _tmp78_;
		services_database_set_parameter_str (self, _tmp77_, "$sync_id", _tmp79_);
	}
	_tmp80_ = stmt;
	_tmp81_ = objects_project_get_source_id (project);
	_tmp82_ = _tmp81_;
	services_database_set_parameter_str (self, _tmp80_, "$source_id", _tmp82_);
	_tmp83_ = stmt;
	_tmp84_ = objects_project_get_calendar_url (project);
	_tmp85_ = _tmp84_;
	services_database_set_parameter_str (self, _tmp83_, "$calendar_url", _tmp85_);
	_tmp86_ = stmt;
	_tmp87_ = objects_project_get_sorted_by (project);
	_tmp88_ = _tmp87_;
	_tmp89_ = sorted_by_type_to_string (_tmp88_);
	_tmp90_ = _tmp89_;
	services_database_set_parameter_str (self, _tmp86_, "$sorted_by", _tmp90_);
	_g_free0 (_tmp90_);
	_tmp91_ = stmt;
	_tmp92_ = objects_project_get_calendar_source_uid (project);
	_tmp93_ = _tmp92_;
	services_database_set_parameter_str (self, _tmp91_, "$calendar_source_uid", _tmp93_);
	_tmp94_ = stmt;
	_tmp95_ = objects_project_get_markdown_setting (project);
	_tmp96_ = _tmp95_;
	_tmp97_ = markdown_setting_to_string (_tmp96_);
	_tmp98_ = _tmp97_;
	services_database_set_parameter_str (self, _tmp94_, "$markdown_setting", _tmp98_);
	_g_free0 (_tmp98_);
	_tmp99_ = stmt;
	_tmp100_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp101_ = _tmp100_;
	services_database_set_parameter_str (self, _tmp99_, "$id", _tmp101_);
	_tmp102_ = stmt;
	_result_ = sqlite3_step (_tmp102_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp103_;
		sqlite3* _tmp104_;
		const gchar* _tmp105_;
		_tmp103_ = self->priv->db;
		_tmp104_ = self->priv->db;
		_tmp105_ = sqlite3_errmsg (_tmp104_);
		g_warning ("Database.vala:1127: Error: %d: %s", sqlite3_errcode (_tmp103_), _tmp105_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_archive_project (ServicesDatabase* self,
                                   ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (project != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Projects SET is_archived=$is_archived WHERE id=$id;" \
"\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_project_get_is_archived (project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_bool (self, _tmp7_, "$is_archived", &_tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$id", _tmp12_);
	_tmp13_ = stmt;
	_result_ = sqlite3_step (_tmp13_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp14_;
		sqlite3* _tmp15_;
		const gchar* _tmp16_;
		_tmp14_ = self->priv->db;
		_tmp15_ = self->priv->db;
		_tmp16_ = sqlite3_errmsg (_tmp15_);
		g_warning ("Database.vala:1147: Error: %d: %s", sqlite3_errcode (_tmp14_), _tmp16_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_labels_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_LABEL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n            SELECT * FROM Labels;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsLabel* _tmp11_;
		ObjectsLabel* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_label (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsLabel*
_services_database_fill_label (ServicesDatabase* self,
                               sqlite3_stmt* stmt)
{
	ObjectsLabel* return_value = NULL;
	ObjectsLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	ObjectsLabel* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_label_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_base_object_set_name ((ObjectsBaseObject*) return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_base_object_set_color ((ObjectsBaseObject*) return_value, _tmp3_);
	objects_label_set_item_order (return_value, sqlite3_column_int (stmt, 3));
	objects_label_set_is_deleted (return_value, services_database_get_parameter_bool (self, stmt, 4));
	objects_label_set_is_favorite (return_value, services_database_get_parameter_bool (self, stmt, 5));
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 6);
	objects_label_set_backend_type (return_value, source_type_parse (_tmp4_));
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 7);
	objects_label_set_source_id (return_value, _tmp5_);
	result = return_value;
	return result;
}

gboolean
services_database_insert_label (ServicesDatabase* self,
                                ObjectsLabel* label)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	sqlite3_stmt* _tmp19_;
	gboolean _tmp20_;
	gboolean _tmp21_;
	sqlite3_stmt* _tmp22_;
	gboolean _tmp23_;
	gboolean _tmp24_;
	sqlite3_stmt* _tmp25_;
	SourceType _tmp26_;
	SourceType _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	sqlite3_stmt* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp33_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (label != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Labels (id, name, color, item_order," \
"\n" \
"                is_deleted, is_favorite, backend_type, source_id)\n" \
"            VALUES ($id, $name, $color, $item_order,\n" \
"                $is_deleted, $is_favorite, $backend_type, $source_id);" \
"\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_name ((ObjectsBaseObject*) label);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$name", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_base_object_get_color ((ObjectsBaseObject*) label);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$color", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_label_get_item_order (label);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_int (self, _tmp16_, "$item_order", &_tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_label_get_is_deleted (label);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_bool (self, _tmp19_, "$is_deleted", &_tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_label_get_is_favorite (label);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_bool (self, _tmp22_, "$is_favorite", &_tmp24_);
	_tmp25_ = stmt;
	_tmp26_ = objects_label_get_backend_type (label);
	_tmp27_ = _tmp26_;
	_tmp28_ = source_type_to_string (_tmp27_);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_str (self, _tmp25_, "$backend_type", _tmp29_);
	_g_free0 (_tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_label_get_source_id (label);
	_tmp32_ = _tmp31_;
	services_database_set_parameter_str (self, _tmp30_, "$source_id", _tmp32_);
	_tmp33_ = stmt;
	_result_ = sqlite3_step (_tmp33_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp34_;
		sqlite3* _tmp35_;
		const gchar* _tmp36_;
		_tmp34_ = self->priv->db;
		_tmp35_ = self->priv->db;
		_tmp36_ = sqlite3_errmsg (_tmp35_);
		g_warning ("Database.vala:1210: Error: %d: %s", sqlite3_errcode (_tmp34_), _tmp36_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_delete_label (ServicesDatabase* self,
                                ObjectsLabel* label)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (label != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Labels WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1229: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_label (ServicesDatabase* self,
                                ObjectsLabel* label)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	sqlite3_stmt* _tmp16_;
	gboolean _tmp17_;
	gboolean _tmp18_;
	sqlite3_stmt* _tmp19_;
	gboolean _tmp20_;
	gboolean _tmp21_;
	sqlite3_stmt* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp25_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (label != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Labels SET name=$name, color=$color, item_order=$it" \
"em_order,\n" \
"                is_deleted=$is_deleted, is_favorite=$is_favorite\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_name ((ObjectsBaseObject*) label);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$name", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_color ((ObjectsBaseObject*) label);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$color", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_label_get_item_order (label);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_int (self, _tmp13_, "$item_order", &_tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_label_get_is_deleted (label);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_bool (self, _tmp16_, "$is_deleted", &_tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_label_get_is_favorite (label);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_bool (self, _tmp19_, "$is_favorite", &_tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_base_object_get_id ((ObjectsBaseObject*) label);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_str (self, _tmp22_, "$id", _tmp24_);
	_tmp25_ = stmt;
	_result_ = sqlite3_step (_tmp25_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp26_;
		sqlite3* _tmp27_;
		const gchar* _tmp28_;
		_tmp26_ = self->priv->db;
		_tmp27_ = self->priv->db;
		_tmp28_ = sqlite3_errmsg (_tmp27_);
		g_warning ("Database.vala:1255: Error: %d: %s", sqlite3_errcode (_tmp26_), _tmp28_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_insert_section (ServicesDatabase* self,
                                  ObjectsSection* section)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	sqlite3_stmt* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	sqlite3_stmt* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	sqlite3_stmt* _tmp25_;
	gboolean _tmp26_;
	gboolean _tmp27_;
	sqlite3_stmt* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	sqlite3_stmt* _tmp31_;
	gboolean _tmp32_;
	gboolean _tmp33_;
	sqlite3_stmt* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	sqlite3_stmt* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	sqlite3_stmt* _tmp40_;
	gboolean _tmp41_;
	gboolean _tmp42_;
	sqlite3_stmt* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp46_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Sections (id, name, archived_at, add" \
"ed_at, project_id, section_order,\n" \
"            collapsed, is_deleted, is_archived, color, description, hi" \
"dded, extra_data)\n" \
"            VALUES ($id, $name, $archived_at, $added_at, $project_id, " \
"$section_order,\n" \
"            $collapsed, $is_deleted, $is_archived, $color, $descriptio" \
"n, $hidded, $extra_data);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_name ((ObjectsBaseObject*) section);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$name", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_section_get_archived_at (section);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$archived_at", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_section_get_added_at (section);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_str (self, _tmp16_, "$added_at", _tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_section_get_project_id (section);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_str (self, _tmp19_, "$project_id", _tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_section_get_section_order (section);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_int (self, _tmp22_, "$section_order", &_tmp24_);
	_tmp25_ = stmt;
	_tmp26_ = objects_section_get_collapsed (section);
	_tmp27_ = _tmp26_;
	services_database_set_parameter_bool (self, _tmp25_, "$collapsed", &_tmp27_);
	_tmp28_ = stmt;
	_tmp29_ = objects_section_get_is_deleted (section);
	_tmp30_ = _tmp29_;
	services_database_set_parameter_bool (self, _tmp28_, "$is_deleted", &_tmp30_);
	_tmp31_ = stmt;
	_tmp32_ = objects_section_get_is_archived (section);
	_tmp33_ = _tmp32_;
	services_database_set_parameter_bool (self, _tmp31_, "$is_archived", &_tmp33_);
	_tmp34_ = stmt;
	_tmp35_ = objects_base_object_get_color ((ObjectsBaseObject*) section);
	_tmp36_ = _tmp35_;
	services_database_set_parameter_str (self, _tmp34_, "$color", _tmp36_);
	_tmp37_ = stmt;
	_tmp38_ = objects_section_get_description (section);
	_tmp39_ = _tmp38_;
	services_database_set_parameter_str (self, _tmp37_, "$description", _tmp39_);
	_tmp40_ = stmt;
	_tmp41_ = objects_section_get_hidded (section);
	_tmp42_ = _tmp41_;
	services_database_set_parameter_bool (self, _tmp40_, "$hidded", &_tmp42_);
	_tmp43_ = stmt;
	_tmp44_ = objects_section_get_extra_data (section);
	_tmp45_ = _tmp44_;
	services_database_set_parameter_str (self, _tmp43_, "$extra_data", _tmp45_);
	_tmp46_ = stmt;
	_result_ = sqlite3_step (_tmp46_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp47_;
		sqlite3* _tmp48_;
		const gchar* _tmp49_;
		_tmp47_ = self->priv->db;
		_tmp48_ = self->priv->db;
		_tmp49_ = sqlite3_errmsg (_tmp48_);
		g_warning ("Database.vala:1293: Error: %d: %s", sqlite3_errcode (_tmp47_), _tmp49_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_sections_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_SECTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("SELECT * FROM Sections WHERE is_deleted = 0;");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsSection* _tmp11_;
		ObjectsSection* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_section (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsSection*
_services_database_fill_section (ServicesDatabase* self,
                                 sqlite3_stmt* stmt)
{
	ObjectsSection* return_value = NULL;
	ObjectsSection* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	ObjectsSection* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_section_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_base_object_set_name ((ObjectsBaseObject*) return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_section_set_archived_at (return_value, _tmp3_);
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_section_set_added_at (return_value, _tmp4_);
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_section_set_project_id (return_value, _tmp5_);
	objects_section_set_section_order (return_value, sqlite3_column_int (stmt, 5));
	objects_section_set_collapsed (return_value, services_database_get_parameter_bool (self, stmt, 6));
	objects_section_set_is_deleted (return_value, services_database_get_parameter_bool (self, stmt, 7));
	objects_section_set_is_archived (return_value, services_database_get_parameter_bool (self, stmt, 8));
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 9);
	objects_base_object_set_color ((ObjectsBaseObject*) return_value, _tmp6_);
	_tmp7_ = (const gchar*) sqlite3_column_text (stmt, 10);
	objects_section_set_description (return_value, _tmp7_);
	objects_section_set_hidded (return_value, services_database_get_parameter_bool (self, stmt, 11));
	_tmp8_ = (const gchar*) sqlite3_column_text (stmt, 12);
	objects_section_set_extra_data (return_value, _tmp8_);
	result = return_value;
	return result;
}

gboolean
services_database_delete_section (ServicesDatabase* self,
                                  ObjectsSection* section)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Sections WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1345: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_section (ServicesDatabase* self,
                                  ObjectsSection* section)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	sqlite3_stmt* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	sqlite3_stmt* _tmp22_;
	gboolean _tmp23_;
	gboolean _tmp24_;
	sqlite3_stmt* _tmp25_;
	gboolean _tmp26_;
	gboolean _tmp27_;
	sqlite3_stmt* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	sqlite3_stmt* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	sqlite3_stmt* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	sqlite3_stmt* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	sqlite3_stmt* _tmp40_;
	const gchar* _tmp41_;
	const gchar* _tmp42_;
	sqlite3_stmt* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp46_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Sections SET name=$name, archived_at=$archived_at, " \
"added_at=$added_at,\n" \
"                project_id=$project_id, section_order=$section_order, " \
"collapsed=$collapsed,\n" \
"                is_deleted=$is_deleted, is_archived=$is_archived, colo" \
"r=$color, description=$description,\n" \
"                hidded=$hidded, extra_data=$extra_data\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_name ((ObjectsBaseObject*) section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$name", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_section_get_archived_at (section);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$archived_at", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_section_get_added_at (section);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$added_at", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_section_get_project_id (section);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_str (self, _tmp16_, "$project_id", _tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_section_get_section_order (section);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_int (self, _tmp19_, "$section_order", &_tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_section_get_collapsed (section);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_bool (self, _tmp22_, "$collapsed", &_tmp24_);
	_tmp25_ = stmt;
	_tmp26_ = objects_section_get_is_deleted (section);
	_tmp27_ = _tmp26_;
	services_database_set_parameter_bool (self, _tmp25_, "$is_deleted", &_tmp27_);
	_tmp28_ = stmt;
	_tmp29_ = objects_section_get_is_archived (section);
	_tmp30_ = _tmp29_;
	services_database_set_parameter_bool (self, _tmp28_, "$is_archived", &_tmp30_);
	_tmp31_ = stmt;
	_tmp32_ = objects_base_object_get_color ((ObjectsBaseObject*) section);
	_tmp33_ = _tmp32_;
	services_database_set_parameter_str (self, _tmp31_, "$color", _tmp33_);
	_tmp34_ = stmt;
	_tmp35_ = objects_section_get_description (section);
	_tmp36_ = _tmp35_;
	services_database_set_parameter_str (self, _tmp34_, "$description", _tmp36_);
	_tmp37_ = stmt;
	_tmp38_ = objects_section_get_hidded (section);
	_tmp39_ = _tmp38_;
	services_database_set_parameter_bool (self, _tmp37_, "$hidded", &_tmp39_);
	_tmp40_ = stmt;
	_tmp41_ = objects_section_get_extra_data (section);
	_tmp42_ = _tmp41_;
	services_database_set_parameter_str (self, _tmp40_, "$extra_data", _tmp42_);
	_tmp43_ = stmt;
	_tmp44_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp45_ = _tmp44_;
	services_database_set_parameter_str (self, _tmp43_, "$id", _tmp45_);
	_tmp46_ = stmt;
	_result_ = sqlite3_step (_tmp46_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp47_;
		sqlite3* _tmp48_;
		const gchar* _tmp49_;
		_tmp47_ = self->priv->db;
		_tmp48_ = self->priv->db;
		_tmp49_ = sqlite3_errmsg (_tmp48_);
		g_warning ("Database.vala:1380: Error: %d: %s", sqlite3_errcode (_tmp47_), _tmp49_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_move_section (ServicesDatabase* self,
                                ObjectsSection* section,
                                const gchar* old_project_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	g_return_val_if_fail (old_project_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Sections SET project_id=$project_id WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_section_get_project_id (section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$project_id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$id", _tmp12_);
	_tmp13_ = stmt;
	_result_ = sqlite3_step (_tmp13_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp14_;
		sqlite3* _tmp15_;
		const gchar* _tmp16_;
		_tmp14_ = self->priv->db;
		_tmp15_ = self->priv->db;
		_tmp16_ = sqlite3_errmsg (_tmp15_);
		g_warning ("Database.vala:1400: Error: %d: %s", sqlite3_errcode (_tmp14_), _tmp16_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_move_section_items (ServicesDatabase* self,
                                      ObjectsSection* section)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET project_id=$project_id WHERE section_id=$" \
"section_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_section_get_project_id (section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$project_id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$section_id", _tmp12_);
	_tmp13_ = stmt;
	_result_ = sqlite3_step (_tmp13_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp14_;
		sqlite3* _tmp15_;
		const gchar* _tmp16_;
		_tmp14_ = self->priv->db;
		_tmp15_ = self->priv->db;
		_tmp16_ = sqlite3_errmsg (_tmp15_);
		g_warning ("Database.vala:1420: Error: %d: %s", sqlite3_errcode (_tmp14_), _tmp16_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_archive_section (ServicesDatabase* self,
                                   ObjectsSection* section)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (section != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Sections SET is_archived=$is_archived WHERE id=$id;" \
"\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_section_get_is_archived (section);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_bool (self, _tmp7_, "$is_archived", &_tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_base_object_get_id ((ObjectsBaseObject*) section);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$id", _tmp12_);
	_tmp13_ = stmt;
	_result_ = sqlite3_step (_tmp13_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp14_;
		sqlite3* _tmp15_;
		const gchar* _tmp16_;
		_tmp14_ = self->priv->db;
		_tmp15_ = self->priv->db;
		_tmp16_ = sqlite3_errmsg (_tmp15_);
		g_warning ("Database.vala:1440: Error: %d: %s", sqlite3_errcode (_tmp14_), _tmp16_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_insert_item (ServicesDatabase* self,
                               ObjectsItem* item)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	ObjectsDueDate* _tmp17_;
	ObjectsDueDate* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	sqlite3_stmt* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	sqlite3_stmt* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	sqlite3_stmt* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	sqlite3_stmt* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	sqlite3_stmt* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	sqlite3_stmt* _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	sqlite3_stmt* _tmp39_;
	gint _tmp40_;
	gint _tmp41_;
	sqlite3_stmt* _tmp42_;
	gint _tmp43_;
	gint _tmp44_;
	sqlite3_stmt* _tmp45_;
	gboolean _tmp46_;
	gboolean _tmp47_;
	sqlite3_stmt* _tmp48_;
	gboolean _tmp49_;
	gboolean _tmp50_;
	sqlite3_stmt* _tmp51_;
	gint _tmp52_;
	gint _tmp53_;
	sqlite3_stmt* _tmp54_;
	gboolean _tmp55_;
	gboolean _tmp56_;
	sqlite3_stmt* _tmp57_;
	gboolean _tmp58_;
	gboolean _tmp59_;
	sqlite3_stmt* _tmp60_;
	GeeArrayList* _tmp61_;
	GeeArrayList* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	sqlite3_stmt* _tmp65_;
	const gchar* _tmp66_;
	const gchar* _tmp67_;
	sqlite3_stmt* _tmp68_;
	ItemType _tmp69_;
	ItemType _tmp70_;
	gchar* _tmp71_;
	gchar* _tmp72_;
	sqlite3_stmt* _tmp73_;
	const gchar* _tmp74_;
	const gchar* _tmp75_;
	sqlite3_stmt* _tmp76_;
	const gchar* _tmp77_;
	const gchar* _tmp78_;
	sqlite3_stmt* _tmp79_;
	const gchar* _tmp80_;
	const gchar* _tmp81_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp82_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Items (id, content, description, due" \
", added_at, completed_at,\n" \
"                updated_at, section_id, project_id, parent_id, priorit" \
"y, child_order,\n" \
"                checked, is_deleted, day_order, collapsed, pinned, lab" \
"els, extra_data, item_type, calendar_event_uid, deadline_date,\n" \
"                responsible_uid)\n" \
"            VALUES ($id, $content, $description, $due, $added_at, $com" \
"pleted_at,\n" \
"                $updated_at, $section_id, $project_id, $parent_id, $pr" \
"iority, $child_order,\n" \
"                $checked, $is_deleted, $day_order, $collapsed, $pinned" \
", $labels, $extra_data, $item_type, $calendar_event_uid, $deadline_dat" \
"e,\n" \
"                $responsible_uid);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) item);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_item_get_content (item);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$content", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_item_get_description (item);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$description", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_item_get_due (item);
	_tmp18_ = _tmp17_;
	_tmp19_ = objects_due_date_to_string (_tmp18_);
	_tmp20_ = _tmp19_;
	services_database_set_parameter_str (self, _tmp16_, "$due", _tmp20_);
	_g_free0 (_tmp20_);
	_tmp21_ = stmt;
	_tmp22_ = objects_item_get_added_at (item);
	_tmp23_ = _tmp22_;
	services_database_set_parameter_str (self, _tmp21_, "$added_at", _tmp23_);
	_tmp24_ = stmt;
	_tmp25_ = objects_item_get_completed_at (item);
	_tmp26_ = _tmp25_;
	services_database_set_parameter_str (self, _tmp24_, "$completed_at", _tmp26_);
	_tmp27_ = stmt;
	_tmp28_ = objects_item_get_updated_at (item);
	_tmp29_ = _tmp28_;
	services_database_set_parameter_str (self, _tmp27_, "$updated_at", _tmp29_);
	_tmp30_ = stmt;
	_tmp31_ = objects_item_get_section_id (item);
	_tmp32_ = _tmp31_;
	services_database_set_parameter_str (self, _tmp30_, "$section_id", _tmp32_);
	_tmp33_ = stmt;
	_tmp34_ = objects_item_get_project_id (item);
	_tmp35_ = _tmp34_;
	services_database_set_parameter_str (self, _tmp33_, "$project_id", _tmp35_);
	_tmp36_ = stmt;
	_tmp37_ = objects_item_get_parent_id (item);
	_tmp38_ = _tmp37_;
	services_database_set_parameter_str (self, _tmp36_, "$parent_id", _tmp38_);
	_tmp39_ = stmt;
	_tmp40_ = objects_item_get_priority (item);
	_tmp41_ = _tmp40_;
	services_database_set_parameter_int (self, _tmp39_, "$priority", &_tmp41_);
	_tmp42_ = stmt;
	_tmp43_ = objects_item_get_child_order (item);
	_tmp44_ = _tmp43_;
	services_database_set_parameter_int (self, _tmp42_, "$child_order", &_tmp44_);
	_tmp45_ = stmt;
	_tmp46_ = objects_item_get_checked (item);
	_tmp47_ = _tmp46_;
	services_database_set_parameter_bool (self, _tmp45_, "$checked", &_tmp47_);
	_tmp48_ = stmt;
	_tmp49_ = objects_item_get_is_deleted (item);
	_tmp50_ = _tmp49_;
	services_database_set_parameter_bool (self, _tmp48_, "$is_deleted", &_tmp50_);
	_tmp51_ = stmt;
	_tmp52_ = objects_item_get_day_order (item);
	_tmp53_ = _tmp52_;
	services_database_set_parameter_int (self, _tmp51_, "$day_order", &_tmp53_);
	_tmp54_ = stmt;
	_tmp55_ = objects_item_get_collapsed (item);
	_tmp56_ = _tmp55_;
	services_database_set_parameter_bool (self, _tmp54_, "$collapsed", &_tmp56_);
	_tmp57_ = stmt;
	_tmp58_ = objects_item_get_pinned (item);
	_tmp59_ = _tmp58_;
	services_database_set_parameter_bool (self, _tmp57_, "$pinned", &_tmp59_);
	_tmp60_ = stmt;
	_tmp61_ = objects_item_get_labels (item);
	_tmp62_ = _tmp61_;
	_tmp63_ = services_database_get_labels_ids (self, _tmp62_);
	_tmp64_ = _tmp63_;
	services_database_set_parameter_str (self, _tmp60_, "$labels", _tmp64_);
	_g_free0 (_tmp64_);
	_tmp65_ = stmt;
	_tmp66_ = objects_item_get_extra_data (item);
	_tmp67_ = _tmp66_;
	services_database_set_parameter_str (self, _tmp65_, "$extra_data", _tmp67_);
	_tmp68_ = stmt;
	_tmp69_ = objects_item_get_item_type (item);
	_tmp70_ = _tmp69_;
	_tmp71_ = item_type_to_string (_tmp70_);
	_tmp72_ = _tmp71_;
	services_database_set_parameter_str (self, _tmp68_, "$item_type", _tmp72_);
	_g_free0 (_tmp72_);
	_tmp73_ = stmt;
	_tmp74_ = objects_item_get_calendar_event_uid (item);
	_tmp75_ = _tmp74_;
	services_database_set_parameter_str (self, _tmp73_, "$calendar_event_uid", _tmp75_);
	_tmp76_ = stmt;
	_tmp77_ = objects_item_get_deadline_date (item);
	_tmp78_ = _tmp77_;
	services_database_set_parameter_str (self, _tmp76_, "$deadline_date", _tmp78_);
	_tmp79_ = stmt;
	_tmp80_ = objects_item_get_responsible_uid (item);
	_tmp81_ = _tmp80_;
	services_database_set_parameter_str (self, _tmp79_, "$responsible_uid", _tmp81_);
	_tmp82_ = stmt;
	_result_ = sqlite3_step (_tmp82_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp83_;
		sqlite3* _tmp84_;
		const gchar* _tmp85_;
		_tmp83_ = self->priv->db;
		_tmp84_ = self->priv->db;
		_tmp85_ = sqlite3_errmsg (_tmp84_);
		g_warning ("Database.vala:1492: Error: %d: %s", sqlite3_errcode (_tmp83_), _tmp85_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_insert_items_transaction (ServicesDatabase* self,
                                            GeeArrayList* items)
{
	sqlite3_stmt* stmt = NULL;
	gboolean success = FALSE;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gint _tmp4_;
	gchar* _tmp6_;
	sqlite3* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	sqlite3_stmt* _tmp12_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (items != NULL, FALSE);
	success = TRUE;
	_tmp0_ = g_strdup ("BEGIN TRANSACTION;");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp4_ = _sqlite3_exec (_tmp1_, _tmp2_, NULL, NULL, &_tmp3_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp3_;
	if (_tmp4_ != SQLITE_OK) {
		const gchar* _tmp5_;
		_tmp5_ = self->priv->errormsg;
		g_warning ("Database.vala:1505: %s", _tmp5_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	_tmp6_ = g_strdup ("\n" \
"        INSERT OR IGNORE INTO Items (id, content, description, due, ad" \
"ded_at, completed_at,\n" \
"            updated_at, section_id, project_id, parent_id, priority, c" \
"hild_order,\n" \
"            checked, is_deleted, day_order, collapsed, pinned, labels," \
" extra_data, item_type, calendar_event_uid, deadline_date,\n" \
"            responsible_uid)\n" \
"        VALUES ($id, $content, $description, $due, $added_at, $complet" \
"ed_at,\n" \
"            $updated_at, $section_id, $project_id, $parent_id, $priori" \
"ty, $child_order,\n" \
"            $checked, $is_deleted, $day_order, $collapsed, $pinned, $l" \
"abels, $extra_data, $item_type, $calendar_event_uid, $deadline_date,\n" \
"            $responsible_uid);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp6_;
	_tmp7_ = self->priv->db;
	_tmp8_ = self->priv->sql;
	_tmp9_ = self->priv->sql;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	sqlite3_prepare_v2 (_tmp7_, _tmp8_, _tmp11_, &_tmp12_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp12_;
	{
		GeeArrayList* _item_list = NULL;
		gint _item_size = 0;
		GeeArrayList* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		gint _item_index = 0;
		_item_list = items;
		_tmp13_ = _item_list;
		_tmp14_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp13_);
		_tmp15_ = _tmp14_;
		_item_size = _tmp15_;
		_item_index = -1;
		while (TRUE) {
			gint _tmp16_;
			gint _tmp17_;
			ObjectsItem* item = NULL;
			GeeArrayList* _tmp18_;
			gpointer _tmp19_;
			sqlite3_stmt* _tmp20_;
			ObjectsItem* _tmp21_;
			const gchar* _tmp22_;
			const gchar* _tmp23_;
			sqlite3_stmt* _tmp24_;
			ObjectsItem* _tmp25_;
			const gchar* _tmp26_;
			const gchar* _tmp27_;
			sqlite3_stmt* _tmp28_;
			ObjectsItem* _tmp29_;
			const gchar* _tmp30_;
			const gchar* _tmp31_;
			sqlite3_stmt* _tmp32_;
			ObjectsItem* _tmp33_;
			ObjectsDueDate* _tmp34_;
			ObjectsDueDate* _tmp35_;
			gchar* _tmp36_;
			gchar* _tmp37_;
			sqlite3_stmt* _tmp38_;
			ObjectsItem* _tmp39_;
			const gchar* _tmp40_;
			const gchar* _tmp41_;
			sqlite3_stmt* _tmp42_;
			ObjectsItem* _tmp43_;
			const gchar* _tmp44_;
			const gchar* _tmp45_;
			sqlite3_stmt* _tmp46_;
			ObjectsItem* _tmp47_;
			const gchar* _tmp48_;
			const gchar* _tmp49_;
			sqlite3_stmt* _tmp50_;
			ObjectsItem* _tmp51_;
			const gchar* _tmp52_;
			const gchar* _tmp53_;
			sqlite3_stmt* _tmp54_;
			ObjectsItem* _tmp55_;
			const gchar* _tmp56_;
			const gchar* _tmp57_;
			sqlite3_stmt* _tmp58_;
			ObjectsItem* _tmp59_;
			const gchar* _tmp60_;
			const gchar* _tmp61_;
			sqlite3_stmt* _tmp62_;
			ObjectsItem* _tmp63_;
			gint _tmp64_;
			gint _tmp65_;
			sqlite3_stmt* _tmp66_;
			ObjectsItem* _tmp67_;
			gint _tmp68_;
			gint _tmp69_;
			sqlite3_stmt* _tmp70_;
			ObjectsItem* _tmp71_;
			gboolean _tmp72_;
			gboolean _tmp73_;
			sqlite3_stmt* _tmp74_;
			ObjectsItem* _tmp75_;
			gboolean _tmp76_;
			gboolean _tmp77_;
			sqlite3_stmt* _tmp78_;
			ObjectsItem* _tmp79_;
			gint _tmp80_;
			gint _tmp81_;
			sqlite3_stmt* _tmp82_;
			ObjectsItem* _tmp83_;
			gboolean _tmp84_;
			gboolean _tmp85_;
			sqlite3_stmt* _tmp86_;
			ObjectsItem* _tmp87_;
			gboolean _tmp88_;
			gboolean _tmp89_;
			sqlite3_stmt* _tmp90_;
			ObjectsItem* _tmp91_;
			GeeArrayList* _tmp92_;
			GeeArrayList* _tmp93_;
			gchar* _tmp94_;
			gchar* _tmp95_;
			sqlite3_stmt* _tmp96_;
			ObjectsItem* _tmp97_;
			const gchar* _tmp98_;
			const gchar* _tmp99_;
			sqlite3_stmt* _tmp100_;
			ObjectsItem* _tmp101_;
			ItemType _tmp102_;
			ItemType _tmp103_;
			gchar* _tmp104_;
			gchar* _tmp105_;
			sqlite3_stmt* _tmp106_;
			ObjectsItem* _tmp107_;
			const gchar* _tmp108_;
			const gchar* _tmp109_;
			sqlite3_stmt* _tmp110_;
			ObjectsItem* _tmp111_;
			const gchar* _tmp112_;
			const gchar* _tmp113_;
			sqlite3_stmt* _tmp114_;
			ObjectsItem* _tmp115_;
			const gchar* _tmp116_;
			const gchar* _tmp117_;
			gint _result_ = 0;
			sqlite3_stmt* _tmp118_;
			sqlite3_stmt* _tmp122_;
			_item_index = _item_index + 1;
			_tmp16_ = _item_index;
			_tmp17_ = _item_size;
			if (!(_tmp16_ < _tmp17_)) {
				break;
			}
			_tmp18_ = _item_list;
			_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp18_, _item_index);
			item = (ObjectsItem*) _tmp19_;
			_tmp20_ = stmt;
			_tmp21_ = item;
			_tmp22_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp21_);
			_tmp23_ = _tmp22_;
			services_database_set_parameter_str (self, _tmp20_, "$id", _tmp23_);
			_tmp24_ = stmt;
			_tmp25_ = item;
			_tmp26_ = objects_item_get_content (_tmp25_);
			_tmp27_ = _tmp26_;
			services_database_set_parameter_str (self, _tmp24_, "$content", _tmp27_);
			_tmp28_ = stmt;
			_tmp29_ = item;
			_tmp30_ = objects_item_get_description (_tmp29_);
			_tmp31_ = _tmp30_;
			services_database_set_parameter_str (self, _tmp28_, "$description", _tmp31_);
			_tmp32_ = stmt;
			_tmp33_ = item;
			_tmp34_ = objects_item_get_due (_tmp33_);
			_tmp35_ = _tmp34_;
			_tmp36_ = objects_due_date_to_string (_tmp35_);
			_tmp37_ = _tmp36_;
			services_database_set_parameter_str (self, _tmp32_, "$due", _tmp37_);
			_g_free0 (_tmp37_);
			_tmp38_ = stmt;
			_tmp39_ = item;
			_tmp40_ = objects_item_get_added_at (_tmp39_);
			_tmp41_ = _tmp40_;
			services_database_set_parameter_str (self, _tmp38_, "$added_at", _tmp41_);
			_tmp42_ = stmt;
			_tmp43_ = item;
			_tmp44_ = objects_item_get_completed_at (_tmp43_);
			_tmp45_ = _tmp44_;
			services_database_set_parameter_str (self, _tmp42_, "$completed_at", _tmp45_);
			_tmp46_ = stmt;
			_tmp47_ = item;
			_tmp48_ = objects_item_get_updated_at (_tmp47_);
			_tmp49_ = _tmp48_;
			services_database_set_parameter_str (self, _tmp46_, "$updated_at", _tmp49_);
			_tmp50_ = stmt;
			_tmp51_ = item;
			_tmp52_ = objects_item_get_section_id (_tmp51_);
			_tmp53_ = _tmp52_;
			services_database_set_parameter_str (self, _tmp50_, "$section_id", _tmp53_);
			_tmp54_ = stmt;
			_tmp55_ = item;
			_tmp56_ = objects_item_get_project_id (_tmp55_);
			_tmp57_ = _tmp56_;
			services_database_set_parameter_str (self, _tmp54_, "$project_id", _tmp57_);
			_tmp58_ = stmt;
			_tmp59_ = item;
			_tmp60_ = objects_item_get_parent_id (_tmp59_);
			_tmp61_ = _tmp60_;
			services_database_set_parameter_str (self, _tmp58_, "$parent_id", _tmp61_);
			_tmp62_ = stmt;
			_tmp63_ = item;
			_tmp64_ = objects_item_get_priority (_tmp63_);
			_tmp65_ = _tmp64_;
			services_database_set_parameter_int (self, _tmp62_, "$priority", &_tmp65_);
			_tmp66_ = stmt;
			_tmp67_ = item;
			_tmp68_ = objects_item_get_child_order (_tmp67_);
			_tmp69_ = _tmp68_;
			services_database_set_parameter_int (self, _tmp66_, "$child_order", &_tmp69_);
			_tmp70_ = stmt;
			_tmp71_ = item;
			_tmp72_ = objects_item_get_checked (_tmp71_);
			_tmp73_ = _tmp72_;
			services_database_set_parameter_bool (self, _tmp70_, "$checked", &_tmp73_);
			_tmp74_ = stmt;
			_tmp75_ = item;
			_tmp76_ = objects_item_get_is_deleted (_tmp75_);
			_tmp77_ = _tmp76_;
			services_database_set_parameter_bool (self, _tmp74_, "$is_deleted", &_tmp77_);
			_tmp78_ = stmt;
			_tmp79_ = item;
			_tmp80_ = objects_item_get_day_order (_tmp79_);
			_tmp81_ = _tmp80_;
			services_database_set_parameter_int (self, _tmp78_, "$day_order", &_tmp81_);
			_tmp82_ = stmt;
			_tmp83_ = item;
			_tmp84_ = objects_item_get_collapsed (_tmp83_);
			_tmp85_ = _tmp84_;
			services_database_set_parameter_bool (self, _tmp82_, "$collapsed", &_tmp85_);
			_tmp86_ = stmt;
			_tmp87_ = item;
			_tmp88_ = objects_item_get_pinned (_tmp87_);
			_tmp89_ = _tmp88_;
			services_database_set_parameter_bool (self, _tmp86_, "$pinned", &_tmp89_);
			_tmp90_ = stmt;
			_tmp91_ = item;
			_tmp92_ = objects_item_get_labels (_tmp91_);
			_tmp93_ = _tmp92_;
			_tmp94_ = services_database_get_labels_ids (self, _tmp93_);
			_tmp95_ = _tmp94_;
			services_database_set_parameter_str (self, _tmp90_, "$labels", _tmp95_);
			_g_free0 (_tmp95_);
			_tmp96_ = stmt;
			_tmp97_ = item;
			_tmp98_ = objects_item_get_extra_data (_tmp97_);
			_tmp99_ = _tmp98_;
			services_database_set_parameter_str (self, _tmp96_, "$extra_data", _tmp99_);
			_tmp100_ = stmt;
			_tmp101_ = item;
			_tmp102_ = objects_item_get_item_type (_tmp101_);
			_tmp103_ = _tmp102_;
			_tmp104_ = item_type_to_string (_tmp103_);
			_tmp105_ = _tmp104_;
			services_database_set_parameter_str (self, _tmp100_, "$item_type", _tmp105_);
			_g_free0 (_tmp105_);
			_tmp106_ = stmt;
			_tmp107_ = item;
			_tmp108_ = objects_item_get_calendar_event_uid (_tmp107_);
			_tmp109_ = _tmp108_;
			services_database_set_parameter_str (self, _tmp106_, "$calendar_event_uid", _tmp109_);
			_tmp110_ = stmt;
			_tmp111_ = item;
			_tmp112_ = objects_item_get_deadline_date (_tmp111_);
			_tmp113_ = _tmp112_;
			services_database_set_parameter_str (self, _tmp110_, "$deadline_date", _tmp113_);
			_tmp114_ = stmt;
			_tmp115_ = item;
			_tmp116_ = objects_item_get_responsible_uid (_tmp115_);
			_tmp117_ = _tmp116_;
			services_database_set_parameter_str (self, _tmp114_, "$responsible_uid", _tmp117_);
			_tmp118_ = stmt;
			_result_ = sqlite3_step (_tmp118_);
			if (_result_ != SQLITE_DONE) {
				sqlite3* _tmp119_;
				sqlite3* _tmp120_;
				const gchar* _tmp121_;
				_tmp119_ = self->priv->db;
				_tmp120_ = self->priv->db;
				_tmp121_ = sqlite3_errmsg (_tmp120_);
				g_warning ("Database.vala:1549: Error: %d: %s", sqlite3_errcode (_tmp119_), _tmp121_);
				success = FALSE;
				_g_object_unref0 (item);
				break;
			}
			_tmp122_ = stmt;
			sqlite3_reset (_tmp122_);
			_g_object_unref0 (item);
		}
	}
	if (success) {
		gchar* _tmp123_;
		sqlite3* _tmp124_;
		const gchar* _tmp125_;
		gchar* _tmp126_ = NULL;
		gint _tmp127_;
		_tmp123_ = g_strdup ("COMMIT;");
		_g_free0 (self->priv->sql);
		self->priv->sql = _tmp123_;
		_tmp124_ = self->priv->db;
		_tmp125_ = self->priv->sql;
		_tmp127_ = _sqlite3_exec (_tmp124_, _tmp125_, NULL, NULL, &_tmp126_);
		_g_free0 (self->priv->errormsg);
		self->priv->errormsg = _tmp126_;
		if (_tmp127_ != SQLITE_OK) {
			const gchar* _tmp128_;
			_tmp128_ = self->priv->errormsg;
			g_warning ("Database.vala:1560: %s", _tmp128_);
			success = FALSE;
		}
	} else {
		gchar* _tmp129_;
		sqlite3* _tmp130_;
		const gchar* _tmp131_;
		gchar* _tmp132_ = NULL;
		gint _tmp133_;
		_tmp129_ = g_strdup ("ROLLBACK;");
		_g_free0 (self->priv->sql);
		self->priv->sql = _tmp129_;
		_tmp130_ = self->priv->db;
		_tmp131_ = self->priv->sql;
		_tmp133_ = _sqlite3_exec (_tmp130_, _tmp131_, NULL, NULL, &_tmp132_);
		_g_free0 (self->priv->errormsg);
		self->priv->errormsg = _tmp132_;
		if (_tmp133_ != SQLITE_OK) {
			const gchar* _tmp134_;
			_tmp134_ = self->priv->errormsg;
			g_warning ("Database.vala:1566: %s", _tmp134_);
		}
	}
	result = success;
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_items_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("SELECT * FROM Items WHERE is_deleted = 0;");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsItem* _tmp11_;
		ObjectsItem* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_item (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsItem*
services_database_get_item_by_id (ServicesDatabase* self,
                                  const gchar* id)
{
	ObjectsItem* returned = NULL;
	ObjectsItem* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	sqlite3_stmt* _tmp8_;
	sqlite3_stmt* _tmp9_;
	ObjectsItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = objects_item_new ();
	returned = _tmp0_;
	_tmp1_ = g_strdup ("SELECT * FROM Items WHERE id = $id LIMIT 1;");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$id", id);
	_tmp9_ = stmt;
	if (sqlite3_step (_tmp9_) == SQLITE_ROW) {
		sqlite3_stmt* _tmp10_;
		ObjectsItem* _tmp11_;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_item (self, _tmp10_);
		_g_object_unref0 (returned);
		returned = _tmp11_;
	}
	result = returned;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsItem*
_services_database_fill_item (ServicesDatabase* self,
                              sqlite3_stmt* stmt)
{
	ObjectsItem* return_value = NULL;
	ObjectsItem* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	ObjectsDueDate* _tmp4_;
	ObjectsDueDate* _tmp5_;
	const gchar* _tmp6_;
	JsonObject* _tmp7_;
	JsonObject* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	ServicesStore* _tmp15_;
	const gchar* _tmp16_;
	GeeArrayList* _tmp17_;
	GeeArrayList* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	ObjectsItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_item_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_item_set_content (return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_item_set_description (return_value, _tmp3_);
	_tmp4_ = objects_item_get_due (return_value);
	_tmp5_ = _tmp4_;
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 3);
	_tmp7_ = services_database_get_due_parameter (self, _tmp6_);
	_tmp8_ = _tmp7_;
	objects_due_date_update_from_json (_tmp5_, _tmp8_);
	_json_object_unref0 (_tmp8_);
	_tmp9_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_item_set_added_at (return_value, _tmp9_);
	_tmp10_ = (const gchar*) sqlite3_column_text (stmt, 5);
	objects_item_set_completed_at (return_value, _tmp10_);
	_tmp11_ = (const gchar*) sqlite3_column_text (stmt, 6);
	objects_item_set_updated_at (return_value, _tmp11_);
	_tmp12_ = (const gchar*) sqlite3_column_text (stmt, 7);
	objects_item_set_section_id (return_value, _tmp12_);
	_tmp13_ = (const gchar*) sqlite3_column_text (stmt, 8);
	objects_item_set_project_id (return_value, _tmp13_);
	_tmp14_ = (const gchar*) sqlite3_column_text (stmt, 9);
	objects_item_set_parent_id (return_value, _tmp14_);
	objects_item_set_priority (return_value, sqlite3_column_int (stmt, 10));
	objects_item_set_child_order (return_value, sqlite3_column_int (stmt, 11));
	objects_item_set_checked (return_value, services_database_get_parameter_bool (self, stmt, 12));
	objects_item_set_is_deleted (return_value, services_database_get_parameter_bool (self, stmt, 13));
	objects_item_set_day_order (return_value, sqlite3_column_int (stmt, 14));
	objects_item_set_collapsed (return_value, services_database_get_parameter_bool (self, stmt, 15));
	objects_item_set_pinned (return_value, services_database_get_parameter_bool (self, stmt, 16));
	_tmp15_ = services_store_instance ();
	_tmp16_ = (const gchar*) sqlite3_column_text (stmt, 17);
	_tmp17_ = services_store_get_labels_by_item_labels (_tmp15_, _tmp16_);
	_tmp18_ = _tmp17_;
	objects_item_set_labels (return_value, _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = (const gchar*) sqlite3_column_text (stmt, 18);
	objects_item_set_extra_data (return_value, _tmp19_);
	_tmp20_ = (const gchar*) sqlite3_column_text (stmt, 19);
	objects_item_set_item_type (return_value, item_type_parse (_tmp20_));
	_tmp21_ = (const gchar*) sqlite3_column_text (stmt, 20);
	objects_item_set_calendar_event_uid (return_value, _tmp21_);
	_tmp22_ = (const gchar*) sqlite3_column_text (stmt, 21);
	objects_item_set_deadline_date (return_value, _tmp22_);
	_tmp23_ = (const gchar*) sqlite3_column_text (stmt, 22);
	objects_item_set_responsible_uid (return_value, _tmp23_);
	result = return_value;
	return result;
}

gboolean
services_database_delete_item (ServicesDatabase* self,
                               ObjectsItem* item)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Items WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) item);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1646: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_delete_all_items_by_project (ServicesDatabase* self,
                                               ObjectsProject* project)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (project != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            DELETE FROM Items WHERE project_id=$project_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) project);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$project_id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1665: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

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

gboolean
services_database_update_item (ServicesDatabase* self,
                               ObjectsItem* item,
                               const gchar* update_id)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp4_;
	sqlite3* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	sqlite3_stmt* _tmp10_ = NULL;
	sqlite3_stmt* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	sqlite3_stmt* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	sqlite3_stmt* _tmp17_;
	ObjectsDueDate* _tmp18_;
	ObjectsDueDate* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	sqlite3_stmt* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	sqlite3_stmt* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	sqlite3_stmt* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	sqlite3_stmt* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	sqlite3_stmt* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	sqlite3_stmt* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	sqlite3_stmt* _tmp40_;
	gint _tmp41_;
	gint _tmp42_;
	sqlite3_stmt* _tmp43_;
	gint _tmp44_;
	gint _tmp45_;
	sqlite3_stmt* _tmp46_;
	gboolean _tmp47_;
	gboolean _tmp48_;
	sqlite3_stmt* _tmp49_;
	gboolean _tmp50_;
	gboolean _tmp51_;
	sqlite3_stmt* _tmp52_;
	gint _tmp53_;
	gint _tmp54_;
	sqlite3_stmt* _tmp55_;
	gboolean _tmp56_;
	gboolean _tmp57_;
	sqlite3_stmt* _tmp58_;
	gboolean _tmp59_;
	gboolean _tmp60_;
	sqlite3_stmt* _tmp61_;
	GeeArrayList* _tmp62_;
	GeeArrayList* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	sqlite3_stmt* _tmp66_;
	const gchar* _tmp67_;
	const gchar* _tmp68_;
	sqlite3_stmt* _tmp69_;
	ItemType _tmp70_;
	ItemType _tmp71_;
	gchar* _tmp72_;
	gchar* _tmp73_;
	sqlite3_stmt* _tmp74_;
	const gchar* _tmp75_;
	const gchar* _tmp76_;
	sqlite3_stmt* _tmp77_;
	const gchar* _tmp78_;
	const gchar* _tmp79_;
	sqlite3_stmt* _tmp80_;
	const gchar* _tmp81_;
	const gchar* _tmp82_;
	sqlite3_stmt* _tmp83_;
	const gchar* _tmp84_;
	const gchar* _tmp85_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp86_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (item != NULL, FALSE);
	g_return_val_if_fail (update_id != NULL, FALSE);
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_to_string (_tmp1_);
	_tmp3_ = _tmp2_;
	objects_item_set_updated_at (item, _tmp3_);
	_g_free0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
	_tmp4_ = g_strdup ("\n" \
"            UPDATE Items SET content=$content, description=$descriptio" \
"n, due=$due,\n" \
"                added_at=$added_at, completed_at=$completed_at, update" \
"d_at=$updated_at,\n" \
"                section_id=$section_id, project_id=$project_id, parent" \
"_id=$parent_id,\n" \
"                priority=$priority, child_order=$child_order, checked=" \
"$checked,\n" \
"                is_deleted=$is_deleted, day_order=$day_order, collapse" \
"d=$collapsed,\n" \
"                pinned=$pinned, labels=$labels, extra_data=$extra_data" \
", item_type=$item_type, calendar_event_uid=$calendar_event_uid,\n" \
"                deadline_date=$deadline_date, responsible_uid=$respons" \
"ible_uid\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp4_;
	_tmp5_ = self->priv->db;
	_tmp6_ = self->priv->sql;
	_tmp7_ = self->priv->sql;
	_tmp8_ = strlen (_tmp7_);
	_tmp9_ = _tmp8_;
	sqlite3_prepare_v2 (_tmp5_, _tmp6_, _tmp9_, &_tmp10_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp10_;
	_tmp11_ = stmt;
	_tmp12_ = objects_item_get_content (item);
	_tmp13_ = _tmp12_;
	services_database_set_parameter_str (self, _tmp11_, "$content", _tmp13_);
	_tmp14_ = stmt;
	_tmp15_ = objects_item_get_description (item);
	_tmp16_ = _tmp15_;
	services_database_set_parameter_str (self, _tmp14_, "$description", _tmp16_);
	_tmp17_ = stmt;
	_tmp18_ = objects_item_get_due (item);
	_tmp19_ = _tmp18_;
	_tmp20_ = objects_due_date_to_string (_tmp19_);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_str (self, _tmp17_, "$due", _tmp21_);
	_g_free0 (_tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_item_get_added_at (item);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_str (self, _tmp22_, "$added_at", _tmp24_);
	_tmp25_ = stmt;
	_tmp26_ = objects_item_get_completed_at (item);
	_tmp27_ = _tmp26_;
	services_database_set_parameter_str (self, _tmp25_, "$completed_at", _tmp27_);
	_tmp28_ = stmt;
	_tmp29_ = objects_item_get_updated_at (item);
	_tmp30_ = _tmp29_;
	services_database_set_parameter_str (self, _tmp28_, "$updated_at", _tmp30_);
	_tmp31_ = stmt;
	_tmp32_ = objects_item_get_section_id (item);
	_tmp33_ = _tmp32_;
	services_database_set_parameter_str (self, _tmp31_, "$section_id", _tmp33_);
	_tmp34_ = stmt;
	_tmp35_ = objects_item_get_project_id (item);
	_tmp36_ = _tmp35_;
	services_database_set_parameter_str (self, _tmp34_, "$project_id", _tmp36_);
	_tmp37_ = stmt;
	_tmp38_ = objects_item_get_parent_id (item);
	_tmp39_ = _tmp38_;
	services_database_set_parameter_str (self, _tmp37_, "$parent_id", _tmp39_);
	_tmp40_ = stmt;
	_tmp41_ = objects_item_get_priority (item);
	_tmp42_ = _tmp41_;
	services_database_set_parameter_int (self, _tmp40_, "$priority", &_tmp42_);
	_tmp43_ = stmt;
	_tmp44_ = objects_item_get_child_order (item);
	_tmp45_ = _tmp44_;
	services_database_set_parameter_int (self, _tmp43_, "$child_order", &_tmp45_);
	_tmp46_ = stmt;
	_tmp47_ = objects_item_get_checked (item);
	_tmp48_ = _tmp47_;
	services_database_set_parameter_bool (self, _tmp46_, "$checked", &_tmp48_);
	_tmp49_ = stmt;
	_tmp50_ = objects_item_get_is_deleted (item);
	_tmp51_ = _tmp50_;
	services_database_set_parameter_bool (self, _tmp49_, "$is_deleted", &_tmp51_);
	_tmp52_ = stmt;
	_tmp53_ = objects_item_get_day_order (item);
	_tmp54_ = _tmp53_;
	services_database_set_parameter_int (self, _tmp52_, "$day_order", &_tmp54_);
	_tmp55_ = stmt;
	_tmp56_ = objects_item_get_collapsed (item);
	_tmp57_ = _tmp56_;
	services_database_set_parameter_bool (self, _tmp55_, "$collapsed", &_tmp57_);
	_tmp58_ = stmt;
	_tmp59_ = objects_item_get_pinned (item);
	_tmp60_ = _tmp59_;
	services_database_set_parameter_bool (self, _tmp58_, "$pinned", &_tmp60_);
	_tmp61_ = stmt;
	_tmp62_ = objects_item_get_labels (item);
	_tmp63_ = _tmp62_;
	_tmp64_ = services_database_get_labels_ids (self, _tmp63_);
	_tmp65_ = _tmp64_;
	services_database_set_parameter_str (self, _tmp61_, "$labels", _tmp65_);
	_g_free0 (_tmp65_);
	_tmp66_ = stmt;
	_tmp67_ = objects_item_get_extra_data (item);
	_tmp68_ = _tmp67_;
	services_database_set_parameter_str (self, _tmp66_, "$extra_data", _tmp68_);
	_tmp69_ = stmt;
	_tmp70_ = objects_item_get_item_type (item);
	_tmp71_ = _tmp70_;
	_tmp72_ = item_type_to_string (_tmp71_);
	_tmp73_ = _tmp72_;
	services_database_set_parameter_str (self, _tmp69_, "$item_type", _tmp73_);
	_g_free0 (_tmp73_);
	_tmp74_ = stmt;
	_tmp75_ = objects_item_get_calendar_event_uid (item);
	_tmp76_ = _tmp75_;
	services_database_set_parameter_str (self, _tmp74_, "$calendar_event_uid", _tmp76_);
	_tmp77_ = stmt;
	_tmp78_ = objects_item_get_deadline_date (item);
	_tmp79_ = _tmp78_;
	services_database_set_parameter_str (self, _tmp77_, "$deadline_date", _tmp79_);
	_tmp80_ = stmt;
	_tmp81_ = objects_item_get_responsible_uid (item);
	_tmp82_ = _tmp81_;
	services_database_set_parameter_str (self, _tmp80_, "$responsible_uid", _tmp82_);
	_tmp83_ = stmt;
	_tmp84_ = objects_base_object_get_id ((ObjectsBaseObject*) item);
	_tmp85_ = _tmp84_;
	services_database_set_parameter_str (self, _tmp83_, "$id", _tmp85_);
	_tmp86_ = stmt;
	_result_ = sqlite3_step (_tmp86_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp87_;
		sqlite3* _tmp88_;
		const gchar* _tmp89_;
		_tmp87_ = self->priv->db;
		_tmp88_ = self->priv->db;
		_tmp89_ = sqlite3_errmsg (_tmp88_);
		g_warning ("Database.vala:1714: Error: %d: %s", sqlite3_errcode (_tmp87_), _tmp89_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_move_item (ServicesDatabase* self,
                             ObjectsItem* item)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp4_;
	sqlite3* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	sqlite3_stmt* _tmp10_ = NULL;
	sqlite3_stmt* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	sqlite3_stmt* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	sqlite3_stmt* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	sqlite3_stmt* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	sqlite3_stmt* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp26_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_to_string (_tmp1_);
	_tmp3_ = _tmp2_;
	objects_item_set_updated_at (item, _tmp3_);
	_g_free0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
	_tmp4_ = g_strdup ("\n" \
"            UPDATE Items SET\n" \
"                section_id=$section_id,\n" \
"                project_id=$project_id,\n" \
"                parent_id=$parent_id,\n" \
"                extra_data=$extra_data\n" \
"            WHERE id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp4_;
	_tmp5_ = self->priv->db;
	_tmp6_ = self->priv->sql;
	_tmp7_ = self->priv->sql;
	_tmp8_ = strlen (_tmp7_);
	_tmp9_ = _tmp8_;
	sqlite3_prepare_v2 (_tmp5_, _tmp6_, _tmp9_, &_tmp10_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp10_;
	_tmp11_ = stmt;
	_tmp12_ = objects_item_get_section_id (item);
	_tmp13_ = _tmp12_;
	services_database_set_parameter_str (self, _tmp11_, "$section_id", _tmp13_);
	_tmp14_ = stmt;
	_tmp15_ = objects_item_get_project_id (item);
	_tmp16_ = _tmp15_;
	services_database_set_parameter_str (self, _tmp14_, "$project_id", _tmp16_);
	_tmp17_ = stmt;
	_tmp18_ = objects_item_get_parent_id (item);
	_tmp19_ = _tmp18_;
	services_database_set_parameter_str (self, _tmp17_, "$parent_id", _tmp19_);
	_tmp20_ = stmt;
	_tmp21_ = objects_item_get_extra_data (item);
	_tmp22_ = _tmp21_;
	services_database_set_parameter_str (self, _tmp20_, "$extra_data", _tmp22_);
	_tmp23_ = stmt;
	_tmp24_ = objects_base_object_get_id ((ObjectsBaseObject*) item);
	_tmp25_ = _tmp24_;
	services_database_set_parameter_str (self, _tmp23_, "$id", _tmp25_);
	_tmp26_ = stmt;
	_result_ = sqlite3_step (_tmp26_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp27_;
		sqlite3* _tmp28_;
		const gchar* _tmp29_;
		_tmp27_ = self->priv->db;
		_tmp28_ = self->priv->db;
		_tmp29_ = sqlite3_errmsg (_tmp28_);
		g_warning ("Database.vala:1743: Error: %d: %s", sqlite3_errcode (_tmp27_), _tmp29_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_complete_item (ServicesDatabase* self,
                                 ObjectsItem* item,
                                 gboolean old_checked)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp16_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET checked=$checked, completed_at=$completed" \
"_at\n" \
"            WHERE id=$id OR parent_id=$id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_item_get_checked (item);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_bool (self, _tmp7_, "$checked", &_tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_item_get_completed_at (item);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$completed_at", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_base_object_get_id ((ObjectsBaseObject*) item);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$id", _tmp15_);
	_tmp16_ = stmt;
	_result_ = sqlite3_step (_tmp16_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp17_;
		sqlite3* _tmp18_;
		const gchar* _tmp19_;
		_tmp17_ = self->priv->db;
		_tmp18_ = self->priv->db;
		_tmp19_ = sqlite3_errmsg (_tmp18_);
		g_warning ("Database.vala:1765: Error: %d: %s", sqlite3_errcode (_tmp17_), _tmp19_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

void
services_database_update_child_order (ServicesDatabase* self,
                                      ObjectsBaseObject* base_object)
{
	sqlite3_stmt* stmt = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	sqlite3* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	sqlite3_stmt* _tmp10_ = NULL;
	sqlite3_stmt* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	sqlite3_stmt* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (base_object != NULL);
	_tmp0_ = objects_base_object_get_table_name (base_object);
	_tmp1_ = _tmp0_;
	_tmp2_ = objects_base_object_get_column_order_name (base_object);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup_printf ("\n            UPDATE %s SET %s=$order WHERE id=$id;\n        ", _tmp1_, _tmp3_);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp4_;
	_tmp5_ = self->priv->db;
	_tmp6_ = self->priv->sql;
	_tmp7_ = self->priv->sql;
	_tmp8_ = strlen (_tmp7_);
	_tmp9_ = _tmp8_;
	sqlite3_prepare_v2 (_tmp5_, _tmp6_, _tmp9_, &_tmp10_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp10_;
	if (OBJECTS_IS_ITEM (base_object)) {
		sqlite3_stmt* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp11_ = stmt;
		_tmp12_ = objects_item_get_child_order (G_TYPE_CHECK_INSTANCE_CAST (base_object, OBJECTS_TYPE_ITEM, ObjectsItem));
		_tmp13_ = _tmp12_;
		services_database_set_parameter_int (self, _tmp11_, "$order", &_tmp13_);
	} else {
		if (OBJECTS_IS_SECTION (base_object)) {
			sqlite3_stmt* _tmp14_;
			gint _tmp15_;
			gint _tmp16_;
			_tmp14_ = stmt;
			_tmp15_ = objects_section_get_section_order (G_TYPE_CHECK_INSTANCE_CAST (base_object, OBJECTS_TYPE_SECTION, ObjectsSection));
			_tmp16_ = _tmp15_;
			services_database_set_parameter_int (self, _tmp14_, "$order", &_tmp16_);
		} else {
			if (OBJECTS_IS_PROJECT (base_object)) {
				sqlite3_stmt* _tmp17_;
				gint _tmp18_;
				gint _tmp19_;
				_tmp17_ = stmt;
				_tmp18_ = objects_project_get_child_order (G_TYPE_CHECK_INSTANCE_CAST (base_object, OBJECTS_TYPE_PROJECT, ObjectsProject));
				_tmp19_ = _tmp18_;
				services_database_set_parameter_int (self, _tmp17_, "$order", &_tmp19_);
			} else {
				if (OBJECTS_IS_LABEL (base_object)) {
					sqlite3_stmt* _tmp20_;
					gint _tmp21_;
					gint _tmp22_;
					_tmp20_ = stmt;
					_tmp21_ = objects_label_get_item_order (G_TYPE_CHECK_INSTANCE_CAST (base_object, OBJECTS_TYPE_LABEL, ObjectsLabel));
					_tmp22_ = _tmp21_;
					services_database_set_parameter_int (self, _tmp20_, "$order", &_tmp22_);
				}
			}
		}
	}
	_tmp23_ = stmt;
	_tmp24_ = objects_base_object_get_id (base_object);
	_tmp25_ = _tmp24_;
	services_database_set_parameter_str (self, _tmp23_, "$id", _tmp25_);
	_tmp26_ = stmt;
	if (sqlite3_step (_tmp26_) != SQLITE_DONE) {
		sqlite3* _tmp27_;
		sqlite3* _tmp28_;
		const gchar* _tmp29_;
		_tmp27_ = self->priv->db;
		_tmp28_ = self->priv->db;
		_tmp29_ = sqlite3_errmsg (_tmp28_);
		g_warning ("Database.vala:1794: Error: %d: %s", sqlite3_errcode (_tmp27_), _tmp29_);
	}
	_sqlite3_finalize0 (stmt);
}

gboolean
services_database_insert_reminder (ServicesDatabase* self,
                                   ObjectsReminder* reminder)
{
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	ReminderType _tmp14_;
	ReminderType _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	sqlite3_stmt* _tmp18_;
	ObjectsDueDate* _tmp19_;
	ObjectsDueDate* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	sqlite3_stmt* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp26_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (reminder != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Reminders (id, item_id, type, due, m" \
"m_offset)\n" \
"            VALUES ($id, $item_id, $type, $due, $mm_offset);\n" \
"        ");
	_g_free0 (sql);
	sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = sql;
	_tmp3_ = sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) reminder);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_reminder_get_item_id (reminder);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$item_id", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_reminder_get_reminder_type (reminder);
	_tmp15_ = _tmp14_;
	_tmp16_ = reminder_type_to_string (_tmp15_);
	_tmp17_ = _tmp16_;
	services_database_set_parameter_str (self, _tmp13_, "$type", _tmp17_);
	_g_free0 (_tmp17_);
	_tmp18_ = stmt;
	_tmp19_ = objects_reminder_get_due (reminder);
	_tmp20_ = _tmp19_;
	_tmp21_ = objects_due_date_to_string (_tmp20_);
	_tmp22_ = _tmp21_;
	services_database_set_parameter_str (self, _tmp18_, "$due", _tmp22_);
	_g_free0 (_tmp22_);
	_tmp23_ = stmt;
	_tmp24_ = objects_reminder_get_mm_offset (reminder);
	_tmp25_ = _tmp24_;
	services_database_set_parameter_int (self, _tmp23_, "$mm_offset", &_tmp25_);
	_tmp26_ = stmt;
	_result_ = sqlite3_step (_tmp26_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp27_;
		sqlite3* _tmp28_;
		const gchar* _tmp29_;
		_tmp27_ = self->priv->db;
		_tmp28_ = self->priv->db;
		_tmp29_ = sqlite3_errmsg (_tmp28_);
		g_warning ("Database.vala:1820: Error: %d: %s", sqlite3_errcode (_tmp27_), _tmp29_);
		result = FALSE;
		_g_free0 (sql);
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_reminders_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_REMINDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n" \
"            SELECT id, item_id, type, due, mm_offset FROM Reminders;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsReminder* _tmp11_;
		ObjectsReminder* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_reminder (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsReminder*
_services_database_fill_reminder (ServicesDatabase* self,
                                  sqlite3_stmt* stmt)
{
	ObjectsReminder* return_value = NULL;
	ObjectsReminder* _tmp0_;
	ObjectsReminder* _tmp1_;
	const gchar* _tmp2_;
	ObjectsReminder* _tmp3_;
	const gchar* _tmp4_;
	ReminderType _tmp5_ = 0;
	const gchar* _tmp6_;
	ObjectsReminder* _tmp7_;
	ObjectsReminder* _tmp8_;
	ObjectsDueDate* _tmp9_;
	ObjectsDueDate* _tmp10_;
	const gchar* _tmp11_;
	JsonObject* _tmp12_;
	JsonObject* _tmp13_;
	ObjectsReminder* _tmp14_;
	ObjectsReminder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_reminder_new ();
	return_value = _tmp0_;
	_tmp1_ = return_value;
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_base_object_set_id ((ObjectsBaseObject*) _tmp1_, _tmp2_);
	_tmp3_ = return_value;
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_reminder_set_item_id (_tmp3_, _tmp4_);
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 2);
	if (g_strcmp0 (_tmp6_, "absolute") == 0) {
		_tmp5_ = REMINDER_TYPE_ABSOLUTE;
	} else {
		_tmp5_ = REMINDER_TYPE_RELATIVE;
	}
	_tmp7_ = return_value;
	objects_reminder_set_reminder_type (_tmp7_, _tmp5_);
	_tmp8_ = return_value;
	_tmp9_ = objects_reminder_get_due (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = (const gchar*) sqlite3_column_text (stmt, 3);
	_tmp12_ = services_database_get_due_parameter (self, _tmp11_);
	_tmp13_ = _tmp12_;
	objects_due_date_update_from_json (_tmp10_, _tmp13_);
	_json_object_unref0 (_tmp13_);
	_tmp14_ = return_value;
	objects_reminder_set_mm_offset (_tmp14_, sqlite3_column_int (stmt, 4));
	result = return_value;
	return result;
}

GeeArrayList*
services_database_get_reminders_by_item_id (ServicesDatabase* self,
                                            const gchar* id)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	sqlite3_stmt* _tmp8_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_REMINDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n" \
"            SELECT id, item_id, type, due, mm_offset FROM Reminders WH" \
"ERE item_id=$item_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$item_id", id);
	while (TRUE) {
		sqlite3_stmt* _tmp9_;
		GeeArrayList* _tmp10_;
		sqlite3_stmt* _tmp11_;
		ObjectsReminder* _tmp12_;
		ObjectsReminder* _tmp13_;
		_tmp9_ = stmt;
		if (!(sqlite3_step (_tmp9_) == SQLITE_ROW)) {
			break;
		}
		_tmp10_ = return_value;
		_tmp11_ = stmt;
		_tmp12_ = _services_database_fill_reminder (self, _tmp11_);
		_tmp13_ = _tmp12_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp13_);
		_g_object_unref0 (_tmp13_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_delete_reminder (ServicesDatabase* self,
                                   ObjectsReminder* reminder)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (reminder != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Reminders WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_base_object_get_id ((ObjectsBaseObject*) reminder);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1884: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_insert_attachment (ServicesDatabase* self,
                                     ObjectsAttachment* attachment)
{
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	sqlite3_stmt* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	sqlite3_stmt* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp25_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (attachment != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Attachments (id, item_id, file_type," \
" file_name, file_size, file_path)\n" \
"            VALUES ($id, $item_id, $file_type, $file_name, $file_size," \
" $file_path);\n" \
"        ");
	_g_free0 (sql);
	sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = sql;
	_tmp3_ = sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_attachment_get_id (attachment);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_attachment_get_item_id (attachment);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$item_id", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_attachment_get_file_type (attachment);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$file_type", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_attachment_get_file_name (attachment);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_str (self, _tmp16_, "$file_name", _tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_attachment_get_file_size (attachment);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_str (self, _tmp19_, "$file_size", _tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_attachment_get_file_path (attachment);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_str (self, _tmp22_, "$file_path", _tmp24_);
	_tmp25_ = stmt;
	_result_ = sqlite3_step (_tmp25_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp26_;
		sqlite3* _tmp27_;
		const gchar* _tmp28_;
		_tmp26_ = self->priv->db;
		_tmp27_ = self->priv->db;
		_tmp28_ = sqlite3_errmsg (_tmp27_);
		g_warning ("Database.vala:1911: Error: %d: %s", sqlite3_errcode (_tmp26_), _tmp28_);
		result = FALSE;
		_g_free0 (sql);
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	return result;
}

GeeArrayList*
services_database_get_attachments_collection (ServicesDatabase* self)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_ATTACHMENT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup ("\n            SELECT * FROM Attachments;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		GeeArrayList* _tmp9_;
		sqlite3_stmt* _tmp10_;
		ObjectsAttachment* _tmp11_;
		ObjectsAttachment* _tmp12_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = return_value;
		_tmp10_ = stmt;
		_tmp11_ = _services_database_fill_attachment (self, _tmp10_);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsAttachment*
_services_database_fill_attachment (ServicesDatabase* self,
                                    sqlite3_stmt* stmt)
{
	ObjectsAttachment* return_value = NULL;
	ObjectsAttachment* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ObjectsAttachment* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_attachment_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_attachment_set_id (return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_attachment_set_item_id (return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_attachment_set_file_type (return_value, _tmp3_);
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_attachment_set_file_name (return_value, _tmp4_);
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_attachment_set_file_size (return_value, _tmp5_);
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 5);
	objects_attachment_set_file_path (return_value, _tmp6_);
	result = return_value;
	return result;
}

gboolean
services_database_delete_attachment (ServicesDatabase* self,
                                     ObjectsAttachment* attachment)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (attachment != NULL, FALSE);
	_tmp0_ = g_strdup ("\n            DELETE FROM Attachments WHERE id=$id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_attachment_get_id (attachment);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$id", _tmp9_);
	_tmp10_ = stmt;
	_result_ = sqlite3_step (_tmp10_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:1958: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

void
services_database_insert_queue (ServicesDatabase* self,
                                ObjectsQueue* queue)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	sqlite3_stmt* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	sqlite3_stmt* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	sqlite3_stmt* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	sqlite3_stmt* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	sqlite3_stmt* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	sqlite3_stmt* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	sqlite3_stmt* _tmp28_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (queue != NULL);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO Queue (uuid, object_id, query, temp_" \
"id, args, source_id, date_added)\n" \
"            VALUES ($uuid, $object_id, $query, $temp_id, $args, $sourc" \
"e_id, $date_added);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	_tmp8_ = objects_queue_get_uuid (queue);
	_tmp9_ = _tmp8_;
	services_database_set_parameter_str (self, _tmp7_, "$uuid", _tmp9_);
	_tmp10_ = stmt;
	_tmp11_ = objects_queue_get_object_id (queue);
	_tmp12_ = _tmp11_;
	services_database_set_parameter_str (self, _tmp10_, "$object_id", _tmp12_);
	_tmp13_ = stmt;
	_tmp14_ = objects_queue_get_query (queue);
	_tmp15_ = _tmp14_;
	services_database_set_parameter_str (self, _tmp13_, "$query", _tmp15_);
	_tmp16_ = stmt;
	_tmp17_ = objects_queue_get_temp_id (queue);
	_tmp18_ = _tmp17_;
	services_database_set_parameter_str (self, _tmp16_, "$temp_id", _tmp18_);
	_tmp19_ = stmt;
	_tmp20_ = objects_queue_get_args (queue);
	_tmp21_ = _tmp20_;
	services_database_set_parameter_str (self, _tmp19_, "$args", _tmp21_);
	_tmp22_ = stmt;
	_tmp23_ = objects_queue_get_source_id (queue);
	_tmp24_ = _tmp23_;
	services_database_set_parameter_str (self, _tmp22_, "$source_id", _tmp24_);
	_tmp25_ = stmt;
	_tmp26_ = objects_queue_get_date_added (queue);
	_tmp27_ = _tmp26_;
	services_database_set_parameter_str (self, _tmp25_, "$date_added", _tmp27_);
	_tmp28_ = stmt;
	if (sqlite3_step (_tmp28_) != SQLITE_DONE) {
		sqlite3* _tmp29_;
		sqlite3* _tmp30_;
		const gchar* _tmp31_;
		_tmp29_ = self->priv->db;
		_tmp30_ = self->priv->db;
		_tmp31_ = sqlite3_errmsg (_tmp30_);
		g_warning ("Database.vala:1987: Error: %d: %s", sqlite3_errcode (_tmp29_), _tmp31_);
	}
	_sqlite3_finalize0 (stmt);
}

GeeArrayList*
services_database_get_all_queue (ServicesDatabase* self,
                                 const gchar* source_id)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (source_id != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_QUEUE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	if (g_strcmp0 (source_id, "") != 0) {
		gchar* _tmp1_;
		sqlite3* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		sqlite3_stmt* _tmp7_ = NULL;
		sqlite3_stmt* _tmp8_;
		_tmp1_ = g_strdup ("\n" \
"                SELECT * FROM Queue WHERE source_id=$source_id ORDER B" \
"Y date_added;\n" \
"            ");
		_g_free0 (self->priv->sql);
		self->priv->sql = _tmp1_;
		_tmp2_ = self->priv->db;
		_tmp3_ = self->priv->sql;
		_tmp4_ = self->priv->sql;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
		_sqlite3_finalize0 (stmt);
		stmt = _tmp7_;
		_tmp8_ = stmt;
		services_database_set_parameter_str (self, _tmp8_, "$source_id", source_id);
	} else {
		gchar* _tmp9_;
		sqlite3* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		gint _tmp13_;
		gint _tmp14_;
		sqlite3_stmt* _tmp15_ = NULL;
		_tmp9_ = g_strdup ("\n" \
"                SELECT * FROM Queue ORDER BY date_added;\n" \
"            ");
		_g_free0 (self->priv->sql);
		self->priv->sql = _tmp9_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->sql;
		_tmp12_ = self->priv->sql;
		_tmp13_ = strlen (_tmp12_);
		_tmp14_ = _tmp13_;
		sqlite3_prepare_v2 (_tmp10_, _tmp11_, _tmp14_, &_tmp15_, NULL);
		_sqlite3_finalize0 (stmt);
		stmt = _tmp15_;
	}
	while (TRUE) {
		sqlite3_stmt* _tmp16_;
		GeeArrayList* _tmp17_;
		sqlite3_stmt* _tmp18_;
		ObjectsQueue* _tmp19_;
		ObjectsQueue* _tmp20_;
		_tmp16_ = stmt;
		if (!(sqlite3_step (_tmp16_) == SQLITE_ROW)) {
			break;
		}
		_tmp17_ = return_value;
		_tmp18_ = stmt;
		_tmp19_ = _services_database_fill_queue (self, _tmp18_);
		_tmp20_ = _tmp19_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp20_);
		_g_object_unref0 (_tmp20_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsQueue*
_services_database_fill_queue (ServicesDatabase* self,
                               sqlite3_stmt* stmt)
{
	ObjectsQueue* return_value = NULL;
	ObjectsQueue* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	ObjectsQueue* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_queue_new ();
	return_value = _tmp0_;
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 0);
	objects_queue_set_uuid (return_value, _tmp1_);
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_queue_set_object_id (return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_queue_set_query (return_value, _tmp3_);
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_queue_set_temp_id (return_value, _tmp4_);
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_queue_set_args (return_value, _tmp5_);
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 5);
	objects_queue_set_source_id (return_value, _tmp6_);
	_tmp7_ = (const gchar*) sqlite3_column_text (stmt, 6);
	objects_queue_set_date_added (return_value, _tmp7_);
	result = return_value;
	return result;
}

void
services_database_insert_CurTempIds (ServicesDatabase* self,
                                     const gchar* id,
                                     const gchar* temp_id,
                                     const gchar* object)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	sqlite3_stmt* _tmp9_;
	sqlite3_stmt* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (id != NULL);
	g_return_if_fail (temp_id != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = g_strdup ("\n" \
"            INSERT OR IGNORE INTO CurTempIds (id, temp_id, object)\n" \
"            VALUES ($id, $temp_id, $object);\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$id", id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$temp_id", temp_id);
	_tmp9_ = stmt;
	services_database_set_parameter_str (self, _tmp9_, "$object", object);
	_tmp10_ = stmt;
	if (sqlite3_step (_tmp10_) != SQLITE_DONE) {
		sqlite3* _tmp11_;
		sqlite3* _tmp12_;
		const gchar* _tmp13_;
		_tmp11_ = self->priv->db;
		_tmp12_ = self->priv->db;
		_tmp13_ = sqlite3_errmsg (_tmp12_);
		g_warning ("Database.vala:2041: Error: %d: %s", sqlite3_errcode (_tmp11_), _tmp13_);
	}
	_sqlite3_finalize0 (stmt);
}

gboolean
services_database_curTempIds_exists (ServicesDatabase* self,
                                     const gchar* id)
{
	gboolean returned = FALSE;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (id != NULL, FALSE);
	returned = FALSE;
	_tmp0_ = g_strdup ("\n" \
"            SELECT COUNT (*) FROM CurTempIds WHERE id = $id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$id", id);
	_tmp8_ = stmt;
	if (sqlite3_step (_tmp8_) == SQLITE_ROW) {
		sqlite3_stmt* _tmp9_;
		_tmp9_ = stmt;
		returned = sqlite3_column_int (_tmp9_, 0) > 0;
	}
	result = returned;
	_sqlite3_finalize0 (stmt);
	return result;
}

gchar*
services_database_get_temp_id (ServicesDatabase* self,
                               const gchar* id)
{
	gchar* returned = NULL;
	gchar* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	sqlite3_stmt* _tmp8_;
	sqlite3_stmt* _tmp9_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = g_strdup ("");
	returned = _tmp0_;
	_tmp1_ = g_strdup ("\n" \
"            SELECT temp_id FROM CurTempIds WHERE id = $id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$id", id);
	_tmp9_ = stmt;
	if (sqlite3_step (_tmp9_) == SQLITE_ROW) {
		sqlite3_stmt* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp10_ = stmt;
		_tmp11_ = (const gchar*) sqlite3_column_text (_tmp10_, 0);
		_tmp12_ = g_strdup (_tmp11_);
		_g_free0 (returned);
		returned = _tmp12_;
	}
	result = returned;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_project_id (ServicesDatabase* self,
                                     const gchar* current_id,
                                     const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Projects SET id = $new_id WHERE id = $current_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2095: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_project_section_id (ServicesDatabase* self,
                                             const gchar* current_id,
                                             const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"                UPDATE Sections SET project_id = $new_id WHERE project" \
"_id = $current_id;\n" \
"            ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2115: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_project_item_id (ServicesDatabase* self,
                                          const gchar* current_id,
                                          const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET project_id = $new_id WHERE project_id = $" \
"current_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2135: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_section_id (ServicesDatabase* self,
                                     const gchar* current_id,
                                     const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Sections SET id = $new_id WHERE id = $current_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2155: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_section_item_id (ServicesDatabase* self,
                                          const gchar* current_id,
                                          const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET section_id = $new_id WHERE section_id = $" \
"current_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2175: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_item_id (ServicesDatabase* self,
                                  const gchar* current_id,
                                  const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET id = $new_id WHERE id = $current_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2195: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

gboolean
services_database_update_item_child_id (ServicesDatabase* self,
                                        const gchar* current_id,
                                        const gchar* new_id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gint _result_ = 0;
	sqlite3_stmt* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (current_id != NULL, FALSE);
	g_return_val_if_fail (new_id != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            UPDATE Items SET parent_id = $new_id WHERE parent_id = $cu" \
"rrent_id;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$new_id", new_id);
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$current_id", current_id);
	_tmp9_ = stmt;
	_result_ = sqlite3_step (_tmp9_);
	if (_result_ != SQLITE_DONE) {
		sqlite3* _tmp10_;
		sqlite3* _tmp11_;
		const gchar* _tmp12_;
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->db;
		_tmp12_ = sqlite3_errmsg (_tmp11_);
		g_warning ("Database.vala:2215: Error: %d: %s", sqlite3_errcode (_tmp10_), _tmp12_);
		result = FALSE;
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

void
services_database_remove_CurTempIds (ServicesDatabase* self,
                                     const gchar* id)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (id != NULL);
	_tmp0_ = g_strdup ("\n            DELETE FROM CurTempIds WHERE id = $id;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$id", id);
	_tmp8_ = stmt;
	if (sqlite3_step (_tmp8_) != SQLITE_DONE) {
		sqlite3* _tmp9_;
		sqlite3* _tmp10_;
		const gchar* _tmp11_;
		_tmp9_ = self->priv->db;
		_tmp10_ = self->priv->db;
		_tmp11_ = sqlite3_errmsg (_tmp10_);
		g_warning ("Database.vala:2233: Error: %d: %s", sqlite3_errcode (_tmp9_), _tmp11_);
	}
	_sqlite3_finalize0 (stmt);
}

void
services_database_remove_queue (ServicesDatabase* self,
                                const gchar* uuid)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uuid != NULL);
	_tmp0_ = g_strdup ("\n            DELETE FROM Queue WHERE uuid = $uuid;\n        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$uuid", uuid);
	_tmp8_ = stmt;
	if (sqlite3_step (_tmp8_) != SQLITE_DONE) {
		sqlite3* _tmp9_;
		sqlite3* _tmp10_;
		const gchar* _tmp11_;
		_tmp9_ = self->priv->db;
		_tmp10_ = self->priv->db;
		_tmp11_ = sqlite3_errmsg (_tmp10_);
		g_warning ("Database.vala:2248: Error: %d: %s", sqlite3_errcode (_tmp9_), _tmp11_);
	}
	_sqlite3_finalize0 (stmt);
}

void
services_database_clear_queue (ServicesDatabase* self)
{
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gint res = 0;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	sqlite3_stmt* _tmp3_ = NULL;
	gint _tmp4_;
	sqlite3_stmt* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("\n            DELETE FROM Queue;\n        ");
	_g_free0 (sql);
	sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = sql;
	_tmp4_ = sqlite3_prepare_v2 (_tmp1_, _tmp2_, -1, &_tmp3_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp3_;
	res = _tmp4_;
	_vala_assert (res == SQLITE_OK, "res == Sqlite.OK");
	_tmp5_ = stmt;
	if (sqlite3_step (_tmp5_) != SQLITE_DONE) {
		sqlite3* _tmp6_;
		sqlite3* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->db;
		_tmp7_ = self->priv->db;
		_tmp8_ = sqlite3_errmsg (_tmp7_);
		g_warning ("Database.vala:2265: Error: %d: %s", sqlite3_errcode (_tmp6_), _tmp8_);
	}
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
}

void
services_database_clear_cur_temp_ids (ServicesDatabase* self)
{
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gint res = 0;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	sqlite3_stmt* _tmp3_ = NULL;
	gint _tmp4_;
	sqlite3_stmt* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("\n            DELETE FROM CurTempIds;\n        ");
	_g_free0 (sql);
	sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = sql;
	_tmp4_ = sqlite3_prepare_v2 (_tmp1_, _tmp2_, -1, &_tmp3_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp3_;
	res = _tmp4_;
	_vala_assert (res == SQLITE_OK, "res == Sqlite.OK");
	_tmp5_ = stmt;
	if (sqlite3_step (_tmp5_) != SQLITE_DONE) {
		sqlite3* _tmp6_;
		sqlite3* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->db;
		_tmp7_ = self->priv->db;
		_tmp8_ = sqlite3_errmsg (_tmp7_);
		g_warning ("Database.vala:2282: Error: %d: %s", sqlite3_errcode (_tmp6_), _tmp8_);
	}
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
}

GeeArrayList*
services_database_get_events_by_item (ServicesDatabase* self,
                                      const gchar* id,
                                      gint start_week,
                                      gint end_week)
{
	GeeArrayList* return_value = NULL;
	GeeArrayList* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	sqlite3_stmt* _tmp7_ = NULL;
	sqlite3_stmt* _tmp8_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = gee_array_list_new (OBJECTS_TYPE_OBJECT_EVENT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return_value = _tmp0_;
	_tmp1_ = g_strdup_printf ("\n" \
"            SELECT * FROM OEvents\n" \
"                WHERE object_id = $object_id\n" \
"                AND (event_date >= DATETIME('now', '-%d days')\n" \
"                AND event_date <= DATETIME('now', '-%d days'))\n" \
"            ORDER BY event_date DESC\n" \
"        ", end_week, start_week);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = self->priv->sql;
	_tmp4_ = self->priv->sql;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	sqlite3_prepare_v2 (_tmp2_, _tmp3_, _tmp6_, &_tmp7_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp7_;
	_tmp8_ = stmt;
	services_database_set_parameter_str (self, _tmp8_, "$object_id", id);
	while (TRUE) {
		sqlite3_stmt* _tmp9_;
		GeeArrayList* _tmp10_;
		sqlite3_stmt* _tmp11_;
		ObjectsObjectEvent* _tmp12_;
		ObjectsObjectEvent* _tmp13_;
		_tmp9_ = stmt;
		if (!(sqlite3_step (_tmp9_) == SQLITE_ROW)) {
			break;
		}
		_tmp10_ = return_value;
		_tmp11_ = stmt;
		_tmp12_ = _services_database_fill_object_event (self, _tmp11_);
		_tmp13_ = _tmp12_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp13_);
		_g_object_unref0 (_tmp13_);
	}
	result = return_value;
	_sqlite3_finalize0 (stmt);
	return result;
}

ObjectsObjectEvent*
_services_database_fill_object_event (ServicesDatabase* self,
                                      sqlite3_stmt* stmt)
{
	ObjectsObjectEvent* return_value = NULL;
	ObjectsObjectEvent* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	ObjectsObjectEvent* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stmt != NULL, NULL);
	_tmp0_ = objects_object_event_new ();
	return_value = _tmp0_;
	objects_object_event_set_id (return_value, sqlite3_column_int64 (stmt, 0));
	_tmp1_ = (const gchar*) sqlite3_column_text (stmt, 1);
	objects_object_event_set_event_type (return_value, object_event_type_parse (_tmp1_));
	_tmp2_ = (const gchar*) sqlite3_column_text (stmt, 2);
	objects_object_event_set_event_date (return_value, _tmp2_);
	_tmp3_ = (const gchar*) sqlite3_column_text (stmt, 3);
	objects_object_event_set_object_id (return_value, _tmp3_);
	_tmp4_ = (const gchar*) sqlite3_column_text (stmt, 4);
	objects_object_event_set_object_type (return_value, _tmp4_);
	_tmp5_ = (const gchar*) sqlite3_column_text (stmt, 5);
	objects_object_event_set_object_key (return_value, object_event_key_type_parse (_tmp5_));
	_tmp6_ = (const gchar*) sqlite3_column_text (stmt, 6);
	objects_object_event_set_object_old_value (return_value, _tmp6_);
	_tmp7_ = (const gchar*) sqlite3_column_text (stmt, 7);
	objects_object_event_set_object_new_value (return_value, _tmp7_);
	_tmp8_ = (const gchar*) sqlite3_column_text (stmt, 8);
	objects_object_event_set_parent_item_id (return_value, _tmp8_);
	_tmp9_ = (const gchar*) sqlite3_column_text (stmt, 9);
	objects_object_event_set_parent_project_id (return_value, _tmp9_);
	result = return_value;
	return result;
}

static void
services_database_set_parameter_int (ServicesDatabase* self,
                                     sqlite3_stmt* stmt,
                                     const gchar* par,
                                     gint* val)
{
	gint par_position = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (par != NULL);
	if (val == NULL) {
		return;
	}
	par_position = sqlite3_bind_parameter_index (stmt, par);
	if (par_position == 0) {
		g_warning ("Database.vala:2336: bind parameter not found: %s", par);
		return;
	}
	sqlite3_bind_int (stmt, par_position, *val);
}

static void
services_database_set_parameter_int64 (ServicesDatabase* self,
                                       sqlite3_stmt* stmt,
                                       const gchar* par,
                                       gint64* val)
{
	gint par_position = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (par != NULL);
	if (val == NULL) {
		return;
	}
	par_position = sqlite3_bind_parameter_index (stmt, par);
	if (par_position == 0) {
		g_warning ("Database.vala:2349: bind parameter not found: %s", par);
		return;
	}
	sqlite3_bind_int64 (stmt, par_position, *val);
}

static void
services_database_set_parameter_str (ServicesDatabase* self,
                                     sqlite3_stmt* stmt,
                                     const gchar* par,
                                     const gchar* val)
{
	gint par_position = 0;
	gchar* _tmp0_;
	GDestroyNotify _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (par != NULL);
	if (val == NULL) {
		return;
	}
	par_position = sqlite3_bind_parameter_index (stmt, par);
	if (par_position == 0) {
		g_warning ("Database.vala:2362: bind parameter not found: %s", par);
		return;
	}
	_tmp0_ = g_strdup (val);
	_tmp1_ = g_free;
	sqlite3_bind_text (stmt, par_position, _tmp0_, -1, _tmp1_);
}

static void
services_database_set_parameter_bool (ServicesDatabase* self,
                                      sqlite3_stmt* stmt,
                                      const gchar* par,
                                      gboolean* val)
{
	gint par_position = 0;
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (par != NULL);
	if (val == NULL) {
		return;
	}
	par_position = sqlite3_bind_parameter_index (stmt, par);
	if (par_position == 0) {
		g_warning ("Database.vala:2375: bind parameter not found: %s", par);
		return;
	}
	if (*val) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	sqlite3_bind_int (stmt, par_position, _tmp0_);
}

static gboolean
services_database_get_parameter_bool (ServicesDatabase* self,
                                      sqlite3_stmt* stmt,
                                      gint col)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (stmt != NULL, FALSE);
	result = sqlite3_column_int (stmt, col) == 1;
	return result;
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

JsonObject*
services_database_get_due_parameter (ServicesDatabase* self,
                                     const gchar* data)
{
	JsonParser* _tmp0_;
	JsonParser* _tmp5_;
	JsonNode* _tmp6_;
	JsonObject* _tmp7_;
	JsonObject* _tmp8_;
	GError* _inner_error0_ = NULL;
	JsonObject* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = self->priv->parser;
	if (_tmp0_ == NULL) {
		JsonParser* _tmp1_;
		_tmp1_ = json_parser_new ();
		_g_object_unref0 (self->priv->parser);
		self->priv->parser = _tmp1_;
	}
	{
		JsonParser* _tmp2_;
		_tmp2_ = self->priv->parser;
		json_parser_load_from_data (_tmp2_, data, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_debug ("Database.vala:2394: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != 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 NULL;
	}
	_tmp5_ = self->priv->parser;
	_tmp6_ = json_parser_get_root (_tmp5_);
	_tmp7_ = json_node_get_object (_tmp6_);
	_tmp8_ = _json_object_ref0 (_tmp7_);
	result = _tmp8_;
	return result;
}

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

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

gchar*
services_database_get_labels_ids (ServicesDatabase* self,
                                  GeeArrayList* labels)
{
	gchar* return_value = NULL;
	gchar* _tmp0_;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (labels != NULL, NULL);
	_tmp0_ = g_strdup ("");
	return_value = _tmp0_;
	{
		GeeArrayList* _label_list = NULL;
		gint _label_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _label_index = 0;
		_label_list = labels;
		_tmp1_ = _label_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_label_size = _tmp3_;
		_label_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ObjectsLabel* label = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			const gchar* _tmp8_;
			ObjectsLabel* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			_label_index = _label_index + 1;
			_tmp4_ = _label_index;
			_tmp5_ = _label_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _label_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _label_index);
			label = (ObjectsLabel*) _tmp7_;
			_tmp8_ = return_value;
			_tmp9_ = label;
			_tmp10_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_strconcat (_tmp11_, ";", NULL);
			_tmp13_ = _tmp12_;
			_tmp14_ = g_strconcat (_tmp8_, _tmp13_, NULL);
			_g_free0 (return_value);
			return_value = _tmp14_;
			_g_free0 (_tmp13_);
			_g_object_unref0 (label);
		}
	}
	_tmp15_ = return_value;
	_tmp16_ = strlen (_tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ > 0) {
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		gchar* _tmp22_;
		_tmp18_ = return_value;
		_tmp19_ = return_value;
		_tmp20_ = strlen (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = string_substring (_tmp18_, (glong) 0, (glong) (_tmp21_ - 1));
		_g_free0 (return_value);
		return_value = _tmp22_;
	}
	result = return_value;
	return result;
}

gboolean
services_database_column_exists (ServicesDatabase* self,
                                 const gchar* table,
                                 const gchar* column)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (table != NULL, FALSE);
	g_return_val_if_fail (column != NULL, FALSE);
	_tmp0_ = g_strdup_printf ("\n            PRAGMA table_info(%s);\n        ", table);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	sqlite3_step (_tmp7_);
	while (TRUE) {
		sqlite3_stmt* _tmp8_;
		sqlite3_stmt* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = stmt;
		if (!(sqlite3_step (_tmp8_) == SQLITE_ROW)) {
			break;
		}
		_tmp9_ = stmt;
		_tmp10_ = (const gchar*) sqlite3_column_text (_tmp9_, 1);
		if (g_strcmp0 (_tmp10_, column) == 0) {
			result = TRUE;
			_sqlite3_finalize0 (stmt);
			return result;
		}
	}
	result = FALSE;
	_sqlite3_finalize0 (stmt);
	return result;
}

void
services_database_add_text_column (ServicesDatabase* self,
                                   const gchar* table,
                                   const gchar* column,
                                   const gchar* default_value)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (table != NULL);
	g_return_if_fail (column != NULL);
	g_return_if_fail (default_value != NULL);
	if (services_database_column_exists (self, table, column)) {
		return;
	}
	_tmp0_ = g_strdup_printf ("\n" \
"            ALTER TABLE %s ADD COLUMN %s TEXT DEFAULT '%s';\n" \
"        ", table, column, default_value);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	if (sqlite3_step (_tmp7_) != SQLITE_DONE) {
		sqlite3* _tmp8_;
		sqlite3* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = self->priv->db;
		_tmp9_ = self->priv->db;
		_tmp10_ = sqlite3_errmsg (_tmp9_);
		g_warning ("Database.vala:2448: Error: %d: %s", sqlite3_errcode (_tmp8_), _tmp10_);
	}
	_sqlite3_finalize0 (stmt);
}

void
services_database_add_int_column (ServicesDatabase* self,
                                  const gchar* table,
                                  const gchar* column,
                                  gint default_value)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (table != NULL);
	g_return_if_fail (column != NULL);
	if (services_database_column_exists (self, table, column)) {
		return;
	}
	_tmp0_ = g_strdup_printf ("\n" \
"            ALTER TABLE %s ADD COLUMN %s INTEGER DEFAULT %i;\n" \
"        ", table, column, default_value);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	if (sqlite3_step (_tmp7_) != SQLITE_DONE) {
		sqlite3* _tmp8_;
		sqlite3* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = self->priv->db;
		_tmp9_ = self->priv->db;
		_tmp10_ = sqlite3_errmsg (_tmp9_);
		g_warning ("Database.vala:2466: Error: %d: %s", sqlite3_errcode (_tmp8_), _tmp10_);
	}
	_sqlite3_finalize0 (stmt);
}

void
services_database_add_item_label_column (ServicesDatabase* self)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	g_return_if_fail (self != NULL);
	if (services_database_column_exists (self, "Items", "labels")) {
		return;
	}
	_tmp0_ = g_strdup ("\n" \
"            ALTER TABLE Items ADD COLUMN labels TEXT;\n" \
"\n" \
"            UPDATE Items\n" \
"            SET labels = (\n" \
"                SELECT GROUP_CONCAT(label_id, ';')\n" \
"                FROM Items_Labels\n" \
"                WHERE item_id = Items.id\n" \
"            );\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	if (sqlite3_step (_tmp7_) != SQLITE_DONE) {
		sqlite3* _tmp8_;
		sqlite3* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = self->priv->db;
		_tmp9_ = self->priv->db;
		_tmp10_ = sqlite3_errmsg (_tmp9_);
		g_warning ("Database.vala:2491: Error: %d: %s", sqlite3_errcode (_tmp8_), _tmp10_);
	}
	_sqlite3_finalize0 (stmt);
}

void
services_database_add_project_labels_source_id (ServicesDatabase* self)
{
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gint _tmp4_;
	gchar* _tmp6_;
	sqlite3* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_ = NULL;
	gint _tmp10_;
	Util* _tmp12_;
	Util* _tmp13_;
	ObjectsSource* _tmp14_;
	ObjectsSource* _tmp15_;
	g_return_if_fail (self != NULL);
	if (services_database_column_exists (self, "Projects", "source_id")) {
		return;
	}
	_tmp0_ = g_strdup ("\n" \
"            ALTER TABLE Projects ADD COLUMN source_id TEXT;\n" \
"            UPDATE Projects SET source_id = backend_type;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp4_ = _sqlite3_exec (_tmp1_, _tmp2_, NULL, NULL, &_tmp3_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp3_;
	if (_tmp4_ != SQLITE_OK) {
		const gchar* _tmp5_;
		_tmp5_ = self->priv->errormsg;
		g_warning ("Database.vala:2506: %s", _tmp5_);
	}
	_tmp6_ = g_strdup ("\n" \
"            ALTER TABLE Labels ADD COLUMN source_id TEXT;\n" \
"            UPDATE Labels SET source_id = backend_type;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp6_;
	_tmp7_ = self->priv->db;
	_tmp8_ = self->priv->sql;
	_tmp10_ = _sqlite3_exec (_tmp7_, _tmp8_, NULL, NULL, &_tmp9_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp9_;
	if (_tmp10_ != SQLITE_OK) {
		const gchar* _tmp11_;
		_tmp11_ = self->priv->errormsg;
		g_warning ("Database.vala:2515: %s", _tmp11_);
	}
	_tmp12_ = util_get_default ();
	_tmp13_ = _tmp12_;
	_tmp14_ = util_create_local_source (_tmp13_);
	_tmp15_ = _tmp14_;
	_g_object_unref0 (_tmp15_);
	_g_object_unref0 (_tmp13_);
}

void
services_database_add_calendar_url_to_project (ServicesDatabase* self)
{
	GeeArrayList* projects = NULL;
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	if (services_database_column_exists (self, "Projects", "calendar_url")) {
		return;
	}
	services_database_add_text_column (self, "Projects", "calendar_url", "");
	_tmp0_ = services_database_get_projects_collection (self);
	projects = _tmp0_;
	{
		GeeArrayList* _project_list = NULL;
		GeeArrayList* _tmp1_;
		gint _project_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _project_index = 0;
		_tmp1_ = projects;
		_project_list = _tmp1_;
		_tmp2_ = _project_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_project_size = _tmp4_;
		_project_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			ObjectsProject* project = NULL;
			GeeArrayList* _tmp7_;
			gpointer _tmp8_;
			ObjectsProject* _tmp9_;
			ObjectsSource* _tmp10_;
			ObjectsSource* _tmp11_;
			SourceType _tmp12_;
			SourceType _tmp13_;
			gchar* url = NULL;
			ObjectsProject* _tmp14_;
			ObjectsSource* _tmp15_;
			ObjectsSource* _tmp16_;
			ObjectsSourceCalDAVData* _tmp17_;
			ObjectsSourceCalDAVData* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			ObjectsProject* _tmp21_;
			ObjectsSource* _tmp22_;
			ObjectsSource* _tmp23_;
			ObjectsSourceCalDAVData* _tmp24_;
			ObjectsSourceCalDAVData* _tmp25_;
			const gchar* _tmp26_;
			const gchar* _tmp27_;
			ObjectsProject* _tmp28_;
			const gchar* _tmp29_;
			const gchar* _tmp30_;
			gchar* _tmp31_;
			const gchar* _tmp32_;
			ObjectsProject* _tmp35_;
			const gchar* _tmp36_;
			const gchar* _tmp37_;
			const gchar* _tmp38_;
			sqlite3_stmt* stmt = NULL;
			gchar* _tmp39_;
			sqlite3* _tmp40_;
			const gchar* _tmp41_;
			const gchar* _tmp42_;
			gint _tmp43_;
			gint _tmp44_;
			sqlite3_stmt* _tmp45_ = NULL;
			sqlite3_stmt* _tmp46_;
			const gchar* _tmp47_;
			sqlite3_stmt* _tmp48_;
			ObjectsProject* _tmp49_;
			const gchar* _tmp50_;
			const gchar* _tmp51_;
			sqlite3_stmt* _tmp52_;
			_project_index = _project_index + 1;
			_tmp5_ = _project_index;
			_tmp6_ = _project_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _project_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _project_index);
			project = (ObjectsProject*) _tmp8_;
			_tmp9_ = project;
			_tmp10_ = objects_project_get_source (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = objects_source_get_source_type (_tmp11_);
			_tmp13_ = _tmp12_;
			if (_tmp13_ != SOURCE_TYPE_CALDAV) {
				_g_object_unref0 (project);
				continue;
			}
			_tmp14_ = project;
			_tmp15_ = objects_project_get_source (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = objects_source_get_caldav_data (_tmp16_);
			_tmp18_ = _tmp17_;
			_tmp19_ = objects_source_cal_dav_data_get_server_url (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = project;
			_tmp22_ = objects_project_get_source (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = objects_source_get_caldav_data (_tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = objects_source_cal_dav_data_get_username (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = project;
			_tmp29_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = g_build_filename (_tmp20_, "calendars", _tmp27_, _tmp30_, NULL);
			url = _tmp31_;
			_tmp32_ = url;
			if (!g_str_has_suffix (_tmp32_, "/")) {
				const gchar* _tmp33_;
				gchar* _tmp34_;
				_tmp33_ = url;
				_tmp34_ = g_strconcat (_tmp33_, "/", NULL);
				_g_free0 (url);
				url = _tmp34_;
			}
			_tmp35_ = project;
			_tmp36_ = objects_base_object_get_name ((ObjectsBaseObject*) _tmp35_);
			_tmp37_ = _tmp36_;
			_tmp38_ = url;
			g_debug ("Database.vala:2546: Migration: Adding calendar_url for Project (%s) (%" \
"s)\n", _tmp37_, _tmp38_);
			_tmp39_ = g_strdup ("\n" \
"                UPDATE Projects SET calendar_url = $calendar_url WHERE" \
" id = $id;\n" \
"            ");
			_g_free0 (self->priv->sql);
			self->priv->sql = _tmp39_;
			_tmp40_ = self->priv->db;
			_tmp41_ = self->priv->sql;
			_tmp42_ = self->priv->sql;
			_tmp43_ = strlen (_tmp42_);
			_tmp44_ = _tmp43_;
			sqlite3_prepare_v2 (_tmp40_, _tmp41_, _tmp44_, &_tmp45_, NULL);
			_sqlite3_finalize0 (stmt);
			stmt = _tmp45_;
			_tmp46_ = stmt;
			_tmp47_ = url;
			services_database_set_parameter_str (self, _tmp46_, "$calendar_url", _tmp47_);
			_tmp48_ = stmt;
			_tmp49_ = project;
			_tmp50_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp49_);
			_tmp51_ = _tmp50_;
			services_database_set_parameter_str (self, _tmp48_, "$id", _tmp51_);
			_tmp52_ = stmt;
			if (sqlite3_step (_tmp52_) != SQLITE_DONE) {
				sqlite3* _tmp53_;
				sqlite3* _tmp54_;
				const gchar* _tmp55_;
				_tmp53_ = self->priv->db;
				_tmp54_ = self->priv->db;
				_tmp55_ = sqlite3_errmsg (_tmp54_);
				g_warning ("Database.vala:2560: Error: %d: %s", sqlite3_errcode (_tmp53_), _tmp55_);
			}
			_sqlite3_finalize0 (stmt);
			_g_free0 (url);
			_g_object_unref0 (project);
		}
	}
	_g_object_unref0 (projects);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
services_database_table_has_on_update_cascade (ServicesDatabase* self,
                                               const gchar* table)
{
	sqlite3_stmt* stmt = NULL;
	gchar* _tmp0_;
	sqlite3* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	sqlite3_stmt* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_;
	sqlite3_stmt* _tmp8_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (table != NULL, FALSE);
	_tmp0_ = g_strdup ("\n" \
"            SELECT sql FROM sqlite_master WHERE type = 'table' AND nam" \
"e = $name;\n" \
"        ");
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	_tmp1_ = self->priv->db;
	_tmp2_ = self->priv->sql;
	_tmp3_ = self->priv->sql;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	sqlite3_prepare_v2 (_tmp1_, _tmp2_, _tmp5_, &_tmp6_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp6_;
	_tmp7_ = stmt;
	services_database_set_parameter_str (self, _tmp7_, "$name", table);
	_tmp8_ = stmt;
	if (sqlite3_step (_tmp8_) == SQLITE_ROW) {
		sqlite3_stmt* _tmp9_;
		const gchar* _tmp10_;
		_tmp9_ = stmt;
		_tmp10_ = (const gchar*) sqlite3_column_text (_tmp9_, 0);
		result = string_contains (_tmp10_, "ON UPDATE CASCADE");
		_sqlite3_finalize0 (stmt);
		return result;
	}
	result = TRUE;
	_sqlite3_finalize0 (stmt);
	return result;
}

static void
services_database_migrate_foreign_keys_on_update_cascade (ServicesDatabase* self)
{
	gboolean migrate_sections = FALSE;
	gboolean migrate_reminders = FALSE;
	gboolean migrate_attachments = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	sqlite3* _tmp2_;
	gboolean success = FALSE;
	sqlite3* _tmp3_;
	gchar* _tmp4_ = NULL;
	gint _tmp5_;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	sqlite3* _tmp14_;
	g_return_if_fail (self != NULL);
	migrate_sections = !services_database_table_has_on_update_cascade (self, "Sections");
	migrate_reminders = !services_database_table_has_on_update_cascade (self, "Reminders");
	migrate_attachments = !services_database_table_has_on_update_cascade (self, "Attachments");
	if (!migrate_sections) {
		_tmp1_ = !migrate_reminders;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = !migrate_attachments;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = self->priv->db;
	_sqlite3_exec (_tmp2_, "PRAGMA foreign_keys = OFF;", NULL, NULL, NULL);
	_tmp3_ = self->priv->db;
	_tmp5_ = _sqlite3_exec (_tmp3_, "BEGIN TRANSACTION;", NULL, NULL, &_tmp4_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp4_;
	success = _tmp5_ == SQLITE_OK;
	if (success) {
		_tmp6_ = migrate_sections;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		success = services_database_rebuild_table (self, "Sections", "\n" \
"                    CREATE TABLE Sections_new (\n" \
"                        id              TEXT PRIMARY KEY,\n" \
"                        name            TEXT,\n" \
"                        archived_at     TEXT,\n" \
"                        added_at        TEXT,\n" \
"                        project_id      TEXT,\n" \
"                        section_order   INTEGER,\n" \
"                        collapsed       INTEGER,\n" \
"                        is_deleted      INTEGER,\n" \
"                        is_archived     INTEGER,\n" \
"                        color           TEXT,\n" \
"                        description     TEXT,\n" \
"                        hidded          INTEGER,\n" \
"                        extra_data      TEXT,\n" \
"                        FOREIGN KEY (project_id) REFERENCES Projects (" \
"id) ON DELETE CASCADE ON UPDATE CASCADE\n" \
"                    );\n" \
"                ", "id, name, archived_at, added_at, project_id, section_order, collapsed," \
" is_deleted, is_archived, color, description, hidded, extra_data");
	}
	if (success) {
		_tmp7_ = migrate_reminders;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		success = services_database_rebuild_table (self, "Reminders", "\n" \
"                    CREATE TABLE Reminders_new (\n" \
"                        id                  TEXT PRIMARY KEY,\n" \
"                        notify_uid          INTEGER,\n" \
"                        item_id             TEXT,\n" \
"                        service             TEXT,\n" \
"                        type                TEXT,\n" \
"                        due                 TEXT,\n" \
"                        mm_offset           INTEGER,\n" \
"                        is_deleted          INTEGER,\n" \
"                        FOREIGN KEY (item_id) REFERENCES Items (id) ON" \
" DELETE CASCADE ON UPDATE CASCADE\n" \
"                    );\n" \
"                ", "id, notify_uid, item_id, service, type, due, mm_offset, is_deleted");
	}
	if (success) {
		_tmp8_ = migrate_attachments;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		success = services_database_rebuild_table (self, "Attachments", "\n" \
"                    CREATE TABLE Attachments_new (\n" \
"                        id              TEXT PRIMARY KEY,\n" \
"                        item_id         TEXT,\n" \
"                        file_type       TEXT,\n" \
"                        file_name       TEXT,\n" \
"                        file_size       TEXT,\n" \
"                        file_path       TEXT,\n" \
"                        FOREIGN KEY (item_id) REFERENCES Items (id) ON" \
" DELETE CASCADE ON UPDATE CASCADE\n" \
"                    );\n" \
"                ", "id, item_id, file_type, file_name, file_size, file_path");
	}
	if (success) {
		sqlite3* _tmp9_;
		gchar* _tmp10_ = NULL;
		gint _tmp11_;
		_tmp9_ = self->priv->db;
		_tmp11_ = _sqlite3_exec (_tmp9_, "COMMIT;", NULL, NULL, &_tmp10_);
		_g_free0 (self->priv->errormsg);
		self->priv->errormsg = _tmp10_;
		success = _tmp11_ == SQLITE_OK;
	}
	if (!success) {
		const gchar* _tmp12_;
		sqlite3* _tmp13_;
		_tmp12_ = self->priv->errormsg;
		g_warning ("Database.vala:2666: Foreign key migration failed, rolling back: %s", _tmp12_);
		_tmp13_ = self->priv->db;
		_sqlite3_exec (_tmp13_, "ROLLBACK;", NULL, NULL, NULL);
	}
	_tmp14_ = self->priv->db;
	_sqlite3_exec (_tmp14_, "PRAGMA foreign_keys = ON;", NULL, NULL, NULL);
}

static gboolean
services_database_rebuild_table (ServicesDatabase* self,
                                 const gchar* table,
                                 const gchar* create_new_sql,
                                 const gchar* columns)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	sqlite3* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	gint _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (table != NULL, FALSE);
	g_return_val_if_fail (create_new_sql != NULL, FALSE);
	g_return_val_if_fail (columns != NULL, FALSE);
	_tmp0_ = g_strdup_printf ("\n" \
"            INSERT INTO %s_new (%s) SELECT %s FROM %s;\n" \
"            DROP TABLE %s;\n" \
"            ALTER TABLE %s_new RENAME TO %s;\n" \
"        ", table, columns, columns, table, table, table, table);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (create_new_sql, _tmp1_, NULL);
	_g_free0 (self->priv->sql);
	self->priv->sql = _tmp2_;
	_g_free0 (_tmp1_);
	_tmp3_ = self->priv->db;
	_tmp4_ = self->priv->sql;
	_tmp6_ = _sqlite3_exec (_tmp3_, _tmp4_, NULL, NULL, &_tmp5_);
	_g_free0 (self->priv->errormsg);
	self->priv->errormsg = _tmp5_;
	if (_tmp6_ != SQLITE_OK) {
		result = FALSE;
		return result;
	}
	result = TRUE;
	return result;
}

ServicesDatabase*
services_database_construct (GType object_type)
{
	ServicesDatabase * self = NULL;
	self = (ServicesDatabase*) g_object_new (object_type, NULL);
	return self;
}

ServicesDatabase*
services_database_new (void)
{
	return services_database_construct (SERVICES_TYPE_DATABASE);
}

gboolean
services_database_get_is_opened (ServicesDatabase* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_opened;
	return result;
}

void
services_database_set_is_opened (ServicesDatabase* self,
                                 gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = services_database_get_is_opened (self);
	if (old_value != value) {
		self->priv->_is_opened = value;
		g_object_notify_by_pspec ((GObject *) self, services_database_properties[SERVICES_DATABASE_IS_OPENED_PROPERTY]);
	}
}

static GObject *
services_database_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ServicesDatabase * self;
	GeeHashMap* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeHashMap* _tmp3_;
	gpointer _tmp4_;
	GeeArrayList* _tmp5_;
	GeeHashMap* _tmp6_;
	gpointer _tmp7_;
	GeeArrayList* _tmp8_;
	GeeHashMap* _tmp9_;
	gpointer _tmp10_;
	GeeArrayList* _tmp11_;
	GeeHashMap* _tmp12_;
	gpointer _tmp13_;
	GeeArrayList* _tmp14_;
	GeeHashMap* _tmp15_;
	gpointer _tmp16_;
	GeeArrayList* _tmp17_;
	GeeHashMap* _tmp18_;
	gpointer _tmp19_;
	GeeArrayList* _tmp20_;
	GeeHashMap* _tmp21_;
	GeeArrayList* _tmp22_;
	GeeArrayList* _tmp23_;
	GeeHashMap* _tmp24_;
	gpointer _tmp25_;
	GeeArrayList* _tmp26_;
	GeeHashMap* _tmp27_;
	gpointer _tmp28_;
	GeeArrayList* _tmp29_;
	GeeHashMap* _tmp30_;
	gpointer _tmp31_;
	GeeArrayList* _tmp32_;
	GeeHashMap* _tmp33_;
	GeeArrayList* _tmp34_;
	GeeArrayList* _tmp35_;
	GeeHashMap* _tmp36_;
	gpointer _tmp37_;
	GeeArrayList* _tmp38_;
	GeeHashMap* _tmp39_;
	gpointer _tmp40_;
	GeeArrayList* _tmp41_;
	GeeHashMap* _tmp42_;
	gpointer _tmp43_;
	GeeArrayList* _tmp44_;
	GeeHashMap* _tmp45_;
	gpointer _tmp46_;
	GeeArrayList* _tmp47_;
	GeeHashMap* _tmp48_;
	gpointer _tmp49_;
	GeeArrayList* _tmp50_;
	GeeHashMap* _tmp51_;
	gpointer _tmp52_;
	GeeArrayList* _tmp53_;
	GeeHashMap* _tmp54_;
	gpointer _tmp55_;
	GeeArrayList* _tmp56_;
	GeeHashMap* _tmp57_;
	gpointer _tmp58_;
	GeeArrayList* _tmp59_;
	GeeHashMap* _tmp60_;
	gpointer _tmp61_;
	GeeArrayList* _tmp62_;
	GeeHashMap* _tmp63_;
	gpointer _tmp64_;
	GeeArrayList* _tmp65_;
	GeeHashMap* _tmp66_;
	gpointer _tmp67_;
	GeeArrayList* _tmp68_;
	GeeHashMap* _tmp69_;
	gpointer _tmp70_;
	GeeArrayList* _tmp71_;
	GeeHashMap* _tmp72_;
	gpointer _tmp73_;
	GeeArrayList* _tmp74_;
	GeeHashMap* _tmp75_;
	gpointer _tmp76_;
	GeeArrayList* _tmp77_;
	GeeHashMap* _tmp78_;
	gpointer _tmp79_;
	GeeArrayList* _tmp80_;
	GeeHashMap* _tmp81_;
	gpointer _tmp82_;
	GeeArrayList* _tmp83_;
	GeeHashMap* _tmp84_;
	gpointer _tmp85_;
	GeeArrayList* _tmp86_;
	GeeHashMap* _tmp87_;
	gpointer _tmp88_;
	GeeArrayList* _tmp89_;
	GeeHashMap* _tmp90_;
	gpointer _tmp91_;
	GeeArrayList* _tmp92_;
	GeeHashMap* _tmp93_;
	gpointer _tmp94_;
	GeeArrayList* _tmp95_;
	GeeHashMap* _tmp96_;
	gpointer _tmp97_;
	GeeArrayList* _tmp98_;
	GeeHashMap* _tmp99_;
	gpointer _tmp100_;
	GeeArrayList* _tmp101_;
	GeeHashMap* _tmp102_;
	gpointer _tmp103_;
	GeeArrayList* _tmp104_;
	GeeHashMap* _tmp105_;
	GeeArrayList* _tmp106_;
	GeeArrayList* _tmp107_;
	GeeHashMap* _tmp108_;
	gpointer _tmp109_;
	GeeArrayList* _tmp110_;
	GeeHashMap* _tmp111_;
	gpointer _tmp112_;
	GeeArrayList* _tmp113_;
	GeeHashMap* _tmp114_;
	gpointer _tmp115_;
	GeeArrayList* _tmp116_;
	GeeHashMap* _tmp117_;
	gpointer _tmp118_;
	GeeArrayList* _tmp119_;
	GeeHashMap* _tmp120_;
	gpointer _tmp121_;
	GeeArrayList* _tmp122_;
	GeeHashMap* _tmp123_;
	gpointer _tmp124_;
	GeeArrayList* _tmp125_;
	GeeHashMap* _tmp126_;
	gpointer _tmp127_;
	GeeArrayList* _tmp128_;
	GeeHashMap* _tmp129_;
	gpointer _tmp130_;
	GeeArrayList* _tmp131_;
	GeeHashMap* _tmp132_;
	GeeArrayList* _tmp133_;
	GeeArrayList* _tmp134_;
	GeeHashMap* _tmp135_;
	gpointer _tmp136_;
	GeeArrayList* _tmp137_;
	GeeHashMap* _tmp138_;
	gpointer _tmp139_;
	GeeArrayList* _tmp140_;
	GeeHashMap* _tmp141_;
	gpointer _tmp142_;
	GeeArrayList* _tmp143_;
	GeeHashMap* _tmp144_;
	gpointer _tmp145_;
	GeeArrayList* _tmp146_;
	GeeHashMap* _tmp147_;
	gpointer _tmp148_;
	GeeArrayList* _tmp149_;
	GeeHashMap* _tmp150_;
	gpointer _tmp151_;
	GeeArrayList* _tmp152_;
	GeeHashMap* _tmp153_;
	gpointer _tmp154_;
	GeeArrayList* _tmp155_;
	GeeHashMap* _tmp156_;
	gpointer _tmp157_;
	GeeArrayList* _tmp158_;
	GeeHashMap* _tmp159_;
	gpointer _tmp160_;
	GeeArrayList* _tmp161_;
	GeeHashMap* _tmp162_;
	gpointer _tmp163_;
	GeeArrayList* _tmp164_;
	GeeHashMap* _tmp165_;
	GeeArrayList* _tmp166_;
	GeeArrayList* _tmp167_;
	GeeHashMap* _tmp168_;
	gpointer _tmp169_;
	GeeArrayList* _tmp170_;
	GeeHashMap* _tmp171_;
	gpointer _tmp172_;
	GeeArrayList* _tmp173_;
	GeeHashMap* _tmp174_;
	gpointer _tmp175_;
	GeeArrayList* _tmp176_;
	GeeHashMap* _tmp177_;
	gpointer _tmp178_;
	GeeArrayList* _tmp179_;
	GeeHashMap* _tmp180_;
	gpointer _tmp181_;
	GeeArrayList* _tmp182_;
	GeeHashMap* _tmp183_;
	gpointer _tmp184_;
	GeeArrayList* _tmp185_;
	GeeHashMap* _tmp186_;
	gpointer _tmp187_;
	GeeArrayList* _tmp188_;
	GeeHashMap* _tmp189_;
	gpointer _tmp190_;
	GeeArrayList* _tmp191_;
	GeeHashMap* _tmp192_;
	gpointer _tmp193_;
	GeeArrayList* _tmp194_;
	GeeHashMap* _tmp195_;
	gpointer _tmp196_;
	GeeArrayList* _tmp197_;
	GeeHashMap* _tmp198_;
	gpointer _tmp199_;
	GeeArrayList* _tmp200_;
	GeeHashMap* _tmp201_;
	gpointer _tmp202_;
	GeeArrayList* _tmp203_;
	GeeHashMap* _tmp204_;
	gpointer _tmp205_;
	GeeArrayList* _tmp206_;
	GeeHashMap* _tmp207_;
	gpointer _tmp208_;
	GeeArrayList* _tmp209_;
	GeeHashMap* _tmp210_;
	gpointer _tmp211_;
	GeeArrayList* _tmp212_;
	GeeHashMap* _tmp213_;
	gpointer _tmp214_;
	GeeArrayList* _tmp215_;
	GeeHashMap* _tmp216_;
	gpointer _tmp217_;
	GeeArrayList* _tmp218_;
	GeeHashMap* _tmp219_;
	gpointer _tmp220_;
	GeeArrayList* _tmp221_;
	GeeHashMap* _tmp222_;
	gpointer _tmp223_;
	GeeArrayList* _tmp224_;
	GeeHashMap* _tmp225_;
	gpointer _tmp226_;
	GeeArrayList* _tmp227_;
	GeeHashMap* _tmp228_;
	gpointer _tmp229_;
	GeeArrayList* _tmp230_;
	GeeHashMap* _tmp231_;
	gpointer _tmp232_;
	GeeArrayList* _tmp233_;
	GeeHashMap* _tmp234_;
	gpointer _tmp235_;
	GeeArrayList* _tmp236_;
	GeeHashMap* _tmp237_;
	gpointer _tmp238_;
	GeeArrayList* _tmp239_;
	GeeHashMap* _tmp240_;
	gpointer _tmp241_;
	GeeArrayList* _tmp242_;
	GeeHashMap* _tmp243_;
	gpointer _tmp244_;
	GeeArrayList* _tmp245_;
	GeeHashMap* _tmp246_;
	gpointer _tmp247_;
	GeeArrayList* _tmp248_;
	GeeHashMap* _tmp249_;
	GeeArrayList* _tmp250_;
	GeeArrayList* _tmp251_;
	GeeHashMap* _tmp252_;
	gpointer _tmp253_;
	GeeArrayList* _tmp254_;
	GeeHashMap* _tmp255_;
	gpointer _tmp256_;
	GeeArrayList* _tmp257_;
	GeeHashMap* _tmp258_;
	gpointer _tmp259_;
	GeeArrayList* _tmp260_;
	GeeHashMap* _tmp261_;
	gpointer _tmp262_;
	GeeArrayList* _tmp263_;
	GeeHashMap* _tmp264_;
	gpointer _tmp265_;
	GeeArrayList* _tmp266_;
	GeeHashMap* _tmp267_;
	gpointer _tmp268_;
	GeeArrayList* _tmp269_;
	GeeHashMap* _tmp270_;
	gpointer _tmp271_;
	GeeArrayList* _tmp272_;
	GeeHashMap* _tmp273_;
	GeeArrayList* _tmp274_;
	GeeArrayList* _tmp275_;
	GeeHashMap* _tmp276_;
	gpointer _tmp277_;
	GeeArrayList* _tmp278_;
	GeeHashMap* _tmp279_;
	gpointer _tmp280_;
	GeeArrayList* _tmp281_;
	GeeHashMap* _tmp282_;
	gpointer _tmp283_;
	GeeArrayList* _tmp284_;
	GeeHashMap* _tmp285_;
	gpointer _tmp286_;
	GeeArrayList* _tmp287_;
	GeeHashMap* _tmp288_;
	gpointer _tmp289_;
	GeeArrayList* _tmp290_;
	GeeHashMap* _tmp291_;
	gpointer _tmp292_;
	GeeArrayList* _tmp293_;
	GeeHashMap* _tmp294_;
	gpointer _tmp295_;
	GeeArrayList* _tmp296_;
	GeeHashMap* _tmp297_;
	gpointer _tmp298_;
	GeeArrayList* _tmp299_;
	GeeHashMap* _tmp300_;
	GeeArrayList* _tmp301_;
	GeeArrayList* _tmp302_;
	GeeHashMap* _tmp303_;
	gpointer _tmp304_;
	GeeArrayList* _tmp305_;
	GeeHashMap* _tmp306_;
	gpointer _tmp307_;
	GeeArrayList* _tmp308_;
	GeeHashMap* _tmp309_;
	gpointer _tmp310_;
	GeeArrayList* _tmp311_;
	GeeHashMap* _tmp312_;
	gpointer _tmp313_;
	GeeArrayList* _tmp314_;
	GeeHashMap* _tmp315_;
	gpointer _tmp316_;
	GeeArrayList* _tmp317_;
	GeeHashMap* _tmp318_;
	gpointer _tmp319_;
	GeeArrayList* _tmp320_;
	GeeHashMap* _tmp321_;
	gpointer _tmp322_;
	GeeArrayList* _tmp323_;
	GeeHashMap* _tmp324_;
	gpointer _tmp325_;
	GeeArrayList* _tmp326_;
	GeeHashMap* _tmp327_;
	gpointer _tmp328_;
	GeeArrayList* _tmp329_;
	GeeHashMap* _tmp330_;
	gpointer _tmp331_;
	GeeArrayList* _tmp332_;
	GeeHashMap* _tmp333_;
	gpointer _tmp334_;
	GeeArrayList* _tmp335_;
	GeeHashMap* _tmp336_;
	gpointer _tmp337_;
	GeeArrayList* _tmp338_;
	GeeHashMap* _tmp339_;
	gpointer _tmp340_;
	GeeArrayList* _tmp341_;
	GeeHashMap* _tmp342_;
	GeeArrayList* _tmp343_;
	GeeArrayList* _tmp344_;
	GeeHashMap* _tmp345_;
	gpointer _tmp346_;
	GeeArrayList* _tmp347_;
	GeeHashMap* _tmp348_;
	gpointer _tmp349_;
	GeeArrayList* _tmp350_;
	GeeHashMap* _tmp351_;
	gpointer _tmp352_;
	GeeArrayList* _tmp353_;
	GeeHashMap* _tmp354_;
	gpointer _tmp355_;
	GeeArrayList* _tmp356_;
	GeeHashMap* _tmp357_;
	gpointer _tmp358_;
	GeeArrayList* _tmp359_;
	GeeHashMap* _tmp360_;
	gpointer _tmp361_;
	GeeArrayList* _tmp362_;
	GeeHashMap* _tmp363_;
	gpointer _tmp364_;
	GeeArrayList* _tmp365_;
	GeeHashMap* _tmp366_;
	gpointer _tmp367_;
	GeeArrayList* _tmp368_;
	GeeHashMap* _tmp369_;
	gpointer _tmp370_;
	GeeArrayList* _tmp371_;
	GeeHashMap* _tmp372_;
	gpointer _tmp373_;
	GeeArrayList* _tmp374_;
	parent_class = G_OBJECT_CLASS (services_database_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SERVICES_TYPE_DATABASE, ServicesDatabase);
	_tmp0_ = self->priv->table_columns;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp2_ = _tmp1_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, "Attachments", _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = self->priv->table_columns;
	_tmp4_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, "Attachments");
	_tmp5_ = (GeeArrayList*) _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, "id");
	_g_object_unref0 (_tmp5_);
	_tmp6_ = self->priv->table_columns;
	_tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp6_, "Attachments");
	_tmp8_ = (GeeArrayList*) _tmp7_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, "item_id");
	_g_object_unref0 (_tmp8_);
	_tmp9_ = self->priv->table_columns;
	_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp9_, "Attachments");
	_tmp11_ = (GeeArrayList*) _tmp10_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, "file_type");
	_g_object_unref0 (_tmp11_);
	_tmp12_ = self->priv->table_columns;
	_tmp13_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp12_, "Attachments");
	_tmp14_ = (GeeArrayList*) _tmp13_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, "file_name");
	_g_object_unref0 (_tmp14_);
	_tmp15_ = self->priv->table_columns;
	_tmp16_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp15_, "Attachments");
	_tmp17_ = (GeeArrayList*) _tmp16_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, "file_size");
	_g_object_unref0 (_tmp17_);
	_tmp18_ = self->priv->table_columns;
	_tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp18_, "Attachments");
	_tmp20_ = (GeeArrayList*) _tmp19_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp20_, "file_path");
	_g_object_unref0 (_tmp20_);
	_tmp21_ = self->priv->table_columns;
	_tmp22_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp23_ = _tmp22_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp21_, "CurTempIds", _tmp23_);
	_g_object_unref0 (_tmp23_);
	_tmp24_ = self->priv->table_columns;
	_tmp25_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp24_, "CurTempIds");
	_tmp26_ = (GeeArrayList*) _tmp25_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp26_, "id");
	_g_object_unref0 (_tmp26_);
	_tmp27_ = self->priv->table_columns;
	_tmp28_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp27_, "CurTempIds");
	_tmp29_ = (GeeArrayList*) _tmp28_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp29_, "temp_id");
	_g_object_unref0 (_tmp29_);
	_tmp30_ = self->priv->table_columns;
	_tmp31_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp30_, "CurTempIds");
	_tmp32_ = (GeeArrayList*) _tmp31_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp32_, "object");
	_g_object_unref0 (_tmp32_);
	_tmp33_ = self->priv->table_columns;
	_tmp34_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp35_ = _tmp34_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp33_, "Items", _tmp35_);
	_g_object_unref0 (_tmp35_);
	_tmp36_ = self->priv->table_columns;
	_tmp37_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp36_, "Items");
	_tmp38_ = (GeeArrayList*) _tmp37_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp38_, "id");
	_g_object_unref0 (_tmp38_);
	_tmp39_ = self->priv->table_columns;
	_tmp40_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp39_, "Items");
	_tmp41_ = (GeeArrayList*) _tmp40_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp41_, "content");
	_g_object_unref0 (_tmp41_);
	_tmp42_ = self->priv->table_columns;
	_tmp43_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp42_, "Items");
	_tmp44_ = (GeeArrayList*) _tmp43_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, "description");
	_g_object_unref0 (_tmp44_);
	_tmp45_ = self->priv->table_columns;
	_tmp46_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp45_, "Items");
	_tmp47_ = (GeeArrayList*) _tmp46_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp47_, "due");
	_g_object_unref0 (_tmp47_);
	_tmp48_ = self->priv->table_columns;
	_tmp49_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp48_, "Items");
	_tmp50_ = (GeeArrayList*) _tmp49_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp50_, "added_at");
	_g_object_unref0 (_tmp50_);
	_tmp51_ = self->priv->table_columns;
	_tmp52_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp51_, "Items");
	_tmp53_ = (GeeArrayList*) _tmp52_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp53_, "completed_at");
	_g_object_unref0 (_tmp53_);
	_tmp54_ = self->priv->table_columns;
	_tmp55_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp54_, "Items");
	_tmp56_ = (GeeArrayList*) _tmp55_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp56_, "updated_at");
	_g_object_unref0 (_tmp56_);
	_tmp57_ = self->priv->table_columns;
	_tmp58_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp57_, "Items");
	_tmp59_ = (GeeArrayList*) _tmp58_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp59_, "section_id");
	_g_object_unref0 (_tmp59_);
	_tmp60_ = self->priv->table_columns;
	_tmp61_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp60_, "Items");
	_tmp62_ = (GeeArrayList*) _tmp61_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp62_, "project_id");
	_g_object_unref0 (_tmp62_);
	_tmp63_ = self->priv->table_columns;
	_tmp64_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp63_, "Items");
	_tmp65_ = (GeeArrayList*) _tmp64_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp65_, "parent_id");
	_g_object_unref0 (_tmp65_);
	_tmp66_ = self->priv->table_columns;
	_tmp67_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp66_, "Items");
	_tmp68_ = (GeeArrayList*) _tmp67_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp68_, "priority");
	_g_object_unref0 (_tmp68_);
	_tmp69_ = self->priv->table_columns;
	_tmp70_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp69_, "Items");
	_tmp71_ = (GeeArrayList*) _tmp70_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp71_, "child_order");
	_g_object_unref0 (_tmp71_);
	_tmp72_ = self->priv->table_columns;
	_tmp73_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp72_, "Items");
	_tmp74_ = (GeeArrayList*) _tmp73_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp74_, "checked");
	_g_object_unref0 (_tmp74_);
	_tmp75_ = self->priv->table_columns;
	_tmp76_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp75_, "Items");
	_tmp77_ = (GeeArrayList*) _tmp76_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp77_, "is_deleted");
	_g_object_unref0 (_tmp77_);
	_tmp78_ = self->priv->table_columns;
	_tmp79_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp78_, "Items");
	_tmp80_ = (GeeArrayList*) _tmp79_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp80_, "day_order");
	_g_object_unref0 (_tmp80_);
	_tmp81_ = self->priv->table_columns;
	_tmp82_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp81_, "Items");
	_tmp83_ = (GeeArrayList*) _tmp82_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp83_, "collapsed");
	_g_object_unref0 (_tmp83_);
	_tmp84_ = self->priv->table_columns;
	_tmp85_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp84_, "Items");
	_tmp86_ = (GeeArrayList*) _tmp85_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp86_, "pinned");
	_g_object_unref0 (_tmp86_);
	_tmp87_ = self->priv->table_columns;
	_tmp88_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp87_, "Items");
	_tmp89_ = (GeeArrayList*) _tmp88_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp89_, "labels");
	_g_object_unref0 (_tmp89_);
	_tmp90_ = self->priv->table_columns;
	_tmp91_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp90_, "Items");
	_tmp92_ = (GeeArrayList*) _tmp91_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp92_, "extra_data");
	_g_object_unref0 (_tmp92_);
	_tmp93_ = self->priv->table_columns;
	_tmp94_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp93_, "Items");
	_tmp95_ = (GeeArrayList*) _tmp94_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp95_, "item_type");
	_g_object_unref0 (_tmp95_);
	_tmp96_ = self->priv->table_columns;
	_tmp97_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp96_, "Items");
	_tmp98_ = (GeeArrayList*) _tmp97_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp98_, "calendar_event_uid");
	_g_object_unref0 (_tmp98_);
	_tmp99_ = self->priv->table_columns;
	_tmp100_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp99_, "Items");
	_tmp101_ = (GeeArrayList*) _tmp100_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp101_, "deadline_date");
	_g_object_unref0 (_tmp101_);
	_tmp102_ = self->priv->table_columns;
	_tmp103_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp102_, "Items");
	_tmp104_ = (GeeArrayList*) _tmp103_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp104_, "responsible_uid");
	_g_object_unref0 (_tmp104_);
	_tmp105_ = self->priv->table_columns;
	_tmp106_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp107_ = _tmp106_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp105_, "Labels", _tmp107_);
	_g_object_unref0 (_tmp107_);
	_tmp108_ = self->priv->table_columns;
	_tmp109_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp108_, "Labels");
	_tmp110_ = (GeeArrayList*) _tmp109_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp110_, "id");
	_g_object_unref0 (_tmp110_);
	_tmp111_ = self->priv->table_columns;
	_tmp112_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp111_, "Labels");
	_tmp113_ = (GeeArrayList*) _tmp112_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp113_, "name");
	_g_object_unref0 (_tmp113_);
	_tmp114_ = self->priv->table_columns;
	_tmp115_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp114_, "Labels");
	_tmp116_ = (GeeArrayList*) _tmp115_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp116_, "color");
	_g_object_unref0 (_tmp116_);
	_tmp117_ = self->priv->table_columns;
	_tmp118_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp117_, "Labels");
	_tmp119_ = (GeeArrayList*) _tmp118_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp119_, "item_order");
	_g_object_unref0 (_tmp119_);
	_tmp120_ = self->priv->table_columns;
	_tmp121_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp120_, "Labels");
	_tmp122_ = (GeeArrayList*) _tmp121_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp122_, "is_deleted");
	_g_object_unref0 (_tmp122_);
	_tmp123_ = self->priv->table_columns;
	_tmp124_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp123_, "Labels");
	_tmp125_ = (GeeArrayList*) _tmp124_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp125_, "is_favorite");
	_g_object_unref0 (_tmp125_);
	_tmp126_ = self->priv->table_columns;
	_tmp127_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp126_, "Labels");
	_tmp128_ = (GeeArrayList*) _tmp127_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp128_, "backend_type");
	_g_object_unref0 (_tmp128_);
	_tmp129_ = self->priv->table_columns;
	_tmp130_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp129_, "Labels");
	_tmp131_ = (GeeArrayList*) _tmp130_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp131_, "source_id");
	_g_object_unref0 (_tmp131_);
	_tmp132_ = self->priv->table_columns;
	_tmp133_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp134_ = _tmp133_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp132_, "OEvents", _tmp134_);
	_g_object_unref0 (_tmp134_);
	_tmp135_ = self->priv->table_columns;
	_tmp136_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp135_, "OEvents");
	_tmp137_ = (GeeArrayList*) _tmp136_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp137_, "id");
	_g_object_unref0 (_tmp137_);
	_tmp138_ = self->priv->table_columns;
	_tmp139_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp138_, "OEvents");
	_tmp140_ = (GeeArrayList*) _tmp139_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp140_, "event_type");
	_g_object_unref0 (_tmp140_);
	_tmp141_ = self->priv->table_columns;
	_tmp142_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp141_, "OEvents");
	_tmp143_ = (GeeArrayList*) _tmp142_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp143_, "event_date");
	_g_object_unref0 (_tmp143_);
	_tmp144_ = self->priv->table_columns;
	_tmp145_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp144_, "OEvents");
	_tmp146_ = (GeeArrayList*) _tmp145_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp146_, "object_id");
	_g_object_unref0 (_tmp146_);
	_tmp147_ = self->priv->table_columns;
	_tmp148_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp147_, "OEvents");
	_tmp149_ = (GeeArrayList*) _tmp148_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp149_, "object_type");
	_g_object_unref0 (_tmp149_);
	_tmp150_ = self->priv->table_columns;
	_tmp151_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp150_, "OEvents");
	_tmp152_ = (GeeArrayList*) _tmp151_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp152_, "object_key");
	_g_object_unref0 (_tmp152_);
	_tmp153_ = self->priv->table_columns;
	_tmp154_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp153_, "OEvents");
	_tmp155_ = (GeeArrayList*) _tmp154_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp155_, "object_old_value");
	_g_object_unref0 (_tmp155_);
	_tmp156_ = self->priv->table_columns;
	_tmp157_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp156_, "OEvents");
	_tmp158_ = (GeeArrayList*) _tmp157_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp158_, "object_new_value");
	_g_object_unref0 (_tmp158_);
	_tmp159_ = self->priv->table_columns;
	_tmp160_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp159_, "OEvents");
	_tmp161_ = (GeeArrayList*) _tmp160_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp161_, "parent_item_id");
	_g_object_unref0 (_tmp161_);
	_tmp162_ = self->priv->table_columns;
	_tmp163_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp162_, "OEvents");
	_tmp164_ = (GeeArrayList*) _tmp163_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp164_, "parent_project_id");
	_g_object_unref0 (_tmp164_);
	_tmp165_ = self->priv->table_columns;
	_tmp166_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp167_ = _tmp166_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp165_, "Projects", _tmp167_);
	_g_object_unref0 (_tmp167_);
	_tmp168_ = self->priv->table_columns;
	_tmp169_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp168_, "Projects");
	_tmp170_ = (GeeArrayList*) _tmp169_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp170_, "id");
	_g_object_unref0 (_tmp170_);
	_tmp171_ = self->priv->table_columns;
	_tmp172_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp171_, "Projects");
	_tmp173_ = (GeeArrayList*) _tmp172_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp173_, "name");
	_g_object_unref0 (_tmp173_);
	_tmp174_ = self->priv->table_columns;
	_tmp175_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp174_, "Projects");
	_tmp176_ = (GeeArrayList*) _tmp175_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp176_, "color");
	_g_object_unref0 (_tmp176_);
	_tmp177_ = self->priv->table_columns;
	_tmp178_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp177_, "Projects");
	_tmp179_ = (GeeArrayList*) _tmp178_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp179_, "backend_type");
	_g_object_unref0 (_tmp179_);
	_tmp180_ = self->priv->table_columns;
	_tmp181_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp180_, "Projects");
	_tmp182_ = (GeeArrayList*) _tmp181_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp182_, "inbox_project");
	_g_object_unref0 (_tmp182_);
	_tmp183_ = self->priv->table_columns;
	_tmp184_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp183_, "Projects");
	_tmp185_ = (GeeArrayList*) _tmp184_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp185_, "team_inbox");
	_g_object_unref0 (_tmp185_);
	_tmp186_ = self->priv->table_columns;
	_tmp187_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp186_, "Projects");
	_tmp188_ = (GeeArrayList*) _tmp187_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp188_, "child_order");
	_g_object_unref0 (_tmp188_);
	_tmp189_ = self->priv->table_columns;
	_tmp190_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp189_, "Projects");
	_tmp191_ = (GeeArrayList*) _tmp190_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp191_, "is_deleted");
	_g_object_unref0 (_tmp191_);
	_tmp192_ = self->priv->table_columns;
	_tmp193_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp192_, "Projects");
	_tmp194_ = (GeeArrayList*) _tmp193_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp194_, "is_archived");
	_g_object_unref0 (_tmp194_);
	_tmp195_ = self->priv->table_columns;
	_tmp196_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp195_, "Projects");
	_tmp197_ = (GeeArrayList*) _tmp196_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp197_, "is_favorite");
	_g_object_unref0 (_tmp197_);
	_tmp198_ = self->priv->table_columns;
	_tmp199_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp198_, "Projects");
	_tmp200_ = (GeeArrayList*) _tmp199_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp200_, "shared");
	_g_object_unref0 (_tmp200_);
	_tmp201_ = self->priv->table_columns;
	_tmp202_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp201_, "Projects");
	_tmp203_ = (GeeArrayList*) _tmp202_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp203_, "view_style");
	_g_object_unref0 (_tmp203_);
	_tmp204_ = self->priv->table_columns;
	_tmp205_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp204_, "Projects");
	_tmp206_ = (GeeArrayList*) _tmp205_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp206_, "sort_order");
	_g_object_unref0 (_tmp206_);
	_tmp207_ = self->priv->table_columns;
	_tmp208_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp207_, "Projects");
	_tmp209_ = (GeeArrayList*) _tmp208_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp209_, "parent_id");
	_g_object_unref0 (_tmp209_);
	_tmp210_ = self->priv->table_columns;
	_tmp211_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp210_, "Projects");
	_tmp212_ = (GeeArrayList*) _tmp211_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp212_, "collapsed");
	_g_object_unref0 (_tmp212_);
	_tmp213_ = self->priv->table_columns;
	_tmp214_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp213_, "Projects");
	_tmp215_ = (GeeArrayList*) _tmp214_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp215_, "icon_style");
	_g_object_unref0 (_tmp215_);
	_tmp216_ = self->priv->table_columns;
	_tmp217_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp216_, "Projects");
	_tmp218_ = (GeeArrayList*) _tmp217_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp218_, "emoji");
	_g_object_unref0 (_tmp218_);
	_tmp219_ = self->priv->table_columns;
	_tmp220_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp219_, "Projects");
	_tmp221_ = (GeeArrayList*) _tmp220_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp221_, "show_completed");
	_g_object_unref0 (_tmp221_);
	_tmp222_ = self->priv->table_columns;
	_tmp223_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp222_, "Projects");
	_tmp224_ = (GeeArrayList*) _tmp223_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp224_, "description");
	_g_object_unref0 (_tmp224_);
	_tmp225_ = self->priv->table_columns;
	_tmp226_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp225_, "Projects");
	_tmp227_ = (GeeArrayList*) _tmp226_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp227_, "due_date");
	_g_object_unref0 (_tmp227_);
	_tmp228_ = self->priv->table_columns;
	_tmp229_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp228_, "Projects");
	_tmp230_ = (GeeArrayList*) _tmp229_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp230_, "inbox_section_hidded");
	_g_object_unref0 (_tmp230_);
	_tmp231_ = self->priv->table_columns;
	_tmp232_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp231_, "Projects");
	_tmp233_ = (GeeArrayList*) _tmp232_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp233_, "sync_id");
	_g_object_unref0 (_tmp233_);
	_tmp234_ = self->priv->table_columns;
	_tmp235_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp234_, "Projects");
	_tmp236_ = (GeeArrayList*) _tmp235_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp236_, "source_id");
	_g_object_unref0 (_tmp236_);
	_tmp237_ = self->priv->table_columns;
	_tmp238_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp237_, "Projects");
	_tmp239_ = (GeeArrayList*) _tmp238_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp239_, "calendar_url");
	_g_object_unref0 (_tmp239_);
	_tmp240_ = self->priv->table_columns;
	_tmp241_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp240_, "Projects");
	_tmp242_ = (GeeArrayList*) _tmp241_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp242_, "sorted_by");
	_g_object_unref0 (_tmp242_);
	_tmp243_ = self->priv->table_columns;
	_tmp244_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp243_, "Projects");
	_tmp245_ = (GeeArrayList*) _tmp244_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp245_, "calendar_source_uid");
	_g_object_unref0 (_tmp245_);
	_tmp246_ = self->priv->table_columns;
	_tmp247_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp246_, "Projects");
	_tmp248_ = (GeeArrayList*) _tmp247_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp248_, "markdown_setting");
	_g_object_unref0 (_tmp248_);
	_tmp249_ = self->priv->table_columns;
	_tmp250_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp251_ = _tmp250_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp249_, "Queue", _tmp251_);
	_g_object_unref0 (_tmp251_);
	_tmp252_ = self->priv->table_columns;
	_tmp253_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp252_, "Queue");
	_tmp254_ = (GeeArrayList*) _tmp253_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp254_, "uuid");
	_g_object_unref0 (_tmp254_);
	_tmp255_ = self->priv->table_columns;
	_tmp256_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp255_, "Queue");
	_tmp257_ = (GeeArrayList*) _tmp256_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp257_, "object_id");
	_g_object_unref0 (_tmp257_);
	_tmp258_ = self->priv->table_columns;
	_tmp259_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp258_, "Queue");
	_tmp260_ = (GeeArrayList*) _tmp259_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp260_, "query");
	_g_object_unref0 (_tmp260_);
	_tmp261_ = self->priv->table_columns;
	_tmp262_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp261_, "Queue");
	_tmp263_ = (GeeArrayList*) _tmp262_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp263_, "temp_id");
	_g_object_unref0 (_tmp263_);
	_tmp264_ = self->priv->table_columns;
	_tmp265_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp264_, "Queue");
	_tmp266_ = (GeeArrayList*) _tmp265_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp266_, "args");
	_g_object_unref0 (_tmp266_);
	_tmp267_ = self->priv->table_columns;
	_tmp268_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp267_, "Queue");
	_tmp269_ = (GeeArrayList*) _tmp268_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp269_, "source_id");
	_g_object_unref0 (_tmp269_);
	_tmp270_ = self->priv->table_columns;
	_tmp271_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp270_, "Queue");
	_tmp272_ = (GeeArrayList*) _tmp271_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp272_, "date_added");
	_g_object_unref0 (_tmp272_);
	_tmp273_ = self->priv->table_columns;
	_tmp274_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp275_ = _tmp274_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp273_, "Reminders", _tmp275_);
	_g_object_unref0 (_tmp275_);
	_tmp276_ = self->priv->table_columns;
	_tmp277_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp276_, "Reminders");
	_tmp278_ = (GeeArrayList*) _tmp277_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp278_, "id");
	_g_object_unref0 (_tmp278_);
	_tmp279_ = self->priv->table_columns;
	_tmp280_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp279_, "Reminders");
	_tmp281_ = (GeeArrayList*) _tmp280_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp281_, "notify_uid");
	_g_object_unref0 (_tmp281_);
	_tmp282_ = self->priv->table_columns;
	_tmp283_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp282_, "Reminders");
	_tmp284_ = (GeeArrayList*) _tmp283_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp284_, "item_id");
	_g_object_unref0 (_tmp284_);
	_tmp285_ = self->priv->table_columns;
	_tmp286_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp285_, "Reminders");
	_tmp287_ = (GeeArrayList*) _tmp286_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp287_, "service");
	_g_object_unref0 (_tmp287_);
	_tmp288_ = self->priv->table_columns;
	_tmp289_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp288_, "Reminders");
	_tmp290_ = (GeeArrayList*) _tmp289_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp290_, "type");
	_g_object_unref0 (_tmp290_);
	_tmp291_ = self->priv->table_columns;
	_tmp292_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp291_, "Reminders");
	_tmp293_ = (GeeArrayList*) _tmp292_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp293_, "due");
	_g_object_unref0 (_tmp293_);
	_tmp294_ = self->priv->table_columns;
	_tmp295_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp294_, "Reminders");
	_tmp296_ = (GeeArrayList*) _tmp295_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp296_, "mm_offset");
	_g_object_unref0 (_tmp296_);
	_tmp297_ = self->priv->table_columns;
	_tmp298_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp297_, "Reminders");
	_tmp299_ = (GeeArrayList*) _tmp298_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp299_, "is_deleted");
	_g_object_unref0 (_tmp299_);
	_tmp300_ = self->priv->table_columns;
	_tmp301_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp302_ = _tmp301_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp300_, "Sections", _tmp302_);
	_g_object_unref0 (_tmp302_);
	_tmp303_ = self->priv->table_columns;
	_tmp304_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp303_, "Sections");
	_tmp305_ = (GeeArrayList*) _tmp304_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp305_, "id");
	_g_object_unref0 (_tmp305_);
	_tmp306_ = self->priv->table_columns;
	_tmp307_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp306_, "Sections");
	_tmp308_ = (GeeArrayList*) _tmp307_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp308_, "name");
	_g_object_unref0 (_tmp308_);
	_tmp309_ = self->priv->table_columns;
	_tmp310_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp309_, "Sections");
	_tmp311_ = (GeeArrayList*) _tmp310_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp311_, "archived_at");
	_g_object_unref0 (_tmp311_);
	_tmp312_ = self->priv->table_columns;
	_tmp313_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp312_, "Sections");
	_tmp314_ = (GeeArrayList*) _tmp313_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp314_, "added_at");
	_g_object_unref0 (_tmp314_);
	_tmp315_ = self->priv->table_columns;
	_tmp316_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp315_, "Sections");
	_tmp317_ = (GeeArrayList*) _tmp316_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp317_, "project_id");
	_g_object_unref0 (_tmp317_);
	_tmp318_ = self->priv->table_columns;
	_tmp319_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp318_, "Sections");
	_tmp320_ = (GeeArrayList*) _tmp319_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp320_, "section_order");
	_g_object_unref0 (_tmp320_);
	_tmp321_ = self->priv->table_columns;
	_tmp322_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp321_, "Sections");
	_tmp323_ = (GeeArrayList*) _tmp322_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp323_, "collapsed");
	_g_object_unref0 (_tmp323_);
	_tmp324_ = self->priv->table_columns;
	_tmp325_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp324_, "Sections");
	_tmp326_ = (GeeArrayList*) _tmp325_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp326_, "is_deleted");
	_g_object_unref0 (_tmp326_);
	_tmp327_ = self->priv->table_columns;
	_tmp328_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp327_, "Sections");
	_tmp329_ = (GeeArrayList*) _tmp328_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp329_, "is_archived");
	_g_object_unref0 (_tmp329_);
	_tmp330_ = self->priv->table_columns;
	_tmp331_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp330_, "Sections");
	_tmp332_ = (GeeArrayList*) _tmp331_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp332_, "color");
	_g_object_unref0 (_tmp332_);
	_tmp333_ = self->priv->table_columns;
	_tmp334_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp333_, "Sections");
	_tmp335_ = (GeeArrayList*) _tmp334_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp335_, "description");
	_g_object_unref0 (_tmp335_);
	_tmp336_ = self->priv->table_columns;
	_tmp337_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp336_, "Sections");
	_tmp338_ = (GeeArrayList*) _tmp337_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp338_, "hidded");
	_g_object_unref0 (_tmp338_);
	_tmp339_ = self->priv->table_columns;
	_tmp340_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp339_, "Sections");
	_tmp341_ = (GeeArrayList*) _tmp340_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp341_, "extra_data");
	_g_object_unref0 (_tmp341_);
	_tmp342_ = self->priv->table_columns;
	_tmp343_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp344_ = _tmp343_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp342_, "Sources", _tmp344_);
	_g_object_unref0 (_tmp344_);
	_tmp345_ = self->priv->table_columns;
	_tmp346_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp345_, "Sources");
	_tmp347_ = (GeeArrayList*) _tmp346_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp347_, "id");
	_g_object_unref0 (_tmp347_);
	_tmp348_ = self->priv->table_columns;
	_tmp349_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp348_, "Sources");
	_tmp350_ = (GeeArrayList*) _tmp349_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp350_, "source_type");
	_g_object_unref0 (_tmp350_);
	_tmp351_ = self->priv->table_columns;
	_tmp352_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp351_, "Sources");
	_tmp353_ = (GeeArrayList*) _tmp352_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp353_, "display_name");
	_g_object_unref0 (_tmp353_);
	_tmp354_ = self->priv->table_columns;
	_tmp355_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp354_, "Sources");
	_tmp356_ = (GeeArrayList*) _tmp355_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp356_, "added_at");
	_g_object_unref0 (_tmp356_);
	_tmp357_ = self->priv->table_columns;
	_tmp358_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp357_, "Sources");
	_tmp359_ = (GeeArrayList*) _tmp358_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp359_, "updated_at");
	_g_object_unref0 (_tmp359_);
	_tmp360_ = self->priv->table_columns;
	_tmp361_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp360_, "Sources");
	_tmp362_ = (GeeArrayList*) _tmp361_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp362_, "is_visible");
	_g_object_unref0 (_tmp362_);
	_tmp363_ = self->priv->table_columns;
	_tmp364_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp363_, "Sources");
	_tmp365_ = (GeeArrayList*) _tmp364_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp365_, "child_order");
	_g_object_unref0 (_tmp365_);
	_tmp366_ = self->priv->table_columns;
	_tmp367_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp366_, "Sources");
	_tmp368_ = (GeeArrayList*) _tmp367_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp368_, "sync_server");
	_g_object_unref0 (_tmp368_);
	_tmp369_ = self->priv->table_columns;
	_tmp370_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp369_, "Sources");
	_tmp371_ = (GeeArrayList*) _tmp370_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp371_, "last_sync");
	_g_object_unref0 (_tmp371_);
	_tmp372_ = self->priv->table_columns;
	_tmp373_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp372_, "Sources");
	_tmp374_ = (GeeArrayList*) _tmp373_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp374_, "data");
	_g_object_unref0 (_tmp374_);
	return obj;
}

static void
services_database_class_init (ServicesDatabaseClass * klass,
                              gpointer klass_data)
{
	services_database_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ServicesDatabase_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_services_database_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_services_database_set_property;
	G_OBJECT_CLASS (klass)->constructor = services_database_constructor;
	G_OBJECT_CLASS (klass)->finalize = services_database_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SERVICES_DATABASE_IS_OPENED_PROPERTY, services_database_properties[SERVICES_DATABASE_IS_OPENED_PROPERTY] = g_param_spec_boolean ("is-opened", "is-opened", "is-opened", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	services_database_signals[SERVICES_DATABASE_OPENED_SIGNAL] = g_signal_new ("opened", SERVICES_TYPE_DATABASE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	services_database_signals[SERVICES_DATABASE_RESET_SIGNAL] = g_signal_new ("reset", SERVICES_TYPE_DATABASE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
services_database_instance_init (ServicesDatabase * self,
                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = services_database_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->table_columns = _tmp0_;
	self->priv->_is_opened = FALSE;
}

static void
services_database_finalize (GObject * obj)
{
	ServicesDatabase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SERVICES_TYPE_DATABASE, ServicesDatabase);
	_sqlite3_close0 (self->priv->db);
	_g_free0 (self->priv->db_path);
	_g_free0 (self->priv->errormsg);
	_g_free0 (self->priv->sql);
	_g_object_unref0 (self->priv->table_columns);
	_g_object_unref0 (self->priv->parser);
	G_OBJECT_CLASS (services_database_parent_class)->finalize (obj);
}

static GType
services_database_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ServicesDatabaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) services_database_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ServicesDatabase), 0, (GInstanceInitFunc) services_database_instance_init, NULL };
	GType services_database_type_id;
	services_database_type_id = g_type_register_static (G_TYPE_OBJECT, "ServicesDatabase", &g_define_type_info, 0);
	ServicesDatabase_private_offset = g_type_add_instance_private (services_database_type_id, sizeof (ServicesDatabasePrivate));
	return services_database_type_id;
}

GType
services_database_get_type (void)
{
	static volatile gsize services_database_type_id__once = 0;
	if (g_once_init_enter (&services_database_type_id__once)) {
		GType services_database_type_id;
		services_database_type_id = services_database_get_type_once ();
		g_once_init_leave (&services_database_type_id__once, services_database_type_id);
	}
	return services_database_type_id__once;
}

static void
_vala_services_database_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	ServicesDatabase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SERVICES_TYPE_DATABASE, ServicesDatabase);
	switch (property_id) {
		case SERVICES_DATABASE_IS_OPENED_PROPERTY:
		g_value_set_boolean (value, services_database_get_is_opened (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_services_database_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	ServicesDatabase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SERVICES_TYPE_DATABASE, ServicesDatabase);
	switch (property_id) {
		case SERVICES_DATABASE_IS_OPENED_PROPERTY:
		services_database_set_is_opened (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

