/* installer-media.c generated by valac 0.17.5.2-8558, the Vala compiler
 * generated from installer-media.vala, do not modify */

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

#include <glib.h>
#include <glib-object.h>
#include <libvirt-gconfig/libvirt-gconfig.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <libcommon.h>
#include <osinfo/osinfo.h>
#include <gudev/gudev.h>
#include <glib/gi18n-lib.h>


#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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#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;
typedef struct _BoxesInstallerMediaCreateForPathData BoxesInstallerMediaCreateForPathData;

#define BOXES_TYPE_OS_DATABASE (boxes_os_database_get_type ())
#define BOXES_OS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_OS_DATABASE, BoxesOSDatabase))
#define BOXES_OS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_OS_DATABASE, BoxesOSDatabaseClass))
#define BOXES_IS_OS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_OS_DATABASE))
#define BOXES_IS_OS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_OS_DATABASE))
#define BOXES_OS_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_OS_DATABASE, BoxesOSDatabaseClass))

typedef struct _BoxesOSDatabase BoxesOSDatabase;
typedef struct _BoxesOSDatabaseClass BoxesOSDatabaseClass;
typedef struct _BoxesInstallerMediaSetupForPathData BoxesInstallerMediaSetupForPathData;
typedef struct _BoxesInstallerMediaPrepareForInstallationData BoxesInstallerMediaPrepareForInstallationData;
#define __g_list_free__boxes_pair_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__boxes_pair_unref0_ (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _BoxesInstallerMediaGetDeviceFromPathData BoxesInstallerMediaGetDeviceFromPathData;

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_for_installation) (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*prepare_for_installation_finish) (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error);
	void (*setup_domain_config) (BoxesInstallerMedia* self, GVirConfigDomain* domain);
	void (*populate_setup_vbox) (BoxesInstallerMedia* self, GtkVBox* setup_vbox);
	GList* (*get_vm_properties) (BoxesInstallerMedia* self);
	guint64 (*get_installed_size) (BoxesInstallerMedia* self);
	gboolean (*get_need_user_input_for_vm_creation) (BoxesInstallerMedia* self);
	gboolean (*get_user_data_for_vm_creation_available) (BoxesInstallerMedia* self);
	gboolean (*get_supports_virtio_disk) (BoxesInstallerMedia* self);
};

struct _BoxesInstallerMediaCreateForPathData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	gchar* path;
	BoxesMediaManager* media_manager;
	GCancellable* cancellable;
	BoxesInstallerMedia* result;
	BoxesInstallerMedia* _tmp0_;
	BoxesInstallerMedia* media;
	const gchar* _tmp1_;
	BoxesMediaManager* _tmp2_;
	GCancellable* _tmp3_;
	GError * _inner_error_;
};

typedef enum  {
	BOXES_OS_DATABASE_ERROR_NON_BOOTABLE,
	BOXES_OS_DATABASE_ERROR_UNKNOWN_OS_ID,
	BOXES_OS_DATABASE_ERROR_UNKNOWN_MEDIA_ID
} BoxesOSDatabaseError;
#define BOXES_OS_DATABASE_ERROR boxes_os_database_error_quark ()
struct _BoxesInstallerMediaSetupForPathData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	BoxesInstallerMedia* self;
	gchar* path;
	BoxesMediaManager* media_manager;
	GCancellable* cancellable;
	const gchar* _tmp0_;
	BoxesMediaManager* _tmp1_;
	GUdevClient* _tmp2_;
	GUdevClient* _tmp3_;
	GCancellable* _tmp4_;
	GUdevDevice* _tmp5_;
	GUdevDevice* device;
	GUdevDevice* _tmp6_;
	GUdevDevice* _tmp7_;
	BoxesMediaManager* _tmp8_;
	BoxesOSDatabase* _tmp9_;
	BoxesOSDatabase* _tmp10_;
	BoxesMediaManager* _tmp11_;
	BoxesOSDatabase* _tmp12_;
	BoxesOSDatabase* _tmp13_;
	const gchar* _tmp14_;
	GCancellable* _tmp15_;
	OsinfoMedia* _tmp16_;
	OsinfoOs* _tmp17_;
	OsinfoOs* _tmp18_;
	gchar* _tmp19_;
	OsinfoMedia* _tmp20_;
	OsinfoMedia* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* architecture;
	BoxesMediaManager* _tmp27_;
	BoxesOSDatabase* _tmp28_;
	BoxesOSDatabase* _tmp29_;
	OsinfoOs* _tmp30_;
	const gchar* _tmp31_;
	OsinfoResources* _tmp32_;
	GError * _inner_error_;
};

struct _BoxesInstallerMediaPrepareForInstallationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	BoxesInstallerMedia* self;
	gchar* vm_name;
	GCancellable* cancellable;
};

struct _BoxesInstallerMediaGetDeviceFromPathData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	BoxesInstallerMedia* self;
	gchar* path;
	GUdevClient* client;
	GCancellable* cancellable;
	GUdevDevice* result;
	const gchar* _tmp0_;
	GFile* _tmp1_;
	GFile* mount_dir;
	GCancellable* _tmp2_;
	GMount* _tmp3_;
	GMount* mount;
	GFile* _tmp4_;
	GFile* root_dir;
	GFile* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gboolean _tmp10_;
	GVolume* _tmp11_;
	GVolume* volume;
	GVolume* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	GError* _error_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	GUdevClient* _tmp20_;
	const gchar* _tmp21_;
	GUdevDevice* _tmp22_;
	GError * _inner_error_;
};


static gpointer boxes_installer_media_parent_class = NULL;

GType boxes_installer_media_get_type (void) G_GNUC_CONST;
enum  {
	BOXES_INSTALLER_MEDIA_DUMMY_PROPERTY,
	BOXES_INSTALLER_MEDIA_INSTALLED_SIZE,
	BOXES_INSTALLER_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION,
	BOXES_INSTALLER_MEDIA_USER_DATA_FOR_VM_CREATION_AVAILABLE,
	BOXES_INSTALLER_MEDIA_SUPPORTS_VIRTIO_DISK,
	BOXES_INSTALLER_MEDIA_LIVE
};
BoxesInstallerMedia* boxes_installer_media_new_from_iso_info (const gchar* path, const gchar* label, OsinfoOs* os, OsinfoMedia* media, OsinfoResources* resources);
BoxesInstallerMedia* boxes_installer_media_construct_from_iso_info (GType object_type, const gchar* path, const gchar* label, OsinfoOs* os, OsinfoMedia* media, OsinfoResources* resources);
static void boxes_installer_media_setup_label (BoxesInstallerMedia* self, const gchar* label);
static void boxes_installer_media_create_for_path_data_free (gpointer _data);
GType boxes_media_manager_get_type (void) G_GNUC_CONST;
void boxes_installer_media_create_for_path (const gchar* path, BoxesMediaManager* media_manager, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
BoxesInstallerMedia* boxes_installer_media_create_for_path_finish (GAsyncResult* _res_, GError** error);
static gboolean boxes_installer_media_create_for_path_co (BoxesInstallerMediaCreateForPathData* _data_);
BoxesInstallerMedia* boxes_installer_media_new (void);
BoxesInstallerMedia* boxes_installer_media_construct (GType object_type);
static void boxes_installer_media_setup_for_path (BoxesInstallerMedia* self, const gchar* path, BoxesMediaManager* media_manager, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void boxes_installer_media_setup_for_path_finish (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error);
static void boxes_installer_media_create_for_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void boxes_installer_media_setup_for_path_data_free (gpointer _data);
static gboolean boxes_installer_media_setup_for_path_co (BoxesInstallerMediaSetupForPathData* _data_);
static void boxes_installer_media_get_device_from_path (BoxesInstallerMedia* self, const gchar* path, GUdevClient* client, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
static GUdevDevice* boxes_installer_media_get_device_from_path_finish (BoxesInstallerMedia* self, GAsyncResult* _res_);
GUdevClient* boxes_media_manager_get_client (BoxesMediaManager* self);
static void boxes_installer_media_setup_for_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
gpointer boxes_os_database_ref (gpointer instance);
void boxes_os_database_unref (gpointer instance);
GParamSpec* boxes_param_spec_os_database (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void boxes_value_set_os_database (GValue* value, gpointer v_object);
void boxes_value_take_os_database (GValue* value, gpointer v_object);
gpointer boxes_value_get_os_database (const GValue* value);
GType boxes_os_database_get_type (void) G_GNUC_CONST;
GQuark boxes_os_database_error_quark (void);
static void boxes_installer_media_get_media_info_from_device (BoxesInstallerMedia* self, GUdevDevice* device, BoxesOSDatabase* os_db, GError** error);
BoxesOSDatabase* boxes_media_manager_get_os_db (BoxesMediaManager* self);
void boxes_os_database_guess_os_from_install_media (BoxesOSDatabase* self, const gchar* media_path, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
OsinfoOs* boxes_os_database_guess_os_from_install_media_finish (BoxesOSDatabase* self, GAsyncResult* _res_, OsinfoMedia** os_media, GError** error);
OsinfoResources* boxes_os_database_get_resources_for_os (BoxesOSDatabase* self, OsinfoOs* os, const gchar* architecture);
void boxes_installer_media_set_direct_boot_params (BoxesInstallerMedia* self, GVirConfigDomainOs* os);
static void boxes_installer_media_real_set_direct_boot_params (BoxesInstallerMedia* self, GVirConfigDomainOs* os);
static void boxes_installer_media_real_prepare_for_installation_data_free (gpointer _data);
static void boxes_installer_media_real_prepare_for_installation (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void boxes_installer_media_prepare_for_installation (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void boxes_installer_media_prepare_for_installation_finish (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error);
static gboolean boxes_installer_media_real_prepare_for_installation_co (BoxesInstallerMediaPrepareForInstallationData* _data_);
void boxes_installer_media_setup_domain_config (BoxesInstallerMedia* self, GVirConfigDomain* domain);
static void boxes_installer_media_real_setup_domain_config (BoxesInstallerMedia* self, GVirConfigDomain* domain);
void boxes_installer_media_add_cd_config (BoxesInstallerMedia* self, GVirConfigDomain* domain, GVirConfigDomainDiskType type, const gchar* iso_path, const gchar* device_name, gboolean mandatory);
void boxes_installer_media_populate_setup_vbox (BoxesInstallerMedia* self, GtkVBox* setup_vbox);
static void boxes_installer_media_real_populate_setup_vbox (BoxesInstallerMedia* self, GtkVBox* setup_vbox);
GList* boxes_installer_media_get_vm_properties (BoxesInstallerMedia* self);
static GList* boxes_installer_media_real_get_vm_properties (BoxesInstallerMedia* self);
static void _boxes_pair_unref0_ (gpointer var);
static void _g_list_free__boxes_pair_unref0_ (GList* self);
gboolean boxes_installer_media_is_architecture_compatible (BoxesInstallerMedia* self, const gchar* architecture);
static void boxes_installer_media_get_device_from_path_data_free (gpointer _data);
static gboolean boxes_installer_media_get_device_from_path_co (BoxesInstallerMediaGetDeviceFromPathData* _data_);
static void boxes_installer_media_get_device_from_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
OsinfoOs* boxes_os_database_get_os_by_id (BoxesOSDatabase* self, const gchar* id, GError** error);
OsinfoMedia* boxes_os_database_get_media_by_id (BoxesOSDatabase* self, OsinfoOs* os, const gchar* id, GError** error);
guint64 boxes_installer_media_get_installed_size (BoxesInstallerMedia* self);
gboolean boxes_installer_media_get_need_user_input_for_vm_creation (BoxesInstallerMedia* self);
gboolean boxes_installer_media_get_user_data_for_vm_creation_available (BoxesInstallerMedia* self);
gboolean boxes_installer_media_get_supports_virtio_disk (BoxesInstallerMedia* self);
OsinfoDevice* boxes_get_os_device_by_prop (OsinfoOs* os, const gchar* prop_name, const gchar* prop_value);
gboolean boxes_installer_media_get_live (BoxesInstallerMedia* self);
static void boxes_installer_media_finalize (GObject* obj);
static void _vala_boxes_installer_media_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


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


BoxesInstallerMedia* boxes_installer_media_construct_from_iso_info (GType object_type, const gchar* path, const gchar* label, OsinfoOs* os, OsinfoMedia* media, OsinfoResources* resources) {
	BoxesInstallerMedia * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	OsinfoOs* _tmp2_;
	OsinfoOs* _tmp3_;
	OsinfoMedia* _tmp4_;
	OsinfoMedia* _tmp5_;
	OsinfoResources* _tmp6_;
	OsinfoResources* _tmp7_;
	const gchar* _tmp8_;
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (label != NULL, NULL);
	g_return_val_if_fail (os != NULL, NULL);
	g_return_val_if_fail (media != NULL, NULL);
	g_return_val_if_fail (resources != NULL, NULL);
	self = (BoxesInstallerMedia*) g_object_new (object_type, NULL);
	_tmp0_ = path;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->device_file);
	self->device_file = _tmp1_;
	_tmp2_ = os;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->os);
	self->os = _tmp3_;
	_tmp4_ = media;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (self->os_media);
	self->os_media = _tmp5_;
	_tmp6_ = resources;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->resources);
	self->resources = _tmp7_;
	self->from_image = TRUE;
	_tmp8_ = label;
	boxes_installer_media_setup_label (self, _tmp8_);
	return self;
}


BoxesInstallerMedia* boxes_installer_media_new_from_iso_info (const gchar* path, const gchar* label, OsinfoOs* os, OsinfoMedia* media, OsinfoResources* resources) {
	return boxes_installer_media_construct_from_iso_info (BOXES_TYPE_INSTALLER_MEDIA, path, label, os, media, resources);
}


static void boxes_installer_media_create_for_path_data_free (gpointer _data) {
	BoxesInstallerMediaCreateForPathData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	_g_object_unref0 (_data_->media_manager);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	g_slice_free (BoxesInstallerMediaCreateForPathData, _data_);
}


void boxes_installer_media_create_for_path (const gchar* path, BoxesMediaManager* media_manager, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BoxesInstallerMediaCreateForPathData* _data_;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	BoxesMediaManager* _tmp2_;
	BoxesMediaManager* _tmp3_;
	GCancellable* _tmp4_;
	GCancellable* _tmp5_;
	_data_ = g_slice_new0 (BoxesInstallerMediaCreateForPathData);
	_data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, boxes_installer_media_create_for_path);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, boxes_installer_media_create_for_path_data_free);
	_tmp0_ = path;
	_tmp1_ = g_strdup (_tmp0_);
	_data_->path = _tmp1_;
	_tmp2_ = media_manager;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_data_->media_manager = _tmp3_;
	_tmp4_ = cancellable;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_data_->cancellable = _tmp5_;
	boxes_installer_media_create_for_path_co (_data_);
}


BoxesInstallerMedia* boxes_installer_media_create_for_path_finish (GAsyncResult* _res_, GError** error) {
	BoxesInstallerMedia* result;
	BoxesInstallerMediaCreateForPathData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return NULL;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


static void boxes_installer_media_create_for_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	BoxesInstallerMediaCreateForPathData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installer_media_create_for_path_co (_data_);
}


static gboolean boxes_installer_media_create_for_path_co (BoxesInstallerMediaCreateForPathData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = boxes_installer_media_new ();
	_data_->media = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->path;
	_data_->_tmp2_ = _data_->media_manager;
	_data_->_tmp3_ = _data_->cancellable;
	_data_->_state_ = 1;
	boxes_installer_media_setup_for_path (_data_->media, _data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, boxes_installer_media_create_for_path_ready, _data_);
	return FALSE;
	_state_1:
	boxes_installer_media_setup_for_path_finish (_data_->media, _data_->_res_, &_data_->_inner_error_);
	if (_data_->_inner_error_ != NULL) {
		g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
		g_error_free (_data_->_inner_error_);
		_g_object_unref0 (_data_->media);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->media;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
	_g_object_unref0 (_data_->media);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void boxes_installer_media_setup_for_path_data_free (gpointer _data) {
	BoxesInstallerMediaSetupForPathData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	_g_object_unref0 (_data_->media_manager);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstallerMediaSetupForPathData, _data_);
}


static void boxes_installer_media_setup_for_path (BoxesInstallerMedia* self, const gchar* path, BoxesMediaManager* media_manager, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BoxesInstallerMediaSetupForPathData* _data_;
	BoxesInstallerMedia* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	BoxesMediaManager* _tmp3_;
	BoxesMediaManager* _tmp4_;
	GCancellable* _tmp5_;
	GCancellable* _tmp6_;
	_data_ = g_slice_new0 (BoxesInstallerMediaSetupForPathData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, boxes_installer_media_setup_for_path);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, boxes_installer_media_setup_for_path_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = path;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->path = _tmp2_;
	_tmp3_ = media_manager;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data_->media_manager = _tmp4_;
	_tmp5_ = cancellable;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_data_->cancellable = _tmp6_;
	boxes_installer_media_setup_for_path_co (_data_);
}


static void boxes_installer_media_setup_for_path_finish (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error) {
	BoxesInstallerMediaSetupForPathData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void boxes_installer_media_setup_for_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	BoxesInstallerMediaSetupForPathData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installer_media_setup_for_path_co (_data_);
}


static gboolean boxes_installer_media_setup_for_path_co (BoxesInstallerMediaSetupForPathData* _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_ = _data_->path;
	_data_->_tmp1_ = _data_->media_manager;
	_data_->_tmp2_ = boxes_media_manager_get_client (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = _data_->cancellable;
	_data_->_state_ = 1;
	boxes_installer_media_get_device_from_path (_data_->self, _data_->_tmp0_, _data_->_tmp3_, _data_->_tmp4_, boxes_installer_media_setup_for_path_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = boxes_installer_media_get_device_from_path_finish (_data_->self, _data_->_res_);
	_data_->device = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->device;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->device;
		_data_->_tmp8_ = _data_->media_manager;
		_data_->_tmp9_ = boxes_media_manager_get_os_db (_data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		boxes_installer_media_get_media_info_from_device (_data_->self, _data_->_tmp7_, _data_->_tmp10_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->device);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	} else {
		_data_->self->from_image = TRUE;
		_data_->_tmp11_ = _data_->media_manager;
		_data_->_tmp12_ = boxes_media_manager_get_os_db (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = _data_->self->device_file;
		_data_->_tmp15_ = _data_->cancellable;
		_data_->_tmp16_ = NULL;
		_data_->_state_ = 2;
		boxes_os_database_guess_os_from_install_media (_data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_, boxes_installer_media_setup_for_path_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = boxes_os_database_guess_os_from_install_media_finish (_data_->_tmp13_, _data_->_res_, &_data_->_tmp16_, &_data_->_inner_error_);
		_g_object_unref0 (_data_->self->os_media);
		_data_->self->os_media = _data_->_tmp16_;
		_data_->_tmp18_ = _data_->_tmp17_;
		if (_data_->_inner_error_ != NULL) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->device);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->self->os);
		_data_->self->os = _data_->_tmp18_;
	}
	boxes_installer_media_setup_label (_data_->self, NULL);
	_data_->_tmp20_ = _data_->self->os_media;
	if (_data_->_tmp20_ != NULL) {
		_data_->_tmp21_ = _data_->self->os_media;
		_data_->_tmp22_ = NULL;
		g_object_get (_data_->_tmp21_, "architecture", &_data_->_tmp22_, NULL);
		_data_->_tmp23_ = _data_->_tmp22_;
		_g_free0 (_data_->_tmp19_);
		_data_->_tmp19_ = _data_->_tmp23_;
	} else {
		_data_->_tmp24_ = g_strdup ("i686");
		_g_free0 (_data_->_tmp19_);
		_data_->_tmp19_ = _data_->_tmp24_;
	}
	_data_->_tmp25_ = _data_->_tmp19_;
	_data_->_tmp26_ = g_strdup (_data_->_tmp25_);
	_data_->architecture = _data_->_tmp26_;
	_data_->_tmp27_ = _data_->media_manager;
	_data_->_tmp28_ = boxes_media_manager_get_os_db (_data_->_tmp27_);
	_data_->_tmp29_ = _data_->_tmp28_;
	_data_->_tmp30_ = _data_->self->os;
	_data_->_tmp31_ = _data_->architecture;
	_data_->_tmp32_ = NULL;
	_data_->_tmp32_ = boxes_os_database_get_resources_for_os (_data_->_tmp29_, _data_->_tmp30_, _data_->_tmp31_);
	_g_object_unref0 (_data_->self->resources);
	_data_->self->resources = _data_->_tmp32_;
	_g_free0 (_data_->architecture);
	_g_free0 (_data_->_tmp19_);
	_g_object_unref0 (_data_->device);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void boxes_installer_media_real_set_direct_boot_params (BoxesInstallerMedia* self, GVirConfigDomainOs* os) {
	g_return_if_fail (os != NULL);
}


void boxes_installer_media_set_direct_boot_params (BoxesInstallerMedia* self, GVirConfigDomainOs* os) {
	g_return_if_fail (self != NULL);
	BOXES_INSTALLER_MEDIA_GET_CLASS (self)->set_direct_boot_params (self, os);
}


static void boxes_installer_media_real_prepare_for_installation_data_free (gpointer _data) {
	BoxesInstallerMediaPrepareForInstallationData* _data_;
	_data_ = _data;
	_g_free0 (_data_->vm_name);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstallerMediaPrepareForInstallationData, _data_);
}


static void boxes_installer_media_real_prepare_for_installation (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BoxesInstallerMediaPrepareForInstallationData* _data_;
	BoxesInstallerMedia* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GCancellable* _tmp3_;
	GCancellable* _tmp4_;
	_data_ = g_slice_new0 (BoxesInstallerMediaPrepareForInstallationData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, boxes_installer_media_real_prepare_for_installation);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, boxes_installer_media_real_prepare_for_installation_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = vm_name;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->vm_name = _tmp2_;
	_tmp3_ = cancellable;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data_->cancellable = _tmp4_;
	boxes_installer_media_real_prepare_for_installation_co (_data_);
}


static void boxes_installer_media_real_prepare_for_installation_finish (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error) {
	BoxesInstallerMediaPrepareForInstallationData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean boxes_installer_media_real_prepare_for_installation_co (BoxesInstallerMediaPrepareForInstallationData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


void boxes_installer_media_prepare_for_installation (BoxesInstallerMedia* self, const gchar* vm_name, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BOXES_INSTALLER_MEDIA_GET_CLASS (self)->prepare_for_installation (self, vm_name, cancellable, _callback_, _user_data_);
}


void boxes_installer_media_prepare_for_installation_finish (BoxesInstallerMedia* self, GAsyncResult* _res_, GError** error) {
	BOXES_INSTALLER_MEDIA_GET_CLASS (self)->prepare_for_installation_finish (self, _res_, error);
}


static void boxes_installer_media_real_setup_domain_config (BoxesInstallerMedia* self, GVirConfigDomain* domain) {
	GVirConfigDomainDiskType _tmp0_ = 0;
	gboolean _tmp1_;
	GVirConfigDomain* _tmp2_;
	GVirConfigDomainDiskType _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (domain != NULL);
	_tmp1_ = self->from_image;
	if (_tmp1_) {
		_tmp0_ = GVIR_CONFIG_DOMAIN_DISK_FILE;
	} else {
		_tmp0_ = GVIR_CONFIG_DOMAIN_DISK_BLOCK;
	}
	_tmp2_ = domain;
	_tmp3_ = _tmp0_;
	_tmp4_ = self->device_file;
	boxes_installer_media_add_cd_config (self, _tmp2_, _tmp3_, _tmp4_, "hdc", TRUE);
}


void boxes_installer_media_setup_domain_config (BoxesInstallerMedia* self, GVirConfigDomain* domain) {
	g_return_if_fail (self != NULL);
	BOXES_INSTALLER_MEDIA_GET_CLASS (self)->setup_domain_config (self, domain);
}


static void boxes_installer_media_real_populate_setup_vbox (BoxesInstallerMedia* self, GtkVBox* setup_vbox) {
	g_return_if_fail (setup_vbox != NULL);
}


void boxes_installer_media_populate_setup_vbox (BoxesInstallerMedia* self, GtkVBox* setup_vbox) {
	g_return_if_fail (self != NULL);
	BOXES_INSTALLER_MEDIA_GET_CLASS (self)->populate_setup_vbox (self, setup_vbox);
}


static void _boxes_pair_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (boxes_pair_unref (var), NULL));
}


static void _g_list_free__boxes_pair_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _boxes_pair_unref0_, NULL);
	g_list_free (self);
}


static GList* boxes_installer_media_real_get_vm_properties (BoxesInstallerMedia* self) {
	GList* result = NULL;
	GList* properties;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	BoxesPair* _tmp2_;
	properties = NULL;
	_tmp0_ = _ ("System");
	_tmp1_ = self->label;
	_tmp2_ = boxes_pair_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp0_, _tmp1_);
	properties = g_list_append (properties, _tmp2_);
	result = properties;
	return result;
}


GList* boxes_installer_media_get_vm_properties (BoxesInstallerMedia* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return BOXES_INSTALLER_MEDIA_GET_CLASS (self)->get_vm_properties (self);
}


gboolean boxes_installer_media_is_architecture_compatible (BoxesInstallerMedia* self, const gchar* architecture) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	OsinfoMedia* _tmp4_;
	gboolean _tmp10_;
	gboolean _tmp19_;
	gboolean _tmp28_;
	gboolean _tmp37_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (architecture != NULL, FALSE);
	_tmp4_ = self->os_media;
	if (_tmp4_ == NULL) {
		_tmp3_ = TRUE;
	} else {
		OsinfoMedia* _tmp5_;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_;
		gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp5_ = self->os_media;
		g_object_get (_tmp5_, "architecture", &_tmp6_, NULL);
		_tmp7_ = _tmp6_;
		_tmp8_ = _tmp7_;
		_tmp9_ = architecture;
		_tmp3_ = g_strcmp0 (_tmp8_, _tmp9_) == 0;
		_g_free0 (_tmp8_);
	}
	_tmp10_ = _tmp3_;
	if (_tmp10_) {
		_tmp2_ = TRUE;
	} else {
		gboolean _tmp11_ = FALSE;
		OsinfoMedia* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gboolean _tmp16_;
		gboolean _tmp18_;
		_tmp12_ = self->os_media;
		g_object_get (_tmp12_, "architecture", &_tmp13_, NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strcmp0 (_tmp15_, "i386") == 0;
		_g_free0 (_tmp15_);
		if (_tmp16_) {
			const gchar* _tmp17_;
			_tmp17_ = architecture;
			_tmp11_ = g_strcmp0 (_tmp17_, "i686") == 0;
		} else {
			_tmp11_ = FALSE;
		}
		_tmp18_ = _tmp11_;
		_tmp2_ = _tmp18_;
	}
	_tmp19_ = _tmp2_;
	if (_tmp19_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp20_ = FALSE;
		OsinfoMedia* _tmp21_;
		gchar* _tmp22_ = NULL;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gboolean _tmp25_;
		gboolean _tmp27_;
		_tmp21_ = self->os_media;
		g_object_get (_tmp21_, "architecture", &_tmp22_, NULL);
		_tmp23_ = _tmp22_;
		_tmp24_ = _tmp23_;
		_tmp25_ = g_strcmp0 (_tmp24_, "i386") == 0;
		_g_free0 (_tmp24_);
		if (_tmp25_) {
			const gchar* _tmp26_;
			_tmp26_ = architecture;
			_tmp20_ = g_strcmp0 (_tmp26_, "x86_64") == 0;
		} else {
			_tmp20_ = FALSE;
		}
		_tmp27_ = _tmp20_;
		_tmp1_ = _tmp27_;
	}
	_tmp28_ = _tmp1_;
	if (_tmp28_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp29_ = FALSE;
		OsinfoMedia* _tmp30_;
		gchar* _tmp31_ = NULL;
		gchar* _tmp32_;
		gchar* _tmp33_;
		gboolean _tmp34_;
		gboolean _tmp36_;
		_tmp30_ = self->os_media;
		g_object_get (_tmp30_, "architecture", &_tmp31_, NULL);
		_tmp32_ = _tmp31_;
		_tmp33_ = _tmp32_;
		_tmp34_ = g_strcmp0 (_tmp33_, "i686") == 0;
		_g_free0 (_tmp33_);
		if (_tmp34_) {
			const gchar* _tmp35_;
			_tmp35_ = architecture;
			_tmp29_ = g_strcmp0 (_tmp35_, "x86_64") == 0;
		} else {
			_tmp29_ = FALSE;
		}
		_tmp36_ = _tmp29_;
		_tmp0_ = _tmp36_;
	}
	_tmp37_ = _tmp0_;
	result = _tmp37_;
	return result;
}


void boxes_installer_media_add_cd_config (BoxesInstallerMedia* self, GVirConfigDomain* domain, GVirConfigDomainDiskType type, const gchar* iso_path, const gchar* device_name, gboolean mandatory) {
	GVirConfigDomainDisk* _tmp0_;
	GVirConfigDomainDisk* disk;
	GVirConfigDomainDisk* _tmp1_;
	GVirConfigDomainDiskType _tmp2_;
	GVirConfigDomainDisk* _tmp3_;
	GVirConfigDomainDisk* _tmp4_;
	GVirConfigDomainDisk* _tmp5_;
	GVirConfigDomainDisk* _tmp6_;
	const gchar* _tmp7_;
	GVirConfigDomainDisk* _tmp8_;
	const gchar* _tmp9_;
	GVirConfigDomainDisk* _tmp10_;
	gboolean _tmp11_;
	GVirConfigDomain* _tmp13_;
	GVirConfigDomainDisk* _tmp14_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (domain != NULL);
	g_return_if_fail (iso_path != NULL);
	g_return_if_fail (device_name != NULL);
	_tmp0_ = gvir_config_domain_disk_new ();
	disk = _tmp0_;
	_tmp1_ = disk;
	_tmp2_ = type;
	gvir_config_domain_disk_set_type (_tmp1_, _tmp2_);
	_tmp3_ = disk;
	gvir_config_domain_disk_set_guest_device_type (_tmp3_, GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_CDROM);
	_tmp4_ = disk;
	gvir_config_domain_disk_set_driver_name (_tmp4_, "qemu");
	_tmp5_ = disk;
	gvir_config_domain_disk_set_driver_type (_tmp5_, "raw");
	_tmp6_ = disk;
	_tmp7_ = device_name;
	gvir_config_domain_disk_set_target_dev (_tmp6_, _tmp7_);
	_tmp8_ = disk;
	_tmp9_ = iso_path;
	gvir_config_domain_disk_set_source (_tmp8_, _tmp9_);
	_tmp10_ = disk;
	gvir_config_domain_disk_set_target_bus (_tmp10_, GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
	_tmp11_ = mandatory;
	if (_tmp11_) {
		GVirConfigDomainDisk* _tmp12_;
		_tmp12_ = disk;
		gvir_config_domain_disk_set_startup_policy (_tmp12_, GVIR_CONFIG_DOMAIN_DISK_STARTUP_POLICY_MANDATORY);
	}
	_tmp13_ = domain;
	_tmp14_ = disk;
	gvir_config_domain_add_device (_tmp13_, (GVirConfigDomainDevice*) _tmp14_);
	_g_object_unref0 (disk);
}


static void boxes_installer_media_get_device_from_path_data_free (gpointer _data) {
	BoxesInstallerMediaGetDeviceFromPathData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	_g_object_unref0 (_data_->client);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesInstallerMediaGetDeviceFromPathData, _data_);
}


static void boxes_installer_media_get_device_from_path (BoxesInstallerMedia* self, const gchar* path, GUdevClient* client, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BoxesInstallerMediaGetDeviceFromPathData* _data_;
	BoxesInstallerMedia* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GUdevClient* _tmp3_;
	GUdevClient* _tmp4_;
	GCancellable* _tmp5_;
	GCancellable* _tmp6_;
	_data_ = g_slice_new0 (BoxesInstallerMediaGetDeviceFromPathData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, boxes_installer_media_get_device_from_path);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, boxes_installer_media_get_device_from_path_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = path;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->path = _tmp2_;
	_tmp3_ = client;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data_->client = _tmp4_;
	_tmp5_ = cancellable;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_data_->cancellable = _tmp6_;
	boxes_installer_media_get_device_from_path_co (_data_);
}


static GUdevDevice* boxes_installer_media_get_device_from_path_finish (BoxesInstallerMedia* self, GAsyncResult* _res_) {
	GUdevDevice* result;
	BoxesInstallerMediaGetDeviceFromPathData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


static void boxes_installer_media_get_device_from_path_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	BoxesInstallerMediaGetDeviceFromPathData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_installer_media_get_device_from_path_co (_data_);
}


static gboolean boxes_installer_media_get_device_from_path_co (BoxesInstallerMediaGetDeviceFromPathData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->path;
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = g_file_new_for_commandline_arg (_data_->_tmp0_);
		_data_->mount_dir = _data_->_tmp1_;
		_data_->_tmp2_ = _data_->cancellable;
		_data_->_state_ = 1;
		g_file_find_enclosing_mount_async (_data_->mount_dir, G_PRIORITY_DEFAULT, _data_->_tmp2_, boxes_installer_media_get_device_from_path_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = g_file_find_enclosing_mount_finish (_data_->mount_dir, _data_->_res_, &_data_->_inner_error_);
		_data_->mount = _data_->_tmp3_;
		if (_data_->_inner_error_ != NULL) {
			_g_object_unref0 (_data_->mount_dir);
			goto __catch11_g_error;
		}
		_data_->_tmp4_ = NULL;
		_data_->_tmp4_ = g_mount_get_root (_data_->mount);
		_data_->root_dir = _data_->_tmp4_;
		_data_->_tmp5_ = _data_->root_dir;
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = g_file_get_path (_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = g_file_get_path (_data_->mount_dir);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = g_strcmp0 (_data_->_tmp7_, _data_->_tmp9_) == 0;
		_g_free0 (_data_->_tmp9_);
		_g_free0 (_data_->_tmp7_);
		if (_data_->_tmp10_) {
			_data_->_tmp11_ = NULL;
			_data_->_tmp11_ = g_mount_get_volume (_data_->mount);
			_data_->volume = _data_->_tmp11_;
			_data_->_tmp12_ = _data_->volume;
			_data_->_tmp13_ = NULL;
			_data_->_tmp13_ = g_volume_get_identifier (_data_->_tmp12_, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
			_g_free0 (_data_->self->device_file);
			_data_->self->device_file = _data_->_tmp13_;
			_data_->_tmp14_ = _data_->path;
			_data_->_tmp15_ = g_strdup (_data_->_tmp14_);
			_g_free0 (_data_->self->mount_point);
			_data_->self->mount_point = _data_->_tmp15_;
			_g_object_unref0 (_data_->volume);
		} else {
			_data_->_tmp16_ = _data_->path;
			_data_->_tmp17_ = g_strdup (_data_->_tmp16_);
			_g_free0 (_data_->self->device_file);
			_data_->self->device_file = _data_->_tmp17_;
		}
		_g_object_unref0 (_data_->root_dir);
		_g_object_unref0 (_data_->mount);
		_g_object_unref0 (_data_->mount_dir);
	}
	goto __finally11;
	__catch11_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp18_ = _data_->path;
		_data_->_tmp19_ = g_strdup (_data_->_tmp18_);
		_g_free0 (_data_->self->device_file);
		_data_->self->device_file = _data_->_tmp19_;
		_g_error_free0 (_data_->_error_);
	}
	__finally11:
	if (_data_->_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_data_->_tmp20_ = _data_->client;
	_data_->_tmp21_ = _data_->self->device_file;
	_data_->_tmp22_ = NULL;
	_data_->_tmp22_ = g_udev_client_query_by_device_file (_data_->_tmp20_, _data_->_tmp21_);
	_data_->result = _data_->_tmp22_;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void boxes_installer_media_get_media_info_from_device (BoxesInstallerMedia* self, GUdevDevice* device, BoxesOSDatabase* os_db, GError** error) {
	GUdevDevice* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GUdevDevice* _tmp4_;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_;
	GUdevDevice* _tmp7_;
	const gchar* _tmp8_ = NULL;
	gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* os_id;
	const gchar* _tmp17_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (device != NULL);
	g_return_if_fail (os_db != NULL);
	_tmp0_ = device;
	_tmp1_ = g_udev_device_get_property_as_boolean (_tmp0_, "OSINFO_BOOTABLE");
	if (!_tmp1_) {
		const gchar* _tmp2_;
		GError* _tmp3_;
		_tmp2_ = self->device_file;
		_tmp3_ = g_error_new (BOXES_OS_DATABASE_ERROR, BOXES_OS_DATABASE_ERROR_NON_BOOTABLE, "Media %s is not bootable.", _tmp2_);
		_inner_error_ = _tmp3_;
		if (_inner_error_->domain == BOXES_OS_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp4_ = device;
	_tmp5_ = g_udev_device_get_property (_tmp4_, "ID_FS_LABEL");
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (self->label);
	self->label = _tmp6_;
	_tmp7_ = device;
	_tmp8_ = g_udev_device_get_property (_tmp7_, "OSINFO_INSTALLER");
	_tmp9_ = g_strdup (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_;
	if (_tmp11_ == NULL) {
		GUdevDevice* _tmp12_;
		const gchar* _tmp13_ = NULL;
		gchar* _tmp14_;
		_tmp12_ = device;
		_tmp13_ = g_udev_device_get_property (_tmp12_, "OSINFO_LIVE");
		_tmp14_ = g_strdup (_tmp13_);
		_g_free0 (_tmp10_);
		_tmp10_ = _tmp14_;
	}
	_tmp15_ = _tmp10_;
	_tmp16_ = g_strdup (_tmp15_);
	os_id = _tmp16_;
	_tmp17_ = os_id;
	if (_tmp17_ != NULL) {
		BoxesOSDatabase* _tmp18_;
		const gchar* _tmp19_;
		OsinfoOs* _tmp20_ = NULL;
		OsinfoOs* _tmp21_;
		GUdevDevice* _tmp22_;
		const gchar* _tmp23_ = NULL;
		gchar* _tmp24_;
		gchar* media_id;
		const gchar* _tmp25_;
		_tmp18_ = os_db;
		_tmp19_ = os_id;
		_tmp20_ = boxes_os_database_get_os_by_id (_tmp18_, _tmp19_, &_inner_error_);
		_tmp21_ = _tmp20_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == BOXES_OS_DATABASE_ERROR) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (os_id);
				_g_free0 (_tmp10_);
				return;
			} else {
				_g_free0 (os_id);
				_g_free0 (_tmp10_);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_g_object_unref0 (self->os);
		self->os = _tmp21_;
		_tmp22_ = device;
		_tmp23_ = g_udev_device_get_property (_tmp22_, "OSINFO_MEDIA");
		_tmp24_ = g_strdup (_tmp23_);
		media_id = _tmp24_;
		_tmp25_ = media_id;
		if (_tmp25_ != NULL) {
			BoxesOSDatabase* _tmp26_;
			OsinfoOs* _tmp27_;
			const gchar* _tmp28_;
			OsinfoMedia* _tmp29_ = NULL;
			OsinfoMedia* _tmp30_;
			_tmp26_ = os_db;
			_tmp27_ = self->os;
			_tmp28_ = media_id;
			_tmp29_ = boxes_os_database_get_media_by_id (_tmp26_, _tmp27_, _tmp28_, &_inner_error_);
			_tmp30_ = _tmp29_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == BOXES_OS_DATABASE_ERROR) {
					g_propagate_error (error, _inner_error_);
					_g_free0 (media_id);
					_g_free0 (os_id);
					_g_free0 (_tmp10_);
					return;
				} else {
					_g_free0 (media_id);
					_g_free0 (os_id);
					_g_free0 (_tmp10_);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return;
				}
			}
			_g_object_unref0 (self->os_media);
			self->os_media = _tmp30_;
		}
		_g_free0 (media_id);
	}
	_g_free0 (os_id);
	_g_free0 (_tmp10_);
}


static void boxes_installer_media_setup_label (BoxesInstallerMedia* self, const gchar* label) {
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = label;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = label;
		_tmp2_ = g_strdup (_tmp1_);
		_g_free0 (self->label);
		self->label = _tmp2_;
	} else {
		OsinfoOs* _tmp3_;
		_tmp3_ = self->os;
		if (_tmp3_ != NULL) {
			OsinfoOs* _tmp4_;
			const gchar* _tmp5_ = NULL;
			gchar* _tmp6_;
			_tmp4_ = self->os;
			_tmp5_ = osinfo_product_get_name ((OsinfoProduct*) _tmp4_);
			_tmp6_ = g_strdup (_tmp5_);
			_g_free0 (self->label);
			self->label = _tmp6_;
		} else {
			const gchar* _tmp7_;
			gchar* _tmp8_ = NULL;
			_tmp7_ = self->device_file;
			_tmp8_ = g_path_get_basename (_tmp7_);
			_g_free0 (self->label);
			self->label = _tmp8_;
			return;
		}
	}
}


BoxesInstallerMedia* boxes_installer_media_construct (GType object_type) {
	BoxesInstallerMedia * self = NULL;
	self = (BoxesInstallerMedia*) g_object_new (object_type, NULL);
	return self;
}


BoxesInstallerMedia* boxes_installer_media_new (void) {
	return boxes_installer_media_construct (BOXES_TYPE_INSTALLER_MEDIA);
}


guint64 boxes_installer_media_get_installed_size (BoxesInstallerMedia* self) {
	g_return_val_if_fail (self != NULL, 0ULL);
	return BOXES_INSTALLER_MEDIA_GET_CLASS (self)->get_installed_size (self);
}


static guint64 boxes_installer_media_real_get_installed_size (BoxesInstallerMedia* base) {
	guint64 result;
	BoxesInstallerMedia* self;
	self = base;
	result = (guint64) 0;
	return result;
}


gboolean boxes_installer_media_get_need_user_input_for_vm_creation (BoxesInstallerMedia* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return BOXES_INSTALLER_MEDIA_GET_CLASS (self)->get_need_user_input_for_vm_creation (self);
}


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


gboolean boxes_installer_media_get_user_data_for_vm_creation_available (BoxesInstallerMedia* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return BOXES_INSTALLER_MEDIA_GET_CLASS (self)->get_user_data_for_vm_creation_available (self);
}


static gboolean boxes_installer_media_real_get_user_data_for_vm_creation_available (BoxesInstallerMedia* base) {
	gboolean result;
	BoxesInstallerMedia* self;
	self = base;
	result = TRUE;
	return result;
}


gboolean boxes_installer_media_get_supports_virtio_disk (BoxesInstallerMedia* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return BOXES_INSTALLER_MEDIA_GET_CLASS (self)->get_supports_virtio_disk (self);
}


static gboolean boxes_installer_media_real_get_supports_virtio_disk (BoxesInstallerMedia* base) {
	gboolean result;
	BoxesInstallerMedia* self;
	OsinfoOs* _tmp0_;
	OsinfoDevice* _tmp1_ = NULL;
	OsinfoDevice* _tmp2_;
	gboolean _tmp3_;
	self = base;
	_tmp0_ = self->os;
	_tmp1_ = boxes_get_os_device_by_prop (_tmp0_, OSINFO_DEVICE_PROP_NAME, "virtio-block");
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ != NULL;
	_g_object_unref0 (_tmp2_);
	result = _tmp3_;
	return result;
}


gboolean boxes_installer_media_get_live (BoxesInstallerMedia* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	OsinfoMedia* _tmp1_;
	gboolean _tmp5_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->os_media;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		OsinfoMedia* _tmp2_;
		gboolean _tmp3_ = FALSE;
		gboolean _tmp4_;
		_tmp2_ = self->os_media;
		g_object_get (_tmp2_, "live", &_tmp3_, NULL);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	}
	_tmp5_ = _tmp0_;
	result = _tmp5_;
	return result;
}


static void boxes_installer_media_class_init (BoxesInstallerMediaClass * klass) {
	boxes_installer_media_parent_class = g_type_class_peek_parent (klass);
	BOXES_INSTALLER_MEDIA_CLASS (klass)->set_direct_boot_params = boxes_installer_media_real_set_direct_boot_params;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->prepare_for_installation = boxes_installer_media_real_prepare_for_installation;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->prepare_for_installation_finish = boxes_installer_media_real_prepare_for_installation_finish;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->setup_domain_config = boxes_installer_media_real_setup_domain_config;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->populate_setup_vbox = boxes_installer_media_real_populate_setup_vbox;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_vm_properties = boxes_installer_media_real_get_vm_properties;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_installed_size = boxes_installer_media_real_get_installed_size;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_need_user_input_for_vm_creation = boxes_installer_media_real_get_need_user_input_for_vm_creation;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_user_data_for_vm_creation_available = boxes_installer_media_real_get_user_data_for_vm_creation_available;
	BOXES_INSTALLER_MEDIA_CLASS (klass)->get_supports_virtio_disk = boxes_installer_media_real_get_supports_virtio_disk;
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_installer_media_get_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_installer_media_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLER_MEDIA_INSTALLED_SIZE, g_param_spec_uint64 ("installed-size", "installed-size", "installed-size", 0, G_MAXUINT64, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLER_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION, 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_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLER_MEDIA_USER_DATA_FOR_VM_CREATION_AVAILABLE, g_param_spec_boolean ("user-data-for-vm-creation-available", "user-data-for-vm-creation-available", "user-data-for-vm-creation-available", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLER_MEDIA_SUPPORTS_VIRTIO_DISK, g_param_spec_boolean ("supports-virtio-disk", "supports-virtio-disk", "supports-virtio-disk", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_INSTALLER_MEDIA_LIVE, g_param_spec_boolean ("live", "live", "live", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void boxes_installer_media_instance_init (BoxesInstallerMedia * self) {
}


static void boxes_installer_media_finalize (GObject* obj) {
	BoxesInstallerMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMedia);
	_g_object_unref0 (self->os);
	_g_object_unref0 (self->resources);
	_g_object_unref0 (self->os_media);
	_g_free0 (self->label);
	_g_free0 (self->device_file);
	_g_free0 (self->mount_point);
	G_OBJECT_CLASS (boxes_installer_media_parent_class)->finalize (obj);
}


GType boxes_installer_media_get_type (void) {
	static volatile gsize boxes_installer_media_type_id__volatile = 0;
	if (g_once_init_enter (&boxes_installer_media_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BoxesInstallerMediaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_installer_media_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesInstallerMedia), 0, (GInstanceInitFunc) boxes_installer_media_instance_init, NULL };
		GType boxes_installer_media_type_id;
		boxes_installer_media_type_id = g_type_register_static (G_TYPE_OBJECT, "BoxesInstallerMedia", &g_define_type_info, 0);
		g_once_init_leave (&boxes_installer_media_type_id__volatile, boxes_installer_media_type_id);
	}
	return boxes_installer_media_type_id__volatile;
}


static void _vala_boxes_installer_media_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	BoxesInstallerMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_INSTALLER_MEDIA, BoxesInstallerMedia);
	switch (property_id) {
		case BOXES_INSTALLER_MEDIA_INSTALLED_SIZE:
		g_value_set_uint64 (value, boxes_installer_media_get_installed_size (self));
		break;
		case BOXES_INSTALLER_MEDIA_NEED_USER_INPUT_FOR_VM_CREATION:
		g_value_set_boolean (value, boxes_installer_media_get_need_user_input_for_vm_creation (self));
		break;
		case BOXES_INSTALLER_MEDIA_USER_DATA_FOR_VM_CREATION_AVAILABLE:
		g_value_set_boolean (value, boxes_installer_media_get_user_data_for_vm_creation_available (self));
		break;
		case BOXES_INSTALLER_MEDIA_SUPPORTS_VIRTIO_DISK:
		g_value_set_boolean (value, boxes_installer_media_get_supports_virtio_disk (self));
		break;
		case BOXES_INSTALLER_MEDIA_LIVE:
		g_value_set_boolean (value, boxes_installer_media_get_live (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



