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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright © 2025 Johan Gay
 *
 * This file is part of GNOME Sudoku.
 *
 * GNOME Sudoku 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.
 *
 * GNOME Sudoku 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 GNOME Sudoku. If not, see <http://www.gnu.org/licenses/>.
 */

#include "libsudoku.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <glib/gstdio.h>
#include <errno.h>
#include <gio/gio.h>
#include <gee.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  {
	SUDOKU_BACKEND_0_PROPERTY,
	SUDOKU_BACKEND_GAME_PROPERTY,
	SUDOKU_BACKEND_TGAME_PROPERTY,
	SUDOKU_BACKEND_NUM_PROPERTIES
};
static GParamSpec* sudoku_backend_properties[SUDOKU_BACKEND_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
enum  {
	SUDOKU_BACKEND_GAME_CHANGED_SIGNAL,
	SUDOKU_BACKEND_NUM_SIGNALS
};
static guint sudoku_backend_signals[SUDOKU_BACKEND_NUM_SIGNALS] = {0};

struct _SudokuBackendPrivate {
	SudokuGame* _game;
	SudokuGame* _tgame;
	Highscores* highscores;
	guint autosave_timeout;
};

struct _Block1Data {
	int _ref_count_;
	SudokuBackend* weak_this;
};

static gint SudokuBackend_private_offset;
static gpointer sudoku_backend_parent_class = NULL;
static gchar* sudoku_backend__active_save_file;
static gchar* sudoku_backend__active_save_file = NULL;
static gchar* sudoku_backend__highscores_file;
static gchar* sudoku_backend__highscores_file = NULL;
static gchar* sudoku_backend__sudoku_data_dir;
static gchar* sudoku_backend__sudoku_data_dir = NULL;
static gchar* sudoku_backend__printed_dir;
static gchar* sudoku_backend__printed_dir = NULL;
static gchar* sudoku_backend__finished_dir;
static gchar* sudoku_backend__finished_dir = NULL;
static gchar* sudoku_backend__saved_dir;
static gchar* sudoku_backend__saved_dir = NULL;

static void sudoku_backend_load_game (SudokuBackend* self);
static void sudoku_backend_start_autosave (SudokuBackend* _this);
static void sudoku_backend_set_game (SudokuBackend* self,
                              SudokuGame* value);
static void sudoku_backend_set_tgame (SudokuBackend* self,
                               SudokuGame* value);
static void sudoku_backend_create_file_for_game (SudokuBackend* self,
                                          SudokuGame* game,
                                          const gchar* file_name,
                                          gboolean save_timer);
static guint8* _vala_array_dup1 (guint8* self,
                          gssize length);
static void __lambda9_ (SudokuBackend* self,
                 GObject* obj,
                 GAsyncResult* res);
static void ___lambda9__gasync_ready_callback (GObject* source_object,
                                        GAsyncResult* res,
                                        gpointer self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static gboolean __lambda5_ (Block1Data* _data1_);
static gboolean ___lambda5__gsource_func (gpointer self);
static gdouble* _double_dup (gdouble* self);
static void sudoku_backend_real_dispose (GObject* base);
static void sudoku_backend_set_active_save_file (const gchar* value);
static void sudoku_backend_set_highscores_file (const gchar* value);
static void sudoku_backend_set_sudoku_data_dir (const gchar* value);
static void sudoku_backend_set_printed_dir (const gchar* value);
static void sudoku_backend_set_finished_dir (const gchar* value);
static void sudoku_backend_set_saved_dir (const gchar* value);
static void sudoku_backend_finalize (GObject * obj);
static GType sudoku_backend_get_type_once (void);
static void _vala_sudoku_backend_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_sudoku_backend_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
sudoku_backend_get_instance_private (SudokuBackend* self)
{
	return G_STRUCT_MEMBER_P (self, SudokuBackend_private_offset);
}

gdouble*
sudoku_backend_get_highscore (SudokuBackend* self)
{
	SudokuGame* _tmp0_;
	gdouble* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_game;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	} else {
		Highscores* _tmp1_;
		SudokuGame* _tmp2_;
		SudokuBoard* _tmp3_;
		SudokuBoard* _tmp4_;
		DifficultyCategory _tmp5_;
		DifficultyCategory _tmp6_;
		gdouble* _tmp7_;
		_tmp1_ = self->priv->highscores;
		_tmp2_ = self->priv->_game;
		_tmp3_ = sudoku_game_get_board (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = sudoku_board_get_difficulty_category (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = highscores_get_highscore (_tmp1_, _tmp6_);
		result = _tmp7_;
		return result;
	}
}

SudokuBackend*
sudoku_backend_construct (GType object_type)
{
	SudokuBackend * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	Highscores* _tmp5_;
	self = (SudokuBackend*) g_object_new (object_type, NULL);
	_tmp0_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp1_ = _tmp0_;
	if (g_mkdir_with_parents (_tmp1_, 0755) == -1) {
		const gchar* _tmp2_;
		_tmp2_ = g_strerror (errno);
		g_warning ("backend.vala:57: Failed to create saver directory: %s", _tmp2_);
	}
	_tmp3_ = sudoku_backend_get_highscores_file ();
	_tmp4_ = _tmp3_;
	_tmp5_ = highscores_new (_tmp4_);
	_g_object_unref0 (self->priv->highscores);
	self->priv->highscores = _tmp5_;
	sudoku_backend_load_game (self);
	return self;
}

SudokuBackend*
sudoku_backend_new (void)
{
	return sudoku_backend_construct (TYPE_SUDOKU_BACKEND);
}

void
sudoku_backend_change_game (SudokuBackend* self,
                            SudokuGame* new_game)
{
	SudokuGame* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_game != NULL);
	sudoku_backend_start_autosave (self);
	_tmp0_ = self->priv->_game;
	if (_tmp0_ != NULL) {
		sudoku_backend_delete_save (self);
	}
	sudoku_backend_set_game (self, new_game);
	sudoku_backend_set_tgame (self, NULL);
	g_signal_emit (self, sudoku_backend_signals[SUDOKU_BACKEND_GAME_CHANGED_SIGNAL], 0);
}

void
sudoku_backend_start_shared_game (SudokuBackend* self)
{
	SudokuGame* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_tgame;
	if (_tmp0_ != NULL) {
		SudokuGame* _tmp1_;
		_tmp1_ = self->priv->_tgame;
		sudoku_backend_change_game (self, _tmp1_);
	}
}

void
sudoku_backend_save_game (SudokuBackend* self)
{
	gboolean _tmp0_ = FALSE;
	SudokuGame* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_game;
	if (_tmp1_ != NULL) {
		SudokuGame* _tmp2_;
		_tmp2_ = self->priv->_game;
		_tmp0_ = !sudoku_game_is_empty (_tmp2_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		SudokuGame* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp3_ = self->priv->_game;
		_tmp4_ = sudoku_backend_get_active_save_file ();
		_tmp5_ = _tmp4_;
		sudoku_backend_create_file_for_game (self, _tmp3_, _tmp5_, TRUE);
	} else {
		sudoku_backend_delete_save (self);
	}
}

void
sudoku_backend_save_game_as (SudokuBackend* self,
                             const gchar* path)
{
	SudokuGame* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = self->priv->_game;
	sudoku_backend_create_file_for_game (self, _tmp0_, path, TRUE);
}

void
sudoku_backend_delete_save (SudokuBackend* self)
{
	GFile* file = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = sudoku_backend_get_active_save_file ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_file_new_for_path (_tmp1_);
	file = _tmp2_;
	{
		g_file_delete (file, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		if (_tmp3_->code != G_IO_ERROR_NOT_FOUND) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			GError* _tmp6_;
			const gchar* _tmp7_;
			_tmp4_ = g_file_get_uri (file);
			_tmp5_ = _tmp4_;
			_tmp6_ = e;
			_tmp7_ = _tmp6_->message;
			g_warning ("backend.vala:105: Failed to delete %s: %s", _tmp5_, _tmp7_);
			_g_free0 (_tmp5_);
		}
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (file);
		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 (file);
}

static void
sudoku_backend_load_game (SudokuBackend* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		SudokuBoard* saved_board = NULL;
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		SudokuBoard* _tmp2_;
		SudokuGame* saved_game = NULL;
		SudokuBoard* _tmp3_;
		SudokuGame* _tmp4_;
		SudokuGame* _tmp5_;
		_tmp0_ = sudoku_backend_get_active_save_file ();
		_tmp1_ = _tmp0_;
		_tmp2_ = sudoku_board_new_from_json (_tmp1_, &_inner_error0_);
		saved_board = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = saved_board;
		_tmp4_ = sudoku_game_new (_tmp3_, &_inner_error0_);
		saved_game = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (saved_board);
			goto __catch0_g_error;
		}
		_tmp5_ = saved_game;
		sudoku_backend_change_game (self, _tmp5_);
		_g_object_unref0 (saved_game);
		_g_object_unref0 (saved_board);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		return;
	}
	__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;
	}
}

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

static guint8*
_vala_array_dup1 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

gboolean
sudoku_backend_load_game_path (SudokuBackend* self,
                               const gchar* path)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	{
		SudokuBoard* _tmp0_ = NULL;
		SudokuBoard* _tmp1_;
		SudokuGame* ngame = NULL;
		SudokuGame* _tmp2_;
		SudokuGame* _tmp3_;
		_tmp1_ = sudoku_board_new_from_json (path, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = sudoku_game_new (_tmp0_, &_inner_error0_);
		ngame = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp0_);
			goto __catch0_g_error;
		}
		_tmp3_ = ngame;
		sudoku_backend_change_game (self, _tmp3_);
		result = TRUE;
		_g_object_unref0 (ngame);
		_g_object_unref0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_print ("%s", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp6_ = FALSE;
		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 _tmp6_;
	}
	{
		GFile* file = NULL;
		GFile* _tmp7_;
		GFileIOStream* iostream = NULL;
		GFile* _tmp8_;
		GFileIOStream* _tmp9_;
		GInputStream* istream = NULL;
		GFileIOStream* _tmp10_;
		GInputStream* _tmp11_;
		GInputStream* _tmp12_;
		GInputStream* _tmp13_;
		GBytes* _tmp14_ = NULL;
		GInputStream* _tmp15_;
		GBytes* _tmp16_;
		guint8* bytes = NULL;
		gsize _tmp17_ = 0;
		guint8* _tmp18_;
		guint8* _tmp19_;
		gint _tmp19__length1;
		gint bytes_length1;
		gint _bytes_size_;
		SudokuBoard* board = NULL;
		guint8* _tmp20_;
		gint _tmp20__length1;
		SudokuBoard* _tmp21_;
		SudokuGame* new_game = NULL;
		SudokuBoard* _tmp22_;
		SudokuGame* _tmp23_;
		SudokuGame* _tmp24_;
		_tmp7_ = g_file_new_for_path (path);
		file = _tmp7_;
		_tmp8_ = file;
		_tmp9_ = g_file_open_readwrite (_tmp8_, NULL, &_inner_error0_);
		iostream = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (file);
			goto __catch1_g_error;
		}
		_tmp10_ = iostream;
		_tmp11_ = g_io_stream_get_input_stream ((GIOStream*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = _g_object_ref0 (_tmp12_);
		istream = _tmp13_;
		_tmp15_ = istream;
		_tmp16_ = g_input_stream_read_bytes (_tmp15_, (gsize) 100, NULL, &_inner_error0_);
		_tmp14_ = _tmp16_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (istream);
			_g_object_unref0 (iostream);
			_g_object_unref0 (file);
			goto __catch1_g_error;
		}
		_tmp18_ = g_bytes_get_data (_tmp14_, &_tmp17_);
		_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup1 (_tmp18_, _tmp17_) : _tmp18_;
		_tmp19__length1 = _tmp17_;
		bytes = _tmp19_;
		bytes_length1 = _tmp19__length1;
		_bytes_size_ = bytes_length1;
		_tmp20_ = bytes;
		_tmp20__length1 = bytes_length1;
		_tmp21_ = sudoku_board_new_from_string ((const gchar*) _tmp20_, &_inner_error0_);
		board = _tmp21_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			bytes = (g_free (bytes), NULL);
			_g_bytes_unref0 (_tmp14_);
			_g_object_unref0 (istream);
			_g_object_unref0 (iostream);
			_g_object_unref0 (file);
			goto __catch1_g_error;
		}
		_tmp22_ = board;
		_tmp23_ = sudoku_game_new (_tmp22_, &_inner_error0_);
		new_game = _tmp23_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (board);
			bytes = (g_free (bytes), NULL);
			_g_bytes_unref0 (_tmp14_);
			_g_object_unref0 (istream);
			_g_object_unref0 (iostream);
			_g_object_unref0 (file);
			goto __catch1_g_error;
		}
		_tmp24_ = new_game;
		sudoku_backend_change_game (self, _tmp24_);
		_g_object_unref0 (new_game);
		_g_object_unref0 (board);
		bytes = (g_free (bytes), NULL);
		_g_bytes_unref0 (_tmp14_);
		_g_object_unref0 (istream);
		_g_object_unref0 (iostream);
		_g_object_unref0 (file);
	}
	goto __finally1;
	__catch1_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = FALSE;
		return result;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp25_ = FALSE;
		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 _tmp25_;
	}
	result = TRUE;
	return result;
}

gboolean
sudoku_backend_save_highscore (SudokuBackend* self)
{
	gdouble* highscore = NULL;
	Highscores* _tmp0_;
	SudokuGame* _tmp1_;
	SudokuBoard* _tmp2_;
	SudokuBoard* _tmp3_;
	DifficultyCategory _tmp4_;
	DifficultyCategory _tmp5_;
	gdouble* _tmp6_;
	gboolean _tmp7_ = FALSE;
	gdouble* _tmp8_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->highscores;
	_tmp1_ = self->priv->_game;
	_tmp2_ = sudoku_game_get_board (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = sudoku_board_get_difficulty_category (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = highscores_get_highscore (_tmp0_, _tmp5_);
	highscore = _tmp6_;
	_tmp8_ = highscore;
	if (_tmp8_ == NULL) {
		_tmp7_ = TRUE;
	} else {
		gboolean _tmp9_ = FALSE;
		gdouble* _tmp10_;
		_tmp10_ = highscore;
		if (_tmp10_ != NULL) {
			SudokuGame* _tmp11_;
			gdouble* _tmp12_;
			_tmp11_ = self->priv->_game;
			_tmp12_ = highscore;
			_tmp9_ = sudoku_game_get_total_time_played (_tmp11_) < (*_tmp12_);
		} else {
			_tmp9_ = FALSE;
		}
		_tmp7_ = _tmp9_;
	}
	if (_tmp7_) {
		Highscores* _tmp13_;
		SudokuGame* _tmp14_;
		SudokuBoard* _tmp15_;
		SudokuBoard* _tmp16_;
		DifficultyCategory _tmp17_;
		DifficultyCategory _tmp18_;
		SudokuGame* _tmp19_;
		_tmp13_ = self->priv->highscores;
		_tmp14_ = self->priv->_game;
		_tmp15_ = sudoku_game_get_board (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = sudoku_board_get_difficulty_category (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = self->priv->_game;
		highscores_save_highscore (_tmp13_, _tmp18_, sudoku_game_get_total_time_played (_tmp19_));
		result = TRUE;
		_g_free0 (highscore);
		return result;
	}
	result = FALSE;
	_g_free0 (highscore);
	return result;
}

gboolean
sudoku_backend_check_clipboard (SudokuBackend* self,
                                const gchar* clipboard)
{
	gboolean _tmp6_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (clipboard != NULL, FALSE);
	{
		SudokuBoard* board = NULL;
		SudokuBoard* _tmp0_ = NULL;
		SudokuBoard* _tmp1_;
		SudokuBoard* _tmp2_;
		SudokuGame* game = NULL;
		SudokuBoard* _tmp3_;
		SudokuGame* _tmp4_;
		SudokuGame* _tmp5_;
		_tmp1_ = sudoku_board_new_from_ascii_string (clipboard, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (board);
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (board);
		board = _tmp2_;
		_tmp3_ = board;
		_tmp4_ = sudoku_game_new (_tmp3_, &_inner_error0_);
		game = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp0_);
			_g_object_unref0 (board);
			goto __catch0_g_error;
		}
		_tmp5_ = game;
		sudoku_backend_set_tgame (self, _tmp5_);
		result = TRUE;
		_g_object_unref0 (game);
		_g_object_unref0 (_tmp0_);
		_g_object_unref0 (board);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = FALSE;
		return result;
	}
	__finally0:
	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 _tmp6_;
}

static void
__lambda9_ (SudokuBackend* self,
            GObject* obj,
            GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		GeeList* gen_boards = NULL;
		GeeList* _tmp0_;
		SudokuGame* ngame = NULL;
		GeeList* _tmp1_;
		gpointer _tmp2_;
		SudokuBoard* _tmp3_;
		SudokuGame* _tmp4_;
		SudokuGame* _tmp5_;
		SudokuGame* _tmp6_;
		_tmp0_ = sudoku_generator_generate_boards_finish (res, &_inner_error0_);
		gen_boards = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = gen_boards;
		_tmp2_ = gee_list_get (_tmp1_, 0);
		_tmp3_ = (SudokuBoard*) _tmp2_;
		_tmp4_ = sudoku_game_new (_tmp3_, &_inner_error0_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		ngame = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (gen_boards);
			goto __catch0_g_error;
		}
		_tmp6_ = ngame;
		sudoku_backend_change_game (self, _tmp6_);
		_g_object_unref0 (ngame);
		_g_object_unref0 (gen_boards);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp7_ = e->message;
		g_error ("backend.vala:195: Error: %s", _tmp7_);
		_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;
	}
}

static void
___lambda9__gasync_ready_callback (GObject* source_object,
                                   GAsyncResult* res,
                                   gpointer self)
{
	__lambda9_ ((SudokuBackend*) self, source_object, res);
	g_object_unref (self);
}

void
sudoku_backend_generate_game (SudokuBackend* self,
                              DifficultyCategory difficulty)
{
	g_return_if_fail (self != NULL);
	sudoku_generator_generate_boards_async (1, difficulty, NULL, ___lambda9__gasync_ready_callback, g_object_ref (self));
}

void
sudoku_backend_export_puzzle (SudokuBackend* self,
                              const gchar* path)
{
	gchar* content = NULL;
	SudokuGame* _tmp0_;
	SudokuBoard* _tmp1_;
	SudokuBoard* _tmp2_;
	gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = self->priv->_game;
	_tmp1_ = sudoku_game_get_board (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = sudoku_board_to_string_pretty (_tmp2_);
	content = _tmp3_;
	{
		g_file_set_contents (path, content, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("backend.vala:209: %s", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (content);
		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_free0 (content);
}

gchar*
sudoku_backend_get_short_puzzle (SudokuBackend* self)
{
	SudokuGame* _tmp0_;
	SudokuBoard* _tmp1_;
	SudokuBoard* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_game;
	_tmp1_ = sudoku_game_get_board (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = sudoku_board_fixed_to_ascii_string (_tmp2_);
	result = _tmp3_;
	return result;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		g_slice_free (Block1Data, _data1_);
	}
}

static gboolean
__lambda5_ (Block1Data* _data1_)
{
	gboolean result;
	sudoku_backend_save_game (_data1_->weak_this);
	result = G_SOURCE_CONTINUE;
	return result;
}

static gboolean
___lambda5__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda5_ (self);
	return result;
}

static void
sudoku_backend_start_autosave (SudokuBackend* _this)
{
	Block1Data* _data1_;
	g_return_if_fail (_this != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->weak_this = _this;
	sudoku_backend_stop_autosave (_data1_->weak_this);
	_data1_->weak_this->priv->autosave_timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 300, ___lambda5__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	g_source_set_name_by_id (_data1_->weak_this->priv->autosave_timeout, "[gnome-sudoku] autosave");
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

void
sudoku_backend_stop_autosave (SudokuBackend* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->autosave_timeout != ((guint) 0)) {
		g_source_remove (self->priv->autosave_timeout);
		self->priv->autosave_timeout = (guint) 0;
	}
}

static gdouble*
_double_dup (gdouble* self)
{
	gdouble* dup;
	dup = g_new0 (gdouble, 1);
	memcpy (dup, self, sizeof (gdouble));
	return dup;
}

static gpointer
__double_dup0 (gpointer self)
{
	return self ? _double_dup (self) : NULL;
}

static void
sudoku_backend_create_file_for_game (SudokuBackend* self,
                                     SudokuGame* game,
                                     const gchar* file_name,
                                     gboolean save_timer)
{
	gdouble* elapsed_time = NULL;
	gchar* json_str = NULL;
	SudokuBoard* _tmp2_;
	SudokuBoard* _tmp3_;
	gdouble* _tmp4_;
	gchar* _tmp5_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (game != NULL);
	g_return_if_fail (file_name != NULL);
	if (save_timer) {
		gdouble _tmp0_;
		gdouble* _tmp1_;
		_tmp0_ = sudoku_game_get_elapsed_time (game);
		_tmp1_ = __double_dup0 (&_tmp0_);
		_g_free0 (elapsed_time);
		elapsed_time = _tmp1_;
	} else {
		_g_free0 (elapsed_time);
		elapsed_time = NULL;
	}
	_tmp2_ = sudoku_game_get_board (game);
	_tmp3_ = _tmp2_;
	_tmp4_ = elapsed_time;
	_tmp5_ = sudoku_board_to_json (_tmp3_, _tmp4_);
	json_str = _tmp5_;
	{
		g_file_set_contents (file_name, json_str, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("backend.vala:258: %s", _tmp7_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (json_str);
		_g_free0 (elapsed_time);
		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_free0 (json_str);
	_g_free0 (elapsed_time);
}

static GError*
vala_g_io_error_from_errno (gint err_no)
{
	const gchar* _tmp0_;
	GError* _tmp1_;
	GError* result;
	_tmp0_ = g_strerror (err_no);
	_tmp1_ = g_error_new (g_io_error_quark (), g_io_error_from_errno (err_no), "%s", _tmp0_);
	result = (GError*) _tmp1_;
	return result;
}

void
sudoku_backend_archive_game (SudokuBackend* self,
                             const gchar* dir_path,
                             SudokuGame* game,
                             gboolean save_timer)
{
	gchar* file_name = NULL;
	SudokuBoard* _tmp4_;
	SudokuBoard* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* file_path = NULL;
	gchar* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dir_path != NULL);
	g_return_if_fail (game != NULL);
	if (g_mkdir (dir_path, 0755) == -1) {
		GError* e = NULL;
		GError* _tmp0_;
		GError* _tmp1_;
		_tmp0_ = vala_g_io_error_from_errno (errno);
		e = _tmp0_;
		_tmp1_ = e;
		if (_tmp1_->code != G_IO_ERROR_EXISTS) {
			GError* _tmp2_;
			const gchar* _tmp3_;
			_tmp2_ = e;
			_tmp3_ = _tmp2_->message;
			g_warning ("backend.vala:268: Failed to create the folder to archive the game: %s", _tmp3_);
		}
		_g_error_free0 (e);
	}
	_tmp4_ = sudoku_game_get_board (game);
	_tmp5_ = _tmp4_;
	_tmp6_ = sudoku_board_to_string (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, ".save", NULL);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	file_name = _tmp9_;
	_tmp10_ = g_build_path (G_DIR_SEPARATOR_S, dir_path, file_name, NULL);
	file_path = _tmp10_;
	sudoku_backend_create_file_for_game (self, game, file_path, save_timer);
	_g_free0 (file_path);
	_g_free0 (file_name);
}

void
sudoku_backend_add_board_to_printed (SudokuBackend* self,
                                     SudokuBoard* board)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (board != NULL);
	{
		SudokuGame* ngame = NULL;
		SudokuGame* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		_tmp0_ = sudoku_game_new (board, &_inner_error0_);
		ngame = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = sudoku_backend_get_printed_dir ();
		_tmp2_ = _tmp1_;
		sudoku_backend_archive_game (self, _tmp2_, ngame, FALSE);
		_g_object_unref0 (ngame);
	}
	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_print ("%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;
	}
}

void
sudoku_backend_add_game_to_printed (SudokuBackend* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	SudokuGame* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = sudoku_backend_get_printed_dir ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_game;
	sudoku_backend_archive_game (self, _tmp1_, _tmp2_, FALSE);
}

void
sudoku_backend_add_game_to_finished (SudokuBackend* self,
                                     gboolean save_timer)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	SudokuGame* _tmp2_;
	g_return_if_fail (self != NULL);
	sudoku_backend_stop_autosave (self);
	_tmp0_ = sudoku_backend_get_finished_dir ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_game;
	sudoku_backend_archive_game (self, _tmp1_, _tmp2_, save_timer);
	sudoku_backend_delete_save (self);
}

static void
sudoku_backend_real_dispose (GObject* base)
{
	SudokuBackend * self;
	self = (SudokuBackend*) base;
	G_OBJECT_CLASS (sudoku_backend_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}

const gchar*
sudoku_backend_get_active_save_file (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__active_save_file;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_active_save_file (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__active_save_file);
	sudoku_backend__active_save_file = _tmp0_;
}

const gchar*
sudoku_backend_get_highscores_file (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__highscores_file;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_highscores_file (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__highscores_file);
	sudoku_backend__highscores_file = _tmp0_;
}

const gchar*
sudoku_backend_get_sudoku_data_dir (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__sudoku_data_dir;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_sudoku_data_dir (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__sudoku_data_dir);
	sudoku_backend__sudoku_data_dir = _tmp0_;
}

const gchar*
sudoku_backend_get_printed_dir (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__printed_dir;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_printed_dir (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__printed_dir);
	sudoku_backend__printed_dir = _tmp0_;
}

const gchar*
sudoku_backend_get_finished_dir (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__finished_dir;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_finished_dir (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__finished_dir);
	sudoku_backend__finished_dir = _tmp0_;
}

const gchar*
sudoku_backend_get_saved_dir (void)
{
	const gchar* result;
	const gchar* _tmp0_;
	_tmp0_ = sudoku_backend__saved_dir;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_saved_dir (const gchar* value)
{
	gchar* _tmp0_;
	_tmp0_ = g_strdup (value);
	_g_free0 (sudoku_backend__saved_dir);
	sudoku_backend__saved_dir = _tmp0_;
}

SudokuGame*
sudoku_backend_get_game (SudokuBackend* self)
{
	SudokuGame* result;
	SudokuGame* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_game;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_game (SudokuBackend* self,
                         SudokuGame* value)
{
	SudokuGame* old_value;
	g_return_if_fail (self != NULL);
	old_value = sudoku_backend_get_game (self);
	if (old_value != value) {
		SudokuGame* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_game);
		self->priv->_game = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, sudoku_backend_properties[SUDOKU_BACKEND_GAME_PROPERTY]);
	}
}

SudokuGame*
sudoku_backend_get_tgame (SudokuBackend* self)
{
	SudokuGame* result;
	SudokuGame* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_tgame;
	result = _tmp0_;
	return result;
}

static void
sudoku_backend_set_tgame (SudokuBackend* self,
                          SudokuGame* value)
{
	SudokuGame* old_value;
	g_return_if_fail (self != NULL);
	old_value = sudoku_backend_get_tgame (self);
	if (old_value != value) {
		SudokuGame* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_tgame);
		self->priv->_tgame = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, sudoku_backend_properties[SUDOKU_BACKEND_TGAME_PROPERTY]);
	}
}

static void
sudoku_backend_class_init (SudokuBackendClass * klass,
                           gpointer klass_data)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* config_dir = NULL;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	sudoku_backend_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SudokuBackend_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) sudoku_backend_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_sudoku_backend_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sudoku_backend_set_property;
	G_OBJECT_CLASS (klass)->finalize = sudoku_backend_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SUDOKU_BACKEND_GAME_PROPERTY, sudoku_backend_properties[SUDOKU_BACKEND_GAME_PROPERTY] = g_param_spec_object ("game", "game", "game", TYPE_SUDOKU_GAME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SUDOKU_BACKEND_TGAME_PROPERTY, sudoku_backend_properties[SUDOKU_BACKEND_TGAME_PROPERTY] = g_param_spec_object ("tgame", "tgame", "tgame", TYPE_SUDOKU_GAME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	sudoku_backend_signals[SUDOKU_BACKEND_GAME_CHANGED_SIGNAL] = g_signal_new ("game-changed", TYPE_SUDOKU_BACKEND, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	_tmp0_ = g_strdup ("");
	sudoku_backend__active_save_file = _tmp0_;
	_tmp1_ = g_strdup ("");
	sudoku_backend__highscores_file = _tmp1_;
	_tmp2_ = g_strdup ("");
	sudoku_backend__sudoku_data_dir = _tmp2_;
	_tmp3_ = g_strdup ("");
	sudoku_backend__printed_dir = _tmp3_;
	_tmp4_ = g_strdup ("");
	sudoku_backend__finished_dir = _tmp4_;
	_tmp5_ = g_strdup ("");
	sudoku_backend__saved_dir = _tmp5_;
	_tmp6_ = g_get_user_data_dir ();
	_tmp7_ = g_strdup (_tmp6_);
	config_dir = _tmp7_;
	_tmp8_ = config_dir;
	_tmp9_ = g_build_path (G_DIR_SEPARATOR_S, _tmp8_, "gnome-sudoku", NULL);
	_tmp10_ = _tmp9_;
	sudoku_backend_set_sudoku_data_dir (_tmp10_);
	_g_free0 (_tmp10_);
	_tmp11_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp12_ = _tmp11_;
	_tmp13_ = g_build_path (G_DIR_SEPARATOR_S, _tmp12_, "savefile", NULL);
	_tmp14_ = _tmp13_;
	sudoku_backend_set_active_save_file (_tmp14_);
	_g_free0 (_tmp14_);
	_tmp15_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp16_ = _tmp15_;
	_tmp17_ = g_build_path (G_DIR_SEPARATOR_S, _tmp16_, "highscores", NULL);
	_tmp18_ = _tmp17_;
	sudoku_backend_set_highscores_file (_tmp18_);
	_g_free0 (_tmp18_);
	_tmp19_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp20_ = _tmp19_;
	_tmp21_ = g_build_path (G_DIR_SEPARATOR_S, _tmp20_, "printed", NULL);
	_tmp22_ = _tmp21_;
	sudoku_backend_set_printed_dir (_tmp22_);
	_g_free0 (_tmp22_);
	_tmp23_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp24_ = _tmp23_;
	_tmp25_ = g_build_path (G_DIR_SEPARATOR_S, _tmp24_, "finished", NULL);
	_tmp26_ = _tmp25_;
	sudoku_backend_set_finished_dir (_tmp26_);
	_g_free0 (_tmp26_);
	_tmp27_ = sudoku_backend_get_sudoku_data_dir ();
	_tmp28_ = _tmp27_;
	_tmp29_ = g_build_path (G_DIR_SEPARATOR_S, _tmp28_, "saved", NULL);
	_tmp30_ = _tmp29_;
	sudoku_backend_set_saved_dir (_tmp30_);
	_g_free0 (_tmp30_);
	_g_free0 (config_dir);
}

static void
sudoku_backend_instance_init (SudokuBackend * self,
                              gpointer klass)
{
	self->priv = sudoku_backend_get_instance_private (self);
	self->priv->_game = NULL;
	self->priv->_tgame = NULL;
}

static void
sudoku_backend_finalize (GObject * obj)
{
	SudokuBackend * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SUDOKU_BACKEND, SudokuBackend);
	_g_object_unref0 (self->priv->_game);
	_g_object_unref0 (self->priv->_tgame);
	_g_object_unref0 (self->priv->highscores);
	G_OBJECT_CLASS (sudoku_backend_parent_class)->finalize (obj);
}

static GType
sudoku_backend_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SudokuBackendClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sudoku_backend_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SudokuBackend), 0, (GInstanceInitFunc) sudoku_backend_instance_init, NULL };
	GType sudoku_backend_type_id;
	sudoku_backend_type_id = g_type_register_static (G_TYPE_OBJECT, "SudokuBackend", &g_define_type_info, 0);
	SudokuBackend_private_offset = g_type_add_instance_private (sudoku_backend_type_id, sizeof (SudokuBackendPrivate));
	return sudoku_backend_type_id;
}

GType
sudoku_backend_get_type (void)
{
	static volatile gsize sudoku_backend_type_id__once = 0;
	if (g_once_init_enter (&sudoku_backend_type_id__once)) {
		GType sudoku_backend_type_id;
		sudoku_backend_type_id = sudoku_backend_get_type_once ();
		g_once_init_leave (&sudoku_backend_type_id__once, sudoku_backend_type_id);
	}
	return sudoku_backend_type_id__once;
}

static void
_vala_sudoku_backend_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	SudokuBackend * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_SUDOKU_BACKEND, SudokuBackend);
	switch (property_id) {
		case SUDOKU_BACKEND_GAME_PROPERTY:
		g_value_set_object (value, sudoku_backend_get_game (self));
		break;
		case SUDOKU_BACKEND_TGAME_PROPERTY:
		g_value_set_object (value, sudoku_backend_get_tgame (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_sudoku_backend_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	SudokuBackend * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_SUDOKU_BACKEND, SudokuBackend);
	switch (property_id) {
		case SUDOKU_BACKEND_GAME_PROPERTY:
		sudoku_backend_set_game (self, g_value_get_object (value));
		break;
		case SUDOKU_BACKEND_TGAME_PROPERTY:
		sudoku_backend_set_tgame (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

