/* installed-media.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from installed-media.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <glib-object.h>
#include <libvirt-gconfig/libvirt-gconfig.h>
#include <gio/gio.h>
#include "common.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <osinfo/osinfo.h>
#include "govf.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define BOXES_TYPE_INSTALLER_MEDIA (boxes_installer_media_get_type ())
#define BOXES_INSTALLER_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMedia))
#define BOXES_INSTALLER_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMediaClass))
#define BOXES_IS_INSTALLER_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_INSTALLER_MEDIA))
#define BOXES_IS_INSTALLER_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_INSTALLER_MEDIA))
#define BOXES_INSTALLER_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMediaClass))

typedef struct _BoxesInstallerMedia BoxesInstallerMedia;
typedef struct _BoxesInstallerMediaClass BoxesInstallerMediaClass;
typedef struct _BoxesInstallerMediaPrivate BoxesInstallerMediaPrivate;

#define BOXES_TYPE_VM_CREATOR (boxes_vm_creator_get_type ())
#define BOXES_VM_CREATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_VM_CREATOR, BoxesVMCreator))
#define BOXES_VM_CREATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_VM_CREATOR, BoxesVMCreatorClass))
#define BOXES_IS_VM_CREATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_VM_CREATOR))
#define BOXES_IS_VM_CREATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_VM_CREATOR))
#define BOXES_VM_CREATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_VM_CREATOR, BoxesVMCreatorClass))

typedef struct _BoxesVMCreator BoxesVMCreator;
typedef struct _BoxesVMCreatorClass BoxesVMCreatorClass;

#define BOXES_TYPE_INSTALLED_MEDIA (boxes_installed_media_get_type ())
#define BOXES_INSTALLED_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_INSTALLED_MEDIA, BoxesInstalledMedia))
#define BOXES_INSTALLED_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_INSTALLED_MEDIA, BoxesInstalledMediaClass))
#define BOXES_IS_INSTALLED_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_INSTALLED_MEDIA))
#define BOXES_IS_INSTALLED_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_INSTALLED_MEDIA))
#define BOXES_INSTALLED_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_INSTALLED_MEDIA, BoxesInstalledMediaClass))

typedef struct _BoxesInstalledMedia BoxesInstalledMedia;
typedef struct _BoxesInstalledMediaClass BoxesInstalledMediaClass;
typedef struct _BoxesInstalledMediaPrivate BoxesInstalledMediaPrivate;
enum  {
	BOXES_INSTALLED_MEDIA_0_PROPERTY,
	BOXES_INSTALLED_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION_PROPERTY,
	BOXES_INSTALLED_MEDIA_LIVE_PROPERTY,
	BOXES_INSTALLED_MEDIA_ARCHITECTURE_PROPERTY,
	BOXES_INSTALLED_MEDIA_NUM_PROPERTIES
};
static GParamSpec* boxes_installed_media_properties[BOXES_INSTALLED_MEDIA_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 _BoxesInstalledMediaNewForPathData BoxesInstalledMediaNewForPathData;
typedef struct _BoxesInstalledMediaCopyData BoxesInstalledMediaCopyData;

#define BOXES_TYPE_VM_IMPORTER (boxes_vm_importer_get_type ())
#define BOXES_VM_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_VM_IMPORTER, BoxesVMImporter))
#define BOXES_VM_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_VM_IMPORTER, BoxesVMImporterClass))
#define BOXES_IS_VM_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_VM_IMPORTER))
#define BOXES_IS_VM_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_VM_IMPORTER))
#define BOXES_VM_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_VM_IMPORTER, BoxesVMImporterClass))

typedef struct _BoxesVMImporter BoxesVMImporter;
typedef struct _BoxesVMImporterClass BoxesVMImporterClass;

#define BOXES_TYPE_MEDIA_MANAGER (boxes_media_manager_get_type ())
#define BOXES_MEDIA_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManager))
#define BOXES_MEDIA_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManagerClass))
#define BOXES_IS_MEDIA_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_MEDIA_MANAGER))
#define BOXES_IS_MEDIA_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_MEDIA_MANAGER))
#define BOXES_MEDIA_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_MEDIA_MANAGER, BoxesMediaManagerClass))

typedef struct _BoxesMediaManager BoxesMediaManager;
typedef struct _BoxesMediaManagerClass BoxesMediaManagerClass;
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef struct _BoxesInstalledMediaExtractOvfData BoxesInstalledMediaExtractOvfData;
typedef struct _BoxesInstalledMediaDecompressData BoxesInstalledMediaDecompressData;

struct _BoxesInstallerMedia {
	GObject parent_instance;
	BoxesInstallerMediaPrivate * priv;
	OsinfoOs* os;
	OsinfoResources* resources;
	OsinfoMedia* os_media;
	gchar* label;
	gchar* device_file;
	gchar* mount_point;
	gboolean from_image;
};

struct _BoxesInstallerMediaClass {
	GObjectClass parent_class;
	void (*set_direct_boot_params) (BoxesInstallerMedia* self, GVirConfigDomainOs* os);
	void (*prepare) (BoxesInstallerMedia* self, BoxesActivityProgress* progress, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gboolean (*prepare_finish) (BoxesInstallerMedia* self, GAsyncResult* _res_);
	void (*prepare_for_installation) (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*prepare_for_installation_finish) (BoxesInstallerMedia* self, GAsyncResult* _res_);
	void (*prepare_to_continue_installation) (BoxesInstallerMedia* self, const gchar* vm_name);
	void (*clean_up) (BoxesInstallerMedia* self);
	void (*clean_up_preparation_cache) (BoxesInstallerMedia* self);
	void (*setup_domain_config) (BoxesInstallerMedia* self, GVirConfigDomain* domain);
	void (*setup_post_install_domain_config) (BoxesInstallerMedia* self, GVirConfigDomain* domain);
	BoxesVMCreator* (*get_vm_creator) (BoxesInstallerMedia* self);
	OsinfoDeviceList* (*get_supported_devices) (BoxesInstallerMedia* self);
	guint64 (*get_installed_size) (BoxesInstallerMedia* self);
	gboolean (*get_need_user_input_for_vm_creation) (BoxesInstallerMedia* self);
	gboolean (*get_prefers_q35) (BoxesInstallerMedia* self);
	gboolean (*get_prefers_ich9) (BoxesInstallerMedia* self);
	gboolean (*get_live) (BoxesInstallerMedia* self);
	gboolean (*get_eject_after_install) (BoxesInstallerMedia* self);
	gchar* (*get_architecture) (BoxesInstallerMedia* self);
};

struct _BoxesInstalledMedia {
	BoxesInstallerMedia parent_instance;
	BoxesInstalledMediaPrivate * priv;
};

struct _BoxesInstalledMediaClass {
	BoxesInstallerMediaClass parent_class;
};

struct _BoxesInstalledMediaPrivate {
	gboolean is_gnome;
};

struct _BoxesInstalledMediaNewForPathData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GType object_type;
	BoxesInstalledMedia* self;
	gchar* path;
	gboolean skip_import;
};

struct _BoxesInstalledMediaCopyData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesInstalledMedia* self;
	gchar* destination_path;
	gboolean decompressed;
	gboolean extracted;
	gchar** argv;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gint argv_length1;
	gint _argv_size_;
	gboolean converting;
	gboolean _tmp8_;
	gboolean _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	const gchar* _tmp13_;
	gboolean _tmp14_;
	GFile* file;
	const gchar* _tmp15_;
	GFile* _tmp16_;
	GFile* _tmp17_;
	GError* _inner_error0_;
};

struct _BoxesInstalledMediaExtractOvfData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesInstalledMedia* self;
	gboolean result;
	BoxesMediaManager* media_manager;
	BoxesMediaManager* _tmp0_;
	BoxesMediaManager* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gboolean _tmp6_;
	GFile* ova_file;
	const gchar* _tmp7_;
	GFile* _tmp8_;
	GovfPackage* ovf_package;
	GovfPackage* _tmp9_;
	GovfPackage* _tmp10_;
	const gchar* _tmp11_;
	GPtrArray* disks;
	GovfPackage* _tmp12_;
	GPtrArray* _tmp13_;
	gchar* extracted_path;
	GFile* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GovfPackage* _tmp21_;
	GPtrArray* _tmp22_;
	gconstpointer _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	GError* _inner_error0_;
};

struct _BoxesInstalledMediaDecompressData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesInstalledMedia* self;
	gboolean result;
	BoxesMediaManager* media_manager;
	BoxesMediaManager* _tmp0_;
	BoxesMediaManager* _tmp1_;
	const gchar* _tmp2_;
	GFile* compressed;
	const gchar* _tmp3_;
	GFile* _tmp4_;
	GFileInputStream* input_stream;
	GFile* _tmp5_;
	GFileInputStream* _tmp6_;
	gchar* decompressed_path;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	GFile* decompressed;
	const gchar* _tmp14_;
	GFile* _tmp15_;
	GOutputStream* output_stream;
	GFile* _tmp16_;
	GFileOutputStream* _tmp17_;
	GZlibDecompressor* decompressor;
	GZlibDecompressor* _tmp18_;
	GOutputStream* _tmp19_;
	GZlibDecompressor* _tmp20_;
	GConverterOutputStream* _tmp21_;
	const gchar* _tmp22_;
	guint8* buffer;
	guint8* _tmp23_;
	gint buffer_length1;
	gint _buffer_size_;
	gssize length;
	GFileInputStream* _tmp24_;
	guint8* _tmp25_;
	gint _tmp25__length1;
	gssize written;
	gssize i;
	gboolean _tmp26_;
	gssize _tmp27_;
	GOutputStream* _tmp28_;
	guint8* _tmp29_;
	gint _tmp29__length1;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	GError* _inner_error0_;
};

static gint BoxesInstalledMedia_private_offset;
static gpointer boxes_installed_media_parent_class = NULL;

VALA_EXTERN GType boxes_installer_media_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesInstallerMedia, g_object_unref)
VALA_EXTERN GType boxes_vm_creator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesVMCreator, g_object_unref)
VALA_EXTERN GType boxes_installed_media_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesInstalledMedia, g_object_unref)
VALA_EXTERN void boxes_installer_media_setup_domain_config (BoxesInstallerMedia* self,
                                                GVirConfigDomain* domain);
VALA_EXTERN BoxesVMCreator* boxes_installer_media_get_vm_creator (BoxesInstallerMedia* self);
VALA_EXTERN gboolean boxes_installer_media_get_need_user_input_for_vm_creation (BoxesInstallerMedia* self);
VALA_EXTERN gboolean boxes_installer_media_get_live (BoxesInstallerMedia* self);
VALA_EXTERN gchar* boxes_installer_media_get_architecture (BoxesInstallerMedia* self);
VALA_EXTERN BoxesInstalledMedia* boxes_installed_media_new (const gchar* path,
                                                gboolean skip_import);
VALA_EXTERN BoxesInstalledMedia* boxes_installed_media_construct (GType object_type,
                                                      const gchar* path,
                                                      gboolean skip_import);
VALA_EXTERN BoxesInstallerMedia* boxes_installer_media_new (void);
VALA_EXTERN BoxesInstallerMedia* boxes_installer_media_construct (GType object_type);
VALA_EXTERN void boxes_installer_media_set_skip_import (BoxesInstallerMedia* self,
                                            gboolean value);
VALA_EXTERN OsinfoResources* boxes_os_database_get_default_resources (void);
VALA_EXTERN void boxes_installer_media_label_setup (BoxesInstallerMedia* self,
                                        const gchar* label);
static void boxes_installed_media_construct_for_path_data_free (gpointer _data);
VALA_EXTERN void boxes_installed_media_new_for_path (const gchar* path,
                                         gboolean skip_import,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN BoxesInstalledMedia* boxes_installed_media_new_for_path_finish (GAsyncResult* _res_);
VALA_EXTERN void boxes_installed_media_construct_for_path (GType object_type,
                                               const gchar* path,
                                               gboolean skip_import,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN BoxesInstalledMedia* boxes_installed_media_construct_for_path_finish (GAsyncResult* _res_);
static gboolean boxes_installed_media_construct_for_path_co (BoxesInstalledMediaNewForPathData* _data_);
static void boxes_installed_media_copy_data_free (gpointer _data);
VALA_EXTERN void boxes_installed_media_copy (BoxesInstalledMedia* self,
                                 const gchar* destination_path,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN void boxes_installed_media_copy_finish (BoxesInstalledMedia* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static gboolean boxes_installed_media_copy_co (BoxesInstalledMediaCopyData* _data_);
static void boxes_installed_media_decompress (BoxesInstalledMedia* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static gboolean boxes_installed_media_decompress_finish (BoxesInstalledMedia* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void boxes_installed_media_copy_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void boxes_installed_media_extract_ovf (BoxesInstalledMedia* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
static gboolean boxes_installed_media_extract_ovf_finish (BoxesInstalledMedia* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
VALA_EXTERN gboolean boxes_installer_media_get_skip_import (BoxesInstallerMedia* self);
static void boxes_installed_media_real_setup_domain_config (BoxesInstallerMedia* base,
                                                     GVirConfigDomain* domain);
VALA_EXTERN void boxes_installer_media_add_cd_config (BoxesInstallerMedia* self,
                                          GVirConfigDomain* domain,
                                          GVirConfigDomainDiskType type,
                                          const gchar* iso_path,
                                          const gchar* device_name,
                                          gboolean mandatory);
static BoxesVMCreator* boxes_installed_media_real_get_vm_creator (BoxesInstallerMedia* base);
VALA_EXTERN BoxesVMImporter* boxes_vm_importer_new (BoxesInstalledMedia* source_media);
VALA_EXTERN BoxesVMImporter* boxes_vm_importer_construct (GType object_type,
                                              BoxesInstalledMedia* source_media);
VALA_EXTERN GType boxes_vm_importer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesVMImporter, g_object_unref)
static void boxes_installed_media_extract_ovf_data_free (gpointer _data);
static gboolean boxes_installed_media_extract_ovf_co (BoxesInstalledMediaExtractOvfData* _data_);
VALA_EXTERN GType boxes_media_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesMediaManager, g_object_unref)
VALA_EXTERN BoxesMediaManager* boxes_media_manager_get_default (void);
VALA_EXTERN gboolean boxes_media_manager_media_matches_content_type (BoxesMediaManager* self,
                                                         const gchar* path,
                                                         gchar** supported_content_types,
                                                         gint supported_content_types_length1);
static void boxes_installed_media_extract_ovf_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_);
static void boxes_installed_media_decompress_data_free (gpointer _data);
static gboolean boxes_installed_media_decompress_co (BoxesInstalledMediaDecompressData* _data_);
VALA_EXTERN gboolean boxes_media_manager_path_is_compressed (BoxesMediaManager* self,
                                                 const gchar* path);
static void boxes_installed_media_decompress_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
static void boxes_installed_media_finalize (GObject * obj);
static GType boxes_installed_media_get_type_once (void);
static void _vala_boxes_installed_media_get_property (GObject * object,
                                               guint property_id,
                                               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);

const gchar* BOXES_INSTALLED_MEDIA_supported_architectures[6] = {"i686", "i586", "i486", "i386", "x86_64", "amd64"};

static inline gpointer
boxes_installed_media_get_instance_private (BoxesInstalledMedia* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesInstalledMedia_private_offset);
}

BoxesInstalledMedia*
boxes_installed_media_construct (GType object_type,
                                 const gchar* path,
                                 gboolean skip_import)
{
	BoxesInstalledMedia * self = NULL;
	OsinfoResources* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (path != NULL, NULL);
	self = (BoxesInstalledMedia*) boxes_installer_media_construct (object_type);
	boxes_installer_media_set_skip_import ((BoxesInstallerMedia*) self, skip_import);
	if (skip_import) {
		g_debug ("installed-media.vala:36: '%s' doesn't need to be imported", path);
	}
	_tmp0_ = boxes_os_database_get_default_resources ();
	_g_object_unref0 (((BoxesInstallerMedia*) self)->resources);
	((BoxesInstallerMedia*) self)->resources = _tmp0_;
	_tmp1_ = g_strdup (path);
	_g_free0 (((BoxesInstallerMedia*) self)->device_file);
	((BoxesInstallerMedia*) self)->device_file = _tmp1_;
	((BoxesInstallerMedia*) self)->from_image = TRUE;
	boxes_installer_media_label_setup ((BoxesInstallerMedia*) self, NULL);
	return self;
}

BoxesInstalledMedia*
boxes_installed_media_new (const gchar* path,
                           gboolean skip_import)
{
	return boxes_installed_media_construct (BOXES_TYPE_INSTALLED_MEDIA, path, skip_import);
}

static void
boxes_installed_media_construct_for_path_data_free (gpointer _data)
{
	BoxesInstalledMediaNewForPathData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstalledMediaNewForPathData, _data_);
}

void
boxes_installed_media_construct_for_path (GType object_type,
                                          const gchar* path,
                                          gboolean skip_import,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	BoxesInstalledMediaNewForPathData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (path != NULL);
	_data_ = g_slice_new0 (BoxesInstalledMediaNewForPathData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_installed_media_construct_for_path_data_free);
	_data_->object_type = object_type;
	_tmp0_ = g_strdup (path);
	_g_free0 (_data_->path);
	_data_->path = _tmp0_;
	_data_->skip_import = skip_import;
	boxes_installed_media_construct_for_path_co (_data_);
}

BoxesInstalledMedia*
boxes_installed_media_construct_for_path_finish (GAsyncResult* _res_)
{
	BoxesInstalledMedia* result;
	BoxesInstalledMediaNewForPathData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->self;
	_data_->self = NULL;
	return result;
}

static gboolean
boxes_installed_media_construct_for_path_co (BoxesInstalledMediaNewForPathData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->self = (BoxesInstalledMedia*) boxes_installed_media_construct (_data_->object_type, _data_->path, _data_->skip_import);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
boxes_installed_media_new_for_path (const gchar* path,
                                    gboolean skip_import,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	boxes_installed_media_construct_for_path (BOXES_TYPE_INSTALLED_MEDIA, path, skip_import, _callback_, _user_data_);
}

BoxesInstalledMedia*
boxes_installed_media_new_for_path_finish (GAsyncResult* _res_)
{
	return boxes_installed_media_construct_for_path_finish (_res_);
}

static void
boxes_installed_media_copy_data_free (gpointer _data)
{
	BoxesInstalledMediaCopyData* _data_;
	_data_ = _data;
	_g_free0 (_data_->destination_path);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstalledMediaCopyData, _data_);
}

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

void
boxes_installed_media_copy (BoxesInstalledMedia* self,
                            const gchar* destination_path,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	BoxesInstalledMediaCopyData* _data_;
	BoxesInstalledMedia* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (destination_path != NULL);
	_data_ = g_slice_new0 (BoxesInstalledMediaCopyData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_installed_media_copy_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (destination_path);
	_g_free0 (_data_->destination_path);
	_data_->destination_path = _tmp1_;
	boxes_installed_media_copy_co (_data_);
}

void
boxes_installed_media_copy_finish (BoxesInstalledMedia* self,
                                   GAsyncResult* _res_,
                                   GError** error)
{
	BoxesInstalledMediaCopyData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
boxes_installed_media_copy_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	BoxesInstalledMediaCopyData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installed_media_copy_co (_data_);
}

static gboolean
boxes_installed_media_copy_co (BoxesInstalledMediaCopyData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	boxes_installed_media_decompress (_data_->self, boxes_installed_media_copy_ready, _data_);
	return FALSE;
	_state_1:
	_data_->decompressed = boxes_installed_media_decompress_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_state_ = 2;
	boxes_installed_media_extract_ovf (_data_->self, boxes_installed_media_copy_ready, _data_);
	return FALSE;
	_state_2:
	_data_->extracted = boxes_installed_media_extract_ovf_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp0_ = g_strdup ("qemu-img");
	_data_->_tmp1_ = g_strdup ("convert");
	_data_->_tmp2_ = g_strdup ("-O");
	_data_->_tmp3_ = g_strdup ("qcow2");
	_data_->_tmp4_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_tmp5_ = g_strdup (_data_->_tmp4_);
	_data_->_tmp6_ = g_strdup (_data_->destination_path);
	_data_->_tmp7_ = g_new0 (gchar*, 6 + 1);
	_data_->_tmp7_[0] = _data_->_tmp0_;
	_data_->_tmp7_[1] = _data_->_tmp1_;
	_data_->_tmp7_[2] = _data_->_tmp2_;
	_data_->_tmp7_[3] = _data_->_tmp3_;
	_data_->_tmp7_[4] = _data_->_tmp5_;
	_data_->_tmp7_[5] = _data_->_tmp6_;
	_data_->argv = _data_->_tmp7_;
	_data_->argv_length1 = 6;
	_data_->_argv_size_ = _data_->argv_length1;
	_data_->_tmp8_ = boxes_installer_media_get_skip_import ((BoxesInstallerMedia*) _data_->self);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->converting = !_data_->_tmp9_;
	if (_data_->converting) {
		_data_->_tmp10_ = " while converting it to 'qcow2' format";
	} else {
		_data_->_tmp10_ = "";
	}
	_data_->_tmp11_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	g_debug ("installed-media.vala:58: Copying '%s' to '%s'%s.", _data_->_tmp11_, _data_->destination_path, _data_->_tmp10_);
	_data_->_tmp12_ = _data_->argv;
	_data_->_tmp12__length1 = _data_->argv_length1;
	_data_->_state_ = 3;
	boxes_exec (_data_->_tmp12_, (gint) _data_->_tmp12__length1, NULL, boxes_installed_media_copy_ready, _data_);
	return FALSE;
	_state_3:
	boxes_exec_finish (_data_->_res_, NULL, NULL, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_data_->argv = (_vala_array_free (_data_->argv, _data_->argv_length1, (GDestroyNotify) g_free), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp13_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	g_debug ("installed-media.vala:63: Finished copying '%s' to '%s'", _data_->_tmp13_, _data_->destination_path);
	if (_data_->decompressed) {
		_data_->_tmp14_ = TRUE;
	} else {
		_data_->_tmp14_ = _data_->extracted;
	}
	if (_data_->_tmp14_) {
		_data_->_tmp15_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
		_data_->_tmp16_ = g_file_new_for_path (_data_->_tmp15_);
		_data_->file = _data_->_tmp16_;
		_data_->_tmp17_ = _data_->file;
		boxes_delete_file (_data_->_tmp17_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->file);
			_data_->argv = (_vala_array_free (_data_->argv, _data_->argv_length1, (GDestroyNotify) g_free), NULL);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->file);
	}
	_data_->argv = (_vala_array_free (_data_->argv, _data_->argv_length1, (GDestroyNotify) g_free), NULL);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
boxes_installed_media_real_setup_domain_config (BoxesInstallerMedia* base,
                                                GVirConfigDomain* domain)
{
	BoxesInstalledMedia * self;
	GVirConfigDomainDiskType _tmp0_ = 0;
	self = (BoxesInstalledMedia*) base;
	g_return_if_fail (domain != NULL);
	if (((BoxesInstallerMedia*) self)->from_image) {
		_tmp0_ = GVIR_CONFIG_DOMAIN_DISK_FILE;
	} else {
		_tmp0_ = GVIR_CONFIG_DOMAIN_DISK_BLOCK;
	}
	boxes_installer_media_add_cd_config ((BoxesInstallerMedia*) self, domain, _tmp0_, NULL, "hdc", FALSE);
}

static BoxesVMCreator*
boxes_installed_media_real_get_vm_creator (BoxesInstallerMedia* base)
{
	BoxesInstalledMedia * self;
	BoxesVMImporter* _tmp0_;
	BoxesVMCreator* result;
	self = (BoxesInstalledMedia*) base;
	_tmp0_ = boxes_vm_importer_new (self);
	result = (BoxesVMCreator*) _tmp0_;
	return result;
}

static void
boxes_installed_media_extract_ovf_data_free (gpointer _data)
{
	BoxesInstalledMediaExtractOvfData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstalledMediaExtractOvfData, _data_);
}

static void
boxes_installed_media_extract_ovf (BoxesInstalledMedia* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	BoxesInstalledMediaExtractOvfData* _data_;
	BoxesInstalledMedia* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesInstalledMediaExtractOvfData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_installed_media_extract_ovf_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	boxes_installed_media_extract_ovf_co (_data_);
}

static gboolean
boxes_installed_media_extract_ovf_finish (BoxesInstalledMedia* self,
                                          GAsyncResult* _res_,
                                          GError** error)
{
	gboolean result;
	BoxesInstalledMediaExtractOvfData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
boxes_installed_media_extract_ovf_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_)
{
	BoxesInstalledMediaExtractOvfData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installed_media_extract_ovf_co (_data_);
}

static gboolean
boxes_installed_media_extract_ovf_co (BoxesInstalledMediaExtractOvfData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = boxes_media_manager_get_default ();
	_data_->media_manager = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->media_manager;
	_data_->_tmp2_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_tmp3_ = g_strdup ("application/ovf");
	_data_->_tmp4_ = g_new0 (gchar*, 1 + 1);
	_data_->_tmp4_[0] = _data_->_tmp3_;
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp5__length1 = 1;
	_data_->_tmp6_ = !boxes_media_manager_media_matches_content_type (_data_->_tmp1_, _data_->_tmp2_, _data_->_tmp5_, (gint) 1);
	_data_->_tmp5_ = (_vala_array_free (_data_->_tmp5_, _data_->_tmp5__length1, (GDestroyNotify) g_free), NULL);
	if (_data_->_tmp6_) {
		_data_->result = FALSE;
		_g_object_unref0 (_data_->media_manager);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_tmp8_ = g_file_new_for_path (_data_->_tmp7_);
	_data_->ova_file = _data_->_tmp8_;
	_data_->_tmp9_ = govf_package_new ();
	_data_->ovf_package = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->ovf_package;
	_data_->_tmp11_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_state_ = 1;
	govf_package_load_from_ova_file (_data_->_tmp10_, _data_->_tmp11_, NULL, boxes_installed_media_extract_ovf_ready, _data_);
	return FALSE;
	_state_1:
	govf_package_load_from_ova_file_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->ovf_package);
		_g_object_unref0 (_data_->ova_file);
		_g_object_unref0 (_data_->media_manager);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp12_ = _data_->ovf_package;
	_data_->_tmp13_ = govf_package_get_disks (_data_->_tmp12_);
	_data_->disks = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->ova_file;
	_data_->_tmp15_ = g_file_get_basename (_data_->_tmp14_);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = g_strconcat (_data_->_tmp16_, ".vmdk", NULL);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = boxes_get_user_pkgcache (_data_->_tmp18_);
	_data_->_tmp20_ = _data_->_tmp19_;
	_g_free0 (_data_->_tmp18_);
	_g_free0 (_data_->_tmp16_);
	_data_->extracted_path = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->ovf_package;
	_data_->_tmp22_ = _data_->disks;
	_data_->_tmp23_ = g_ptr_array_index (_data_->_tmp22_, (guint) 0);
	_data_->_tmp24_ = _data_->extracted_path;
	_data_->_state_ = 2;
	govf_package_extract_disk (_data_->_tmp21_, (GovfDisk*) _data_->_tmp23_, _data_->_tmp24_, NULL, boxes_installed_media_extract_ovf_ready, _data_);
	return FALSE;
	_state_2:
	govf_package_extract_disk_finish (_data_->_tmp21_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_free0 (_data_->extracted_path);
		_g_ptr_array_unref0 (_data_->disks);
		_g_object_unref0 (_data_->ovf_package);
		_g_object_unref0 (_data_->ova_file);
		_g_object_unref0 (_data_->media_manager);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp25_ = _data_->extracted_path;
	_data_->_tmp26_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	g_debug ("installed-media.vala:93: Extracted '%s' from '%s'.", _data_->_tmp25_, _data_->_tmp26_);
	_data_->_tmp27_ = _data_->extracted_path;
	_data_->_tmp28_ = g_strdup (_data_->_tmp27_);
	_g_free0 (((BoxesInstallerMedia*) _data_->self)->device_file);
	((BoxesInstallerMedia*) _data_->self)->device_file = _data_->_tmp28_;
	_data_->result = TRUE;
	_g_free0 (_data_->extracted_path);
	_g_ptr_array_unref0 (_data_->disks);
	_g_object_unref0 (_data_->ovf_package);
	_g_object_unref0 (_data_->ova_file);
	_g_object_unref0 (_data_->media_manager);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
boxes_installed_media_decompress_data_free (gpointer _data)
{
	BoxesInstalledMediaDecompressData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstalledMediaDecompressData, _data_);
}

static void
boxes_installed_media_decompress (BoxesInstalledMedia* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	BoxesInstalledMediaDecompressData* _data_;
	BoxesInstalledMedia* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BoxesInstalledMediaDecompressData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_installed_media_decompress_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	boxes_installed_media_decompress_co (_data_);
}

static gboolean
boxes_installed_media_decompress_finish (BoxesInstalledMedia* self,
                                         GAsyncResult* _res_,
                                         GError** error)
{
	gboolean result;
	BoxesInstalledMediaDecompressData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
boxes_installed_media_decompress_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	BoxesInstalledMediaDecompressData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installed_media_decompress_co (_data_);
}

static gboolean
boxes_installed_media_decompress_co (BoxesInstalledMediaDecompressData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = boxes_media_manager_get_default ();
	_data_->media_manager = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->media_manager;
	_data_->_tmp2_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	if (!boxes_media_manager_path_is_compressed (_data_->_tmp1_, _data_->_tmp2_)) {
		_data_->result = FALSE;
		_g_object_unref0 (_data_->media_manager);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_tmp4_ = g_file_new_for_path (_data_->_tmp3_);
	_data_->compressed = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->compressed;
	_data_->_state_ = 1;
	g_file_read_async (_data_->_tmp5_, G_PRIORITY_DEFAULT, NULL, boxes_installed_media_decompress_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp6_ = g_file_read_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
	_data_->input_stream = _data_->_tmp6_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->compressed);
		_g_object_unref0 (_data_->media_manager);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	_data_->_tmp8_ = g_path_get_basename (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = g_strconcat (_data_->_tmp9_, ".boxes", NULL);
	_data_->_tmp11_ = _data_->_tmp10_;
	_g_free0 (_data_->_tmp9_);
	_data_->decompressed_path = _data_->_tmp11_;
	_data_->_tmp12_ = _data_->decompressed_path;
	_data_->_tmp13_ = boxes_get_user_pkgcache (_data_->_tmp12_);
	_g_free0 (_data_->decompressed_path);
	_data_->decompressed_path = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->decompressed_path;
	_data_->_tmp15_ = g_file_new_for_path (_data_->_tmp14_);
	_data_->decompressed = _data_->_tmp15_;
	_data_->_tmp16_ = _data_->decompressed;
	_data_->_state_ = 2;
	g_file_replace_async (_data_->_tmp16_, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, G_PRIORITY_DEFAULT, NULL, boxes_installed_media_decompress_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp17_ = g_file_replace_finish (_data_->_tmp16_, _data_->_res_, &_data_->_inner_error0_);
	_data_->output_stream = (GOutputStream*) _data_->_tmp17_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->decompressed);
		_g_free0 (_data_->decompressed_path);
		_g_object_unref0 (_data_->input_stream);
		_g_object_unref0 (_data_->compressed);
		_g_object_unref0 (_data_->media_manager);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp18_ = g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP);
	_data_->decompressor = _data_->_tmp18_;
	_data_->_tmp19_ = _data_->output_stream;
	_data_->_tmp20_ = _data_->decompressor;
	_data_->_tmp21_ = (GConverterOutputStream*) g_converter_output_stream_new (_data_->_tmp19_, (GConverter*) _data_->_tmp20_);
	_g_object_unref0 (_data_->output_stream);
	_data_->output_stream = (GOutputStream*) _data_->_tmp21_;
	_data_->_tmp22_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	g_debug ("installed-media.vala:117: Decompressing '%s'..", _data_->_tmp22_);
	_data_->_tmp23_ = g_new0 (guint8, 1048576);
	_data_->buffer = _data_->_tmp23_;
	_data_->buffer_length1 = 1048576;
	_data_->_buffer_size_ = _data_->buffer_length1;
	while (TRUE) {
		_data_->_tmp24_ = _data_->input_stream;
		_data_->_tmp25_ = _data_->buffer;
		_data_->_tmp25__length1 = _data_->buffer_length1;
		_data_->_state_ = 3;
		g_input_stream_read_async ((GInputStream*) _data_->_tmp24_, _data_->_tmp25_, (gsize) _data_->_tmp25__length1, G_PRIORITY_DEFAULT, NULL, boxes_installed_media_decompress_ready, _data_);
		return FALSE;
		_state_3:
		_data_->length = g_input_stream_read_finish ((GInputStream*) _data_->_tmp24_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_data_->buffer = (g_free (_data_->buffer), NULL);
			_g_object_unref0 (_data_->decompressor);
			_g_object_unref0 (_data_->output_stream);
			_g_object_unref0 (_data_->decompressed);
			_g_free0 (_data_->decompressed_path);
			_g_object_unref0 (_data_->input_stream);
			_g_object_unref0 (_data_->compressed);
			_g_object_unref0 (_data_->media_manager);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		if (_data_->length <= ((gssize) 0)) {
			break;
		}
		_data_->written = (gssize) 0;
		_data_->i = (gssize) 0;
		{
			_data_->_tmp26_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp26_) {
					if (!(_data_->i < _data_->length)) {
						break;
					}
				}
				_data_->_tmp26_ = FALSE;
				_data_->_tmp28_ = _data_->output_stream;
				_data_->_tmp29_ = _data_->buffer;
				_data_->_tmp29__length1 = _data_->buffer_length1;
				_data_->_tmp27_ = g_output_stream_write (_data_->_tmp28_, _data_->_tmp29_ + ((gint) _data_->i), (gsize) (((gint) _data_->length) - ((gint) _data_->i)), NULL, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_data_->buffer = (g_free (_data_->buffer), NULL);
					_g_object_unref0 (_data_->decompressor);
					_g_object_unref0 (_data_->output_stream);
					_g_object_unref0 (_data_->decompressed);
					_g_free0 (_data_->decompressed_path);
					_g_object_unref0 (_data_->input_stream);
					_g_object_unref0 (_data_->compressed);
					_g_object_unref0 (_data_->media_manager);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->written = _data_->_tmp27_;
				_data_->i += _data_->written;
			}
		}
	}
	_data_->_tmp30_ = ((BoxesInstallerMedia*) _data_->self)->device_file;
	g_debug ("installed-media.vala:130: Decompressed '%s'.", _data_->_tmp30_);
	_data_->_tmp31_ = _data_->decompressed_path;
	_data_->_tmp32_ = g_strdup (_data_->_tmp31_);
	_g_free0 (((BoxesInstallerMedia*) _data_->self)->device_file);
	((BoxesInstallerMedia*) _data_->self)->device_file = _data_->_tmp32_;
	_data_->result = TRUE;
	_data_->buffer = (g_free (_data_->buffer), NULL);
	_g_object_unref0 (_data_->decompressor);
	_g_object_unref0 (_data_->output_stream);
	_g_object_unref0 (_data_->decompressed);
	_g_free0 (_data_->decompressed_path);
	_g_object_unref0 (_data_->input_stream);
	_g_object_unref0 (_data_->compressed);
	_g_object_unref0 (_data_->media_manager);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
boxes_installed_media_real_get_need_user_input_for_vm_creation (BoxesInstallerMedia* base)
{
	gboolean result;
	BoxesInstalledMedia* self;
	self = (BoxesInstalledMedia*) base;
	result = FALSE;
	return result;
}

static gboolean
boxes_installed_media_real_get_live (BoxesInstallerMedia* base)
{
	gboolean result;
	BoxesInstalledMedia* self;
	self = (BoxesInstalledMedia*) base;
	result = FALSE;
	return result;
}

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 gchar*
boxes_installed_media_real_get_architecture (BoxesInstallerMedia* base)
{
	gchar* result;
	BoxesInstalledMedia* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	self = (BoxesInstalledMedia*) base;
	_tmp2_ = ((BoxesInstallerMedia*) self)->device_file;
	if (string_contains (_tmp2_, "amd64")) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = ((BoxesInstallerMedia*) self)->device_file;
		_tmp1_ = string_contains (_tmp3_, "x86_64");
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->is_gnome;
	}
	if (_tmp0_) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("x86_64");
		result = _tmp4_;
		return result;
	} else {
		const gchar* _tmp9_;
		{
			const gchar** arch_collection = NULL;
			gint arch_collection_length1 = 0;
			gint _arch_collection_size_ = 0;
			gint arch_it = 0;
			arch_collection = BOXES_INSTALLED_MEDIA_supported_architectures;
			arch_collection_length1 = G_N_ELEMENTS (BOXES_INSTALLED_MEDIA_supported_architectures);
			for (arch_it = 0; arch_it < arch_collection_length1; arch_it = arch_it + 1) {
				const gchar* arch = NULL;
				arch = arch_collection[arch_it];
				{
					const gchar* _tmp5_;
					const gchar* _tmp6_;
					_tmp5_ = ((BoxesInstallerMedia*) self)->device_file;
					_tmp6_ = arch;
					if (string_contains (_tmp5_, _tmp6_)) {
						const gchar* _tmp7_;
						gchar* _tmp8_;
						_tmp7_ = arch;
						_tmp8_ = g_strdup (_tmp7_);
						result = _tmp8_;
						return result;
					}
				}
			}
		}
		_tmp9_ = ((BoxesInstallerMedia*) self)->device_file;
		g_debug ("installed-media.vala:26: Failed to guess architecture for media '%s'.", _tmp9_);
		result = NULL;
		return result;
	}
}

static void
boxes_installed_media_class_init (BoxesInstalledMediaClass * klass,
                                  gpointer klass_data)
{
	boxes_installed_media_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesInstalledMedia_private_offset);
	((BoxesInstallerMediaClass *) klass)->setup_domain_config = (void (*) (BoxesInstallerMedia*, GVirConfigDomain*)) boxes_installed_media_real_setup_domain_config;
	((BoxesInstallerMediaClass *) klass)->get_vm_creator = (BoxesVMCreator* (*) (BoxesInstallerMedia*)) boxes_installed_media_real_get_vm_creator;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_need_user_input_for_vm_creation = (gboolean (*) (BoxesInstallerMedia*)) boxes_installed_media_real_get_need_user_input_for_vm_creation;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_live = (gboolean (*) (BoxesInstallerMedia*)) boxes_installed_media_real_get_live;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_architecture = (gchar* (*) (BoxesInstallerMedia*)) boxes_installed_media_real_get_architecture;
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_installed_media_get_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_installed_media_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLED_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION_PROPERTY, boxes_installed_media_properties[BOXES_INSTALLED_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION_PROPERTY] = g_param_spec_boolean ("need-user-input-for-vm-creation", "need-user-input-for-vm-creation", "need-user-input-for-vm-creation", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLED_MEDIA_LIVE_PROPERTY, boxes_installed_media_properties[BOXES_INSTALLED_MEDIA_LIVE_PROPERTY] = g_param_spec_boolean ("live", "live", "live", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLED_MEDIA_ARCHITECTURE_PROPERTY, boxes_installed_media_properties[BOXES_INSTALLED_MEDIA_ARCHITECTURE_PROPERTY] = g_param_spec_string ("architecture", "architecture", "architecture", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
boxes_installed_media_instance_init (BoxesInstalledMedia * self,
                                     gpointer klass)
{
	self->priv = boxes_installed_media_get_instance_private (self);
}

static void
boxes_installed_media_finalize (GObject * obj)
{
	BoxesInstalledMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_INSTALLED_MEDIA, BoxesInstalledMedia);
	G_OBJECT_CLASS (boxes_installed_media_parent_class)->finalize (obj);
}

static GType
boxes_installed_media_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesInstalledMediaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_installed_media_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesInstalledMedia), 0, (GInstanceInitFunc) boxes_installed_media_instance_init, NULL };
	GType boxes_installed_media_type_id;
	boxes_installed_media_type_id = g_type_register_static (BOXES_TYPE_INSTALLER_MEDIA, "BoxesInstalledMedia", &g_define_type_info, 0);
	BoxesInstalledMedia_private_offset = g_type_add_instance_private (boxes_installed_media_type_id, sizeof (BoxesInstalledMediaPrivate));
	return boxes_installed_media_type_id;
}

GType
boxes_installed_media_get_type (void)
{
	static volatile gsize boxes_installed_media_type_id__once = 0;
	if (g_once_init_enter (&boxes_installed_media_type_id__once)) {
		GType boxes_installed_media_type_id;
		boxes_installed_media_type_id = boxes_installed_media_get_type_once ();
		g_once_init_leave (&boxes_installed_media_type_id__once, boxes_installed_media_type_id);
	}
	return boxes_installed_media_type_id__once;
}

static void
_vala_boxes_installed_media_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	BoxesInstalledMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_INSTALLED_MEDIA, BoxesInstalledMedia);
	switch (property_id) {
		case BOXES_INSTALLED_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION_PROPERTY:
		g_value_set_boolean (value, boxes_installer_media_get_need_user_input_for_vm_creation ((BoxesInstallerMedia*) self));
		break;
		case BOXES_INSTALLED_MEDIA_LIVE_PROPERTY:
		g_value_set_boolean (value, boxes_installer_media_get_live ((BoxesInstallerMedia*) self));
		break;
		case BOXES_INSTALLED_MEDIA_ARCHITECTURE_PROPERTY:
		g_value_take_string (value, boxes_installer_media_get_architecture ((BoxesInstallerMedia*) self));
		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);
}

