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

/*
* Copyright 2011-2020 elementary, Inc. (https://elementary.io)
*
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser 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, see http://www.gnu.org/licenses/.
*/

#include "keyboard.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib-object.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  {
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_0_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_NUM_PROPERTIES
};
static GParamSpec* keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_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))
typedef struct _Block2Data Block2Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block3Data Block3Data;
enum  {
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FINISHED_SIGNAL,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FAILED_SIGNAL,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_REMOVE_FINISHED_SIGNAL,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_PROGRESS_CHANGED_SIGNAL,
	KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_NUM_SIGNALS
};
static guint keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_NUM_SIGNALS] = {0};

struct _KeyboardInputMethodPageUbuntuInstallerPrivate {
	KeyboardInputMethodPageAptdProxy* aptd;
	KeyboardInputMethodPageAptdTransactionProxy* proxy;
	gboolean _install_cancellable;
	KeyboardInputMethodPageUbuntuInstallerTransactionMode _transaction_mode;
	gchar* _engine_to_address;
	GeeHashMap* transactions;
};

struct _Block2Data {
	int _ref_count_;
	KeyboardInputMethodPageUbuntuInstaller* self;
	gchar* engine_name;
};

struct _Block3Data {
	int _ref_count_;
	KeyboardInputMethodPageUbuntuInstaller* self;
	gchar* transaction_id;
};

static gint KeyboardInputMethodPageUbuntuInstaller_private_offset;
static gpointer keyboard_input_method_page_ubuntu_installer_parent_class = NULL;
static GOnce keyboard_input_method_page_ubuntu_installer_instance;
static GOnce keyboard_input_method_page_ubuntu_installer_instance = G_ONCE_INIT;

static KeyboardInputMethodPageUbuntuInstaller* __lambda7_ (void);
static KeyboardInputMethodPageUbuntuInstaller* keyboard_input_method_page_ubuntu_installer_new (void);
static KeyboardInputMethodPageUbuntuInstaller* keyboard_input_method_page_ubuntu_installer_construct (GType object_type);
static gpointer ___lambda7__gthread_func (gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void keyboard_input_method_page_ubuntu_installer_set_transaction_mode (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                       KeyboardInputMethodPageUbuntuInstallerTransactionMode value);
static void keyboard_input_method_page_ubuntu_installer_set_engine_to_address (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                        const gchar* value);
static void _vala_array_add1 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void __lambda8_ (Block2Data* _data2_,
                 GObject* obj,
                 GAsyncResult* res);
static void keyboard_input_method_page_ubuntu_installer_run_transaction (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                  const gchar* transaction_id);
static void ___lambda8__gasync_ready_callback (GObject* source_object,
                                        GAsyncResult* res,
                                        gpointer self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda9_ (Block3Data* _data3_);
static void keyboard_input_method_page_ubuntu_installer_on_apt_finshed (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                 const gchar* id,
                                                                 gboolean success);
static void ___lambda9__keyboard_input_method_page_aptd_transaction_proxy_finished (KeyboardInputMethodPageAptdTransactionProxy* _sender,
                                                                             const gchar* transaction_id,
                                                                             gpointer self);
static void __lambda10_ (KeyboardInputMethodPageUbuntuInstaller* self,
                  const gchar* prop,
                  GVariant* val);
static void keyboard_input_method_page_ubuntu_installer_set_install_cancellable (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                          gboolean value);
static void ___lambda10__keyboard_input_method_page_aptd_transaction_proxy_property_changed (KeyboardInputMethodPageAptdTransactionProxy* _sender,
                                                                                      const gchar* property,
                                                                                      GVariant* variant,
                                                                                      gpointer self);
static GObject * keyboard_input_method_page_ubuntu_installer_constructor (GType type,
                                                                   guint n_construct_properties,
                                                                   GObjectConstructParam * construct_properties);
static void keyboard_input_method_page_ubuntu_installer_finalize (GObject * obj);
static GType keyboard_input_method_page_ubuntu_installer_get_type_once (void);
static void _vala_keyboard_input_method_page_ubuntu_installer_get_property (GObject * object,
                                                                     guint property_id,
                                                                     GValue * value,
                                                                     GParamSpec * pspec);
static void _vala_keyboard_input_method_page_ubuntu_installer_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
keyboard_input_method_page_ubuntu_installer_get_instance_private (KeyboardInputMethodPageUbuntuInstaller* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardInputMethodPageUbuntuInstaller_private_offset);
}

static GType
keyboard_input_method_page_ubuntu_installer_transaction_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL, "KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL", "install"}, {KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_REMOVE, "KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_REMOVE", "remove"}, {KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL_MISSING, "KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL_MISSING", "install-missing"}, {0, NULL, NULL}};
	GType keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id;
	keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id = g_enum_register_static ("KeyboardInputMethodPageUbuntuInstallerTransactionMode", values);
	return keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id;
}

GType
keyboard_input_method_page_ubuntu_installer_transaction_mode_get_type (void)
{
	static volatile gsize keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id__once = 0;
	if (g_once_init_enter (&keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id__once)) {
		GType keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id;
		keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id = keyboard_input_method_page_ubuntu_installer_transaction_mode_get_type_once ();
		g_once_init_leave (&keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id__once, keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id);
	}
	return keyboard_input_method_page_ubuntu_installer_transaction_mode_type_id__once;
}

static KeyboardInputMethodPageUbuntuInstaller*
__lambda7_ (void)
{
	KeyboardInputMethodPageUbuntuInstaller* _tmp0_;
	KeyboardInputMethodPageUbuntuInstaller* result;
	_tmp0_ = keyboard_input_method_page_ubuntu_installer_new ();
	result = _tmp0_;
	return result;
}

static gpointer
___lambda7__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda7_ ();
	return result;
}

KeyboardInputMethodPageUbuntuInstaller*
keyboard_input_method_page_ubuntu_installer_get_default (void)
{
	gconstpointer _tmp0_;
	KeyboardInputMethodPageUbuntuInstaller* result;
	_tmp0_ = g_once (&keyboard_input_method_page_ubuntu_installer_instance, ___lambda7__gthread_func, NULL);
	result = (KeyboardInputMethodPageUbuntuInstaller*) _tmp0_;
	return result;
}

static KeyboardInputMethodPageUbuntuInstaller*
keyboard_input_method_page_ubuntu_installer_construct (GType object_type)
{
	KeyboardInputMethodPageUbuntuInstaller * self = NULL;
	self = (KeyboardInputMethodPageUbuntuInstaller*) g_object_new (object_type, NULL);
	return self;
}

static KeyboardInputMethodPageUbuntuInstaller*
keyboard_input_method_page_ubuntu_installer_new (void)
{
	return keyboard_input_method_page_ubuntu_installer_construct (KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER);
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		KeyboardInputMethodPageUbuntuInstaller* self;
		self = _data2_->self;
		_g_free0 (_data2_->engine_name);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
_vala_array_add1 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda8_ (Block2Data* _data2_,
            GObject* obj,
            GAsyncResult* res)
{
	KeyboardInputMethodPageUbuntuInstaller* self;
	GError* _inner_error0_ = NULL;
	self = _data2_->self;
	g_return_if_fail (res != NULL);
	{
		gchar* transaction_id = NULL;
		KeyboardInputMethodPageAptdProxy* _tmp0_;
		gchar* _tmp1_;
		GeeHashMap* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp0_ = self->priv->aptd;
		_tmp1_ = keyboard_input_method_page_aptd_proxy_install_packages_finish (_tmp0_, res, &_inner_error0_);
		transaction_id = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = self->priv->transactions;
		_tmp3_ = g_strconcat ("i-", _data2_->engine_name, NULL);
		_tmp4_ = _tmp3_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, transaction_id, _tmp4_);
		_g_free0 (_tmp4_);
		keyboard_input_method_page_ubuntu_installer_run_transaction (self, transaction_id);
		_g_free0 (transaction_id);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp5_;
		const gchar* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = e;
		_tmp6_ = _tmp5_->message;
		g_warning ("UbuntuInstaller.vala:75: Could not queue downloads: %s", _tmp6_);
		_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
___lambda8__gasync_ready_callback (GObject* source_object,
                                   GAsyncResult* res,
                                   gpointer self)
{
	__lambda8_ (self, source_object, res);
	block2_data_unref (self);
}

void
keyboard_input_method_page_ubuntu_installer_install (KeyboardInputMethodPageUbuntuInstaller* self,
                                                     const gchar* engine_name)
{
	Block2Data* _data2_;
	gchar* _tmp0_;
	gchar** packages = NULL;
	gchar** _tmp1_;
	gint packages_length1;
	gint _packages_size_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	KeyboardInputMethodPageAptdProxy* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine_name != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = g_strdup (engine_name);
	_g_free0 (_data2_->engine_name);
	_data2_->engine_name = _tmp0_;
	keyboard_input_method_page_ubuntu_installer_set_transaction_mode (self, KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL);
	keyboard_input_method_page_ubuntu_installer_set_engine_to_address (self, _data2_->engine_name);
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	packages = _tmp1_;
	packages_length1 = 0;
	_packages_size_ = packages_length1;
	_tmp2_ = self->priv->_engine_to_address;
	_tmp3_ = g_strdup (_tmp2_);
	_vala_array_add1 (&packages, &packages_length1, &_packages_size_, _tmp3_);
	_tmp4_ = packages;
	_tmp4__length1 = packages_length1;
	{
		gchar** packet_collection = NULL;
		gint packet_collection_length1 = 0;
		gint _packet_collection_size_ = 0;
		gint packet_it = 0;
		packet_collection = _tmp4_;
		packet_collection_length1 = _tmp4__length1;
		for (packet_it = 0; packet_it < packet_collection_length1; packet_it = packet_it + 1) {
			gchar* _tmp5_;
			gchar* packet = NULL;
			_tmp5_ = g_strdup (packet_collection[packet_it]);
			packet = _tmp5_;
			{
				const gchar* _tmp6_;
				_tmp6_ = packet;
				g_message ("UbuntuInstaller.vala:66: Packet: %s", _tmp6_);
				_g_free0 (packet);
			}
		}
	}
	_tmp7_ = self->priv->aptd;
	_tmp8_ = packages;
	_tmp8__length1 = packages_length1;
	keyboard_input_method_page_aptd_proxy_install_packages (_tmp7_, _tmp8_, (gint) _tmp8__length1, ___lambda8__gasync_ready_callback, block2_data_ref (_data2_));
	packages = (_vala_array_free (packages, packages_length1, (GDestroyNotify) g_free), NULL);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}

void
keyboard_input_method_page_ubuntu_installer_cancel_install (KeyboardInputMethodPageUbuntuInstaller* self)
{
	gboolean _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_install_cancellable;
	if (_tmp0_) {
		g_warning ("UbuntuInstaller.vala:82: cancel_install");
		{
			KeyboardInputMethodPageAptdTransactionProxy* _tmp1_;
			_tmp1_ = self->priv->proxy;
			keyboard_input_method_page_aptd_transaction_proxy_cancel (_tmp1_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp2_;
			const gchar* _tmp3_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp2_ = e;
			_tmp3_ = _tmp2_->message;
			g_warning ("UbuntuInstaller.vala:86: cannot cancel installation:%s", _tmp3_);
			_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 Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

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

static void
__lambda9_ (Block3Data* _data3_)
{
	KeyboardInputMethodPageUbuntuInstaller* self;
	self = _data3_->self;
	keyboard_input_method_page_ubuntu_installer_on_apt_finshed (self, _data3_->transaction_id, TRUE);
}

static void
___lambda9__keyboard_input_method_page_aptd_transaction_proxy_finished (KeyboardInputMethodPageAptdTransactionProxy* _sender,
                                                                        const gchar* transaction_id,
                                                                        gpointer self)
{
	__lambda9_ (self);
}

static void
__lambda10_ (KeyboardInputMethodPageUbuntuInstaller* self,
             const gchar* prop,
             GVariant* val)
{
	g_return_if_fail (prop != NULL);
	g_return_if_fail (val != NULL);
	if (g_strcmp0 (prop, "Progress") == 0) {
		g_signal_emit (self, keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_PROGRESS_CHANGED_SIGNAL], 0, (gint) g_variant_get_int32 (val));
	}
	if (g_strcmp0 (prop, "Cancellable") == 0) {
		keyboard_input_method_page_ubuntu_installer_set_install_cancellable (self, g_variant_get_boolean (val));
	}
}

static void
___lambda10__keyboard_input_method_page_aptd_transaction_proxy_property_changed (KeyboardInputMethodPageAptdTransactionProxy* _sender,
                                                                                 const gchar* property,
                                                                                 GVariant* variant,
                                                                                 gpointer self)
{
	__lambda10_ ((KeyboardInputMethodPageUbuntuInstaller*) self, property, variant);
}

static void
keyboard_input_method_page_ubuntu_installer_run_transaction (KeyboardInputMethodPageUbuntuInstaller* self,
                                                             const gchar* transaction_id)
{
	Block3Data* _data3_;
	gchar* _tmp0_;
	KeyboardInputMethodPageAptdTransactionProxy* _tmp1_;
	KeyboardInputMethodPageAptdTransactionProxy* _tmp2_;
	KeyboardInputMethodPageAptdTransactionProxy* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (transaction_id != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = g_strdup (transaction_id);
	_g_free0 (_data3_->transaction_id);
	_data3_->transaction_id = _tmp0_;
	_tmp1_ = keyboard_input_method_page_aptd_transaction_proxy_new ();
	_g_object_unref0 (self->priv->proxy);
	self->priv->proxy = _tmp1_;
	_tmp2_ = self->priv->proxy;
	g_signal_connect_data (_tmp2_, "finished", (GCallback) ___lambda9__keyboard_input_method_page_aptd_transaction_proxy_finished, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	_tmp3_ = self->priv->proxy;
	g_signal_connect_object (_tmp3_, "property-changed", (GCallback) ___lambda10__keyboard_input_method_page_aptd_transaction_proxy_property_changed, self, 0);
	{
		KeyboardInputMethodPageAptdTransactionProxy* _tmp4_;
		KeyboardInputMethodPageAptdTransactionProxy* _tmp5_;
		KeyboardInputMethodPageAptdTransactionProxy* _tmp6_;
		_tmp4_ = self->priv->proxy;
		keyboard_input_method_page_aptd_transaction_proxy_connect_to_aptd (_tmp4_, _data3_->transaction_id, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp5_ = self->priv->proxy;
		keyboard_input_method_page_aptd_transaction_proxy_simulate (_tmp5_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = self->priv->proxy;
		keyboard_input_method_page_aptd_transaction_proxy_run (_tmp6_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		keyboard_input_method_page_ubuntu_installer_on_apt_finshed (self, _data3_->transaction_id, FALSE);
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("UbuntuInstaller.vala:114: Could no run transaction: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		block3_data_unref (_data3_);
		_data3_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

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

static void
keyboard_input_method_page_ubuntu_installer_on_apt_finshed (KeyboardInputMethodPageUbuntuInstaller* self,
                                                            const gchar* id,
                                                            gboolean success)
{
	GeeHashMap* _tmp1_;
	gchar* action = NULL;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	gchar* lang = NULL;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gboolean _tmp13_;
	GeeHashMap* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (id != NULL);
	if (!success) {
		GeeHashMap* _tmp0_;
		g_signal_emit (self, keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FAILED_SIGNAL], 0);
		_tmp0_ = self->priv->transactions;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, id, NULL);
		return;
	}
	_tmp1_ = self->priv->transactions;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, id)) {
		return;
	}
	_tmp2_ = self->priv->transactions;
	_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, id);
	action = (gchar*) _tmp3_;
	_tmp4_ = action;
	_tmp5_ = action;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = string_slice (_tmp4_, (glong) 2, (glong) _tmp7_);
	lang = _tmp8_;
	if (success) {
		_tmp9_ = "success";
	} else {
		_tmp9_ = "failed";
	}
	g_message ("UbuntuInstaller.vala:132: ID %s -> %s", id, _tmp9_);
	_tmp10_ = action;
	_tmp11_ = string_slice (_tmp10_, (glong) 0, (glong) 1);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strcmp0 (_tmp12_, "i") == 0;
	_g_free0 (_tmp12_);
	if (_tmp13_) {
		const gchar* _tmp14_;
		_tmp14_ = lang;
		g_signal_emit (self, keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FINISHED_SIGNAL], 0, _tmp14_);
	} else {
		const gchar* _tmp15_;
		_tmp15_ = lang;
		g_signal_emit (self, keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_REMOVE_FINISHED_SIGNAL], 0, _tmp15_);
	}
	_tmp16_ = self->priv->transactions;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp16_, id, NULL);
	_g_free0 (lang);
	_g_free0 (action);
}

gboolean
keyboard_input_method_page_ubuntu_installer_get_install_cancellable (KeyboardInputMethodPageUbuntuInstaller* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_install_cancellable;
	return result;
}

static void
keyboard_input_method_page_ubuntu_installer_set_install_cancellable (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_ubuntu_installer_get_install_cancellable (self);
	if (old_value != value) {
		self->priv->_install_cancellable = value;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY]);
	}
}

KeyboardInputMethodPageUbuntuInstallerTransactionMode
keyboard_input_method_page_ubuntu_installer_get_transaction_mode (KeyboardInputMethodPageUbuntuInstaller* self)
{
	KeyboardInputMethodPageUbuntuInstallerTransactionMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_transaction_mode;
	return result;
}

static void
keyboard_input_method_page_ubuntu_installer_set_transaction_mode (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                  KeyboardInputMethodPageUbuntuInstallerTransactionMode value)
{
	KeyboardInputMethodPageUbuntuInstallerTransactionMode old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_ubuntu_installer_get_transaction_mode (self);
	if (old_value != value) {
		self->priv->_transaction_mode = value;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY]);
	}
}

const gchar*
keyboard_input_method_page_ubuntu_installer_get_engine_to_address (KeyboardInputMethodPageUbuntuInstaller* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_engine_to_address;
	result = _tmp0_;
	return result;
}

static void
keyboard_input_method_page_ubuntu_installer_set_engine_to_address (KeyboardInputMethodPageUbuntuInstaller* self,
                                                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_input_method_page_ubuntu_installer_get_engine_to_address (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_engine_to_address);
		self->priv->_engine_to_address = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY]);
	}
}

static GObject *
keyboard_input_method_page_ubuntu_installer_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KeyboardInputMethodPageUbuntuInstaller * self;
	GeeHashMap* _tmp0_;
	KeyboardInputMethodPageAptdProxy* _tmp1_;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (keyboard_input_method_page_ubuntu_installer_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, KeyboardInputMethodPageUbuntuInstaller);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->transactions);
	self->priv->transactions = _tmp0_;
	_tmp1_ = keyboard_input_method_page_aptd_proxy_new ();
	_g_object_unref0 (self->priv->aptd);
	self->priv->aptd = _tmp1_;
	{
		KeyboardInputMethodPageAptdProxy* _tmp2_;
		_tmp2_ = self->priv->aptd;
		keyboard_input_method_page_aptd_proxy_connect_to_aptd (_tmp2_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_warning ("UbuntuInstaller.vala:55: Could not connect to APT daemon");
	}
	__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 obj;
}

static void
keyboard_input_method_page_ubuntu_installer_class_init (KeyboardInputMethodPageUbuntuInstallerClass * klass,
                                                        gpointer klass_data)
{
	keyboard_input_method_page_ubuntu_installer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardInputMethodPageUbuntuInstaller_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_keyboard_input_method_page_ubuntu_installer_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_keyboard_input_method_page_ubuntu_installer_set_property;
	G_OBJECT_CLASS (klass)->constructor = keyboard_input_method_page_ubuntu_installer_constructor;
	G_OBJECT_CLASS (klass)->finalize = keyboard_input_method_page_ubuntu_installer_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY] = g_param_spec_boolean ("install-cancellable", "install-cancellable", "install-cancellable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY] = g_param_spec_enum ("transaction-mode", "transaction-mode", "transaction-mode", KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TYPE_TRANSACTION_MODE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY, keyboard_input_method_page_ubuntu_installer_properties[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY] = g_param_spec_string ("engine-to-address", "engine-to-address", "engine-to-address", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FINISHED_SIGNAL] = g_signal_new ("install-finished", KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_FAILED_SIGNAL] = g_signal_new ("install-failed", KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_REMOVE_FINISHED_SIGNAL] = g_signal_new ("remove-finished", KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	keyboard_input_method_page_ubuntu_installer_signals[KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_PROGRESS_CHANGED_SIGNAL] = g_signal_new ("progress-changed", KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
keyboard_input_method_page_ubuntu_installer_instance_init (KeyboardInputMethodPageUbuntuInstaller * self,
                                                           gpointer klass)
{
	self->priv = keyboard_input_method_page_ubuntu_installer_get_instance_private (self);
}

static void
keyboard_input_method_page_ubuntu_installer_finalize (GObject * obj)
{
	KeyboardInputMethodPageUbuntuInstaller * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, KeyboardInputMethodPageUbuntuInstaller);
	_g_object_unref0 (self->priv->aptd);
	_g_object_unref0 (self->priv->proxy);
	_g_free0 (self->priv->_engine_to_address);
	_g_object_unref0 (self->priv->transactions);
	G_OBJECT_CLASS (keyboard_input_method_page_ubuntu_installer_parent_class)->finalize (obj);
}

static GType
keyboard_input_method_page_ubuntu_installer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardInputMethodPageUbuntuInstallerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_input_method_page_ubuntu_installer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardInputMethodPageUbuntuInstaller), 0, (GInstanceInitFunc) keyboard_input_method_page_ubuntu_installer_instance_init, NULL };
	GType keyboard_input_method_page_ubuntu_installer_type_id;
	keyboard_input_method_page_ubuntu_installer_type_id = g_type_register_static (G_TYPE_OBJECT, "KeyboardInputMethodPageUbuntuInstaller", &g_define_type_info, 0);
	KeyboardInputMethodPageUbuntuInstaller_private_offset = g_type_add_instance_private (keyboard_input_method_page_ubuntu_installer_type_id, sizeof (KeyboardInputMethodPageUbuntuInstallerPrivate));
	return keyboard_input_method_page_ubuntu_installer_type_id;
}

GType
keyboard_input_method_page_ubuntu_installer_get_type (void)
{
	static volatile gsize keyboard_input_method_page_ubuntu_installer_type_id__once = 0;
	if (g_once_init_enter (&keyboard_input_method_page_ubuntu_installer_type_id__once)) {
		GType keyboard_input_method_page_ubuntu_installer_type_id;
		keyboard_input_method_page_ubuntu_installer_type_id = keyboard_input_method_page_ubuntu_installer_get_type_once ();
		g_once_init_leave (&keyboard_input_method_page_ubuntu_installer_type_id__once, keyboard_input_method_page_ubuntu_installer_type_id);
	}
	return keyboard_input_method_page_ubuntu_installer_type_id__once;
}

static void
_vala_keyboard_input_method_page_ubuntu_installer_get_property (GObject * object,
                                                                guint property_id,
                                                                GValue * value,
                                                                GParamSpec * pspec)
{
	KeyboardInputMethodPageUbuntuInstaller * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, KeyboardInputMethodPageUbuntuInstaller);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY:
		g_value_set_boolean (value, keyboard_input_method_page_ubuntu_installer_get_install_cancellable (self));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY:
		g_value_set_enum (value, keyboard_input_method_page_ubuntu_installer_get_transaction_mode (self));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY:
		g_value_set_string (value, keyboard_input_method_page_ubuntu_installer_get_engine_to_address (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_keyboard_input_method_page_ubuntu_installer_set_property (GObject * object,
                                                                guint property_id,
                                                                const GValue * value,
                                                                GParamSpec * pspec)
{
	KeyboardInputMethodPageUbuntuInstaller * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_INPUT_METHOD_PAGE_TYPE_UBUNTU_INSTALLER, KeyboardInputMethodPageUbuntuInstaller);
	switch (property_id) {
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_INSTALL_CANCELLABLE_PROPERTY:
		keyboard_input_method_page_ubuntu_installer_set_install_cancellable (self, g_value_get_boolean (value));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_TRANSACTION_MODE_PROPERTY:
		keyboard_input_method_page_ubuntu_installer_set_transaction_mode (self, g_value_get_enum (value));
		break;
		case KEYBOARD_INPUT_METHOD_PAGE_UBUNTU_INSTALLER_ENGINE_TO_ADDRESS_PROPERTY:
		keyboard_input_method_page_ubuntu_installer_set_engine_to_address (self, g_value_get_string (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);
}

