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

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

#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <libvirt-gconfig/libvirt-gconfig.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "common.h"
#include <libvirt-gobject/libvirt-gobject.h>
#include <gtk/gtk.h>
#include <handy.h>
#include <osinfo/osinfo.h>
#include <glib/gi18n-lib.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_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;
typedef struct _BoxesVMCreatorPrivate BoxesVMCreatorPrivate;

#define BOXES_TYPE_COLLECTION_ITEM (boxes_collection_item_get_type ())
#define BOXES_COLLECTION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItem))
#define BOXES_COLLECTION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItemClass))
#define BOXES_IS_COLLECTION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_COLLECTION_ITEM))
#define BOXES_IS_COLLECTION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_COLLECTION_ITEM))
#define BOXES_COLLECTION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_COLLECTION_ITEM, BoxesCollectionItemClass))

typedef struct _BoxesCollectionItem BoxesCollectionItem;
typedef struct _BoxesCollectionItemClass BoxesCollectionItemClass;

#define BOXES_TYPE_MACHINE (boxes_machine_get_type ())
#define BOXES_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_MACHINE, BoxesMachine))
#define BOXES_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_MACHINE, BoxesMachineClass))
#define BOXES_IS_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_MACHINE))
#define BOXES_IS_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_MACHINE))
#define BOXES_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_MACHINE, BoxesMachineClass))

typedef struct _BoxesMachine BoxesMachine;
typedef struct _BoxesMachineClass BoxesMachineClass;

#define BOXES_TYPE_LIBVIRT_MACHINE (boxes_libvirt_machine_get_type ())
#define BOXES_LIBVIRT_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachine))
#define BOXES_LIBVIRT_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachineClass))
#define BOXES_IS_LIBVIRT_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_LIBVIRT_MACHINE))
#define BOXES_IS_LIBVIRT_MACHINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_LIBVIRT_MACHINE))
#define BOXES_LIBVIRT_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_LIBVIRT_MACHINE, BoxesLibvirtMachineClass))

typedef struct _BoxesLibvirtMachine BoxesLibvirtMachine;
typedef struct _BoxesLibvirtMachineClass BoxesLibvirtMachineClass;

#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;
typedef struct _BoxesVMImporterPrivate BoxesVMImporterPrivate;
enum  {
	BOXES_VM_IMPORTER_0_PROPERTY,
	BOXES_VM_IMPORTER_SOURCE_MEDIA_PROPERTY,
	BOXES_VM_IMPORTER_NUM_PROPERTIES
};
static GParamSpec* boxes_vm_importer_properties[BOXES_VM_IMPORTER_NUM_PROPERTIES];

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

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

#define BOXES_TYPE_UI (boxes_ui_get_type ())
#define BOXES_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_UI, BoxesUI))
#define BOXES_IS_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_UI))
#define BOXES_UI_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), BOXES_TYPE_UI, BoxesUIIface))

typedef struct _BoxesUI BoxesUI;
typedef struct _BoxesUIIface BoxesUIIface;
typedef enum  {
	BOXES_UI_STATE_NONE,
	BOXES_UI_STATE_COLLECTION,
	BOXES_UI_STATE_CREDS,
	BOXES_UI_STATE_DISPLAY,
	BOXES_UI_STATE_WIZARD,
	BOXES_UI_STATE_PROPERTIES,
	BOXES_UI_STATE_TROUBLESHOOT
} BoxesUIState;

#define BOXES_TYPE_UI_STATE (boxes_ui_state_get_type ())
typedef struct _BoxesCollectionItemPrivate BoxesCollectionItemPrivate;
typedef struct _BoxesMachinePrivate BoxesMachinePrivate;
typedef enum  {
	BOXES_MACHINE_CONNECT_FLAGS_NONE = 0,
	BOXES_MACHINE_CONNECT_FLAGS_IGNORE_SAVED_STATE = 1 << 0
} BoxesMachineConnectFlags;

#define BOXES_MACHINE_TYPE_CONNECT_FLAGS (boxes_machine_connect_flags_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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 _BoxesVmImporterContinueInstallationData BoxesVmImporterContinueInstallationData;

#define BOXES_TYPE_APP (boxes_app_get_type ())
#define BOXES_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_APP, BoxesApp))
#define BOXES_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_APP, BoxesAppClass))
#define BOXES_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_APP))
#define BOXES_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_APP))
#define BOXES_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_APP, BoxesAppClass))

typedef struct _BoxesApp BoxesApp;
typedef struct _BoxesAppClass BoxesAppClass;

#define BOXES_TYPE_APP_WINDOW (boxes_app_window_get_type ())
#define BOXES_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_APP_WINDOW, BoxesAppWindow))
#define BOXES_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_APP_WINDOW, BoxesAppWindowClass))
#define BOXES_IS_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_APP_WINDOW))
#define BOXES_IS_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_APP_WINDOW))
#define BOXES_APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_APP_WINDOW, BoxesAppWindowClass))

typedef struct _BoxesAppWindow BoxesAppWindow;
typedef struct _BoxesAppWindowClass BoxesAppWindowClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _BoxesVmImporterPostImportSetupData BoxesVmImporterPostImportSetupData;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _BoxesInstallerMediaPrivate BoxesInstallerMediaPrivate;

#define BOXES_TYPE_TOAST (boxes_toast_get_type ())
#define BOXES_TOAST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_TOAST, BoxesToast))
#define BOXES_TOAST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_TOAST, BoxesToastClass))
#define BOXES_IS_TOAST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_TOAST))
#define BOXES_IS_TOAST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_TOAST))
#define BOXES_TOAST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_TOAST, BoxesToastClass))

typedef struct _BoxesToast BoxesToast;
typedef struct _BoxesToastClass BoxesToastClass;
typedef struct _BoxesVmImporterImportVmData BoxesVmImporterImportVmData;

struct _BoxesVMCreator {
	GObject parent_instance;
	BoxesVMCreatorPrivate * priv;
};

struct _BoxesVMCreatorClass {
	GObjectClass parent_class;
	void (*launch_vm) (BoxesVMCreator* self, BoxesLibvirtMachine* machine, gint64 access_last_time, gboolean clone, GError** error);
	void (*continue_installation) (BoxesVMCreator* self, BoxesLibvirtMachine* machine, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*continue_installation_finish) (BoxesVMCreator* self, GAsyncResult* _res_);
	void (*create_domain_config) (BoxesVMCreator* self, const gchar* name, const gchar* title, const gchar* volume_path, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GVirConfigDomain* (*create_domain_config_finish) (BoxesVMCreator* self, GAsyncResult* _res_, GError** error);
	void (*create_domain_base_name_and_title) (BoxesVMCreator* self, gchar** base_name, gchar** base_title);
};

struct _BoxesVMImporter {
	BoxesVMCreator parent_instance;
	BoxesVMImporterPrivate * priv;
	gboolean start_after_import;
};

struct _BoxesVMImporterClass {
	BoxesVMCreatorClass parent_class;
	void (*post_import_setup) (BoxesVMImporter* self, BoxesLibvirtMachine* machine, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*post_import_setup_finish) (BoxesVMImporter* self, GAsyncResult* _res_);
};

struct _BoxesUIIface {
	GTypeInterface parent_iface;
	BoxesUIState (*get_previous_ui_state) (BoxesUI* self);
	void (*set_previous_ui_state) (BoxesUI* self, BoxesUIState value);
	BoxesUIState (*get_ui_state) (BoxesUI* self);
	void (*set_ui_state) (BoxesUI* self, BoxesUIState value);
};

struct _BoxesCollectionItem {
	GObject parent_instance;
	BoxesCollectionItemPrivate * priv;
};

struct _BoxesCollectionItemClass {
	GObjectClass parent_class;
	gint (*compare) (BoxesCollectionItem* self, BoxesCollectionItem* other);
};

struct _BoxesMachine {
	BoxesCollectionItem parent_instance;
	BoxesMachinePrivate * priv;
	BoxesCollectionSource* source;
	BoxesBoxConfig* config;
	gboolean stay_on_display;
};

struct _BoxesMachineClass {
	BoxesCollectionItemClass parent_class;
	void (*save_real) (BoxesMachine* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*save_real_finish) (BoxesMachine* self, GAsyncResult* _res_, GError** error);
	void (*take_screenshot) (BoxesMachine* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GdkPixbuf* (*take_screenshot_finish) (BoxesMachine* self, GAsyncResult* _res_, GError** error);
	void (*connect_display) (BoxesMachine* self, BoxesMachineConnectFlags flags, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*connect_display_finish) (BoxesMachine* self, GAsyncResult* _res_, GError** error);
	void (*restart) (BoxesMachine* self);
	void (*clone) (BoxesMachine* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*clone_finish) (BoxesMachine* self, GAsyncResult* _res_);
	void (*disconnect_display) (BoxesMachine* self);
	void (*update_status) (BoxesMachine* self);
	void (*delete) (BoxesMachine* self, gboolean by_user);
	gboolean (*get_suspend_at_exit) (BoxesMachine* self);
	gboolean (*get_can_save) (BoxesMachine* self);
	gboolean (*get_can_restart) (BoxesMachine* self);
	gboolean (*get_can_clone) (BoxesMachine* self);
	gboolean (*get_should_autosave) (BoxesMachine* self);
	gboolean (*get_is_local) (BoxesMachine* self);
};

struct _BoxesVmImporterContinueInstallationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesVMImporter* self;
	BoxesLibvirtMachine* machine;
	BoxesMediaManager* _tmp0_;
	BoxesMediaManager* _tmp1_;
	GVirConfigDomain* _tmp2_;
	GVirConfigDomain* _tmp3_;
	BoxesInstallerMedia* _tmp4_;
	BoxesInstallerMedia* _tmp5_;
};

struct _BoxesVmImporterPostImportSetupData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesVMImporter* self;
	BoxesLibvirtMachine* machine;
	GVirDomain* _tmp0_;
	GVirDomain* _tmp1_;
	BoxesApp* _tmp2_;
	BoxesAppWindow* _tmp3_;
	BoxesAppWindow* _tmp4_;
	GError* _error_;
	GVirDomain* _tmp5_;
	GVirDomain* _tmp6_;
	const gchar* _tmp7_;
	GError* _tmp8_;
	const gchar* _tmp9_;
	GError* _inner_error0_;
};

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 _BoxesVmImporterImportVmData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BoxesVMImporter* self;
	BoxesLibvirtMachine* machine;
	gchar* destination_path;
	GVirStorageVol* _tmp0_;
	GVirStorageVol* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	BoxesInstalledMedia* _tmp4_;
	BoxesInstalledMedia* _tmp5_;
	const gchar* _tmp6_;
	GVirConnection* _tmp7_;
	GVirConnection* _tmp8_;
	GVirConnection* _tmp9_;
	GVirStoragePool* _tmp10_;
	GVirStoragePool* _tmp11_;
	GError* _error_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	BoxesInstalledMedia* _tmp14_;
	BoxesInstalledMedia* _tmp15_;
	const gchar* _tmp16_;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* message;
	BoxesInstalledMedia* _tmp19_;
	BoxesInstalledMedia* _tmp20_;
	const gchar* _tmp21_;
	GError* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	BoxesApp* _tmp25_;
	BoxesAppWindow* _tmp26_;
	BoxesAppWindow* _tmp27_;
	const gchar* _tmp28_;
	BoxesToast* _tmp29_;
	BoxesToast* _tmp30_;
	GError* _inner_error0_;
};

static gpointer boxes_vm_importer_parent_class = NULL;
VALA_EXTERN BoxesApp* boxes_app_app;

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_collection_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesCollectionItem, g_object_unref)
VALA_EXTERN GType boxes_machine_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesMachine, g_object_unref)
VALA_EXTERN GType boxes_libvirt_machine_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesLibvirtMachine, g_object_unref)
VALA_EXTERN GType boxes_vm_importer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesVMImporter, g_object_unref)
VALA_EXTERN void boxes_vm_creator_launch_vm (BoxesVMCreator* self,
                                 BoxesLibvirtMachine* machine,
                                 gint64 access_last_time,
                                 gboolean clone,
                                 GError** error);
VALA_EXTERN void boxes_vm_creator_continue_installation (BoxesVMCreator* self,
                                             BoxesLibvirtMachine* machine,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN void boxes_vm_creator_continue_installation_finish (BoxesVMCreator* self,
                                                    GAsyncResult* _res_);
VALA_EXTERN void boxes_vm_importer_post_import_setup (BoxesVMImporter* self,
                                          BoxesLibvirtMachine* machine,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN void boxes_vm_importer_post_import_setup_finish (BoxesVMImporter* self,
                                                 GAsyncResult* _res_);
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_installed_media_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesInstalledMedia, g_object_unref)
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 BoxesVMCreator* boxes_vm_creator_new (BoxesInstallerMedia* install_media);
VALA_EXTERN BoxesVMCreator* boxes_vm_creator_construct (GType object_type,
                                            BoxesInstallerMedia* install_media);
VALA_EXTERN BoxesVMImporter* boxes_vm_importer_new_for_import_completion (BoxesLibvirtMachine* machine);
VALA_EXTERN BoxesVMImporter* boxes_vm_importer_construct_for_import_completion (GType object_type,
                                                                    BoxesLibvirtMachine* machine);
VALA_EXTERN BoxesVMCreator* boxes_vm_creator_new_for_install_completion (BoxesLibvirtMachine* machine);
VALA_EXTERN BoxesVMCreator* boxes_vm_creator_construct_for_install_completion (GType object_type,
                                                                   BoxesLibvirtMachine* machine);
static void boxes_vm_importer_real_launch_vm (BoxesVMCreator* base,
                                       BoxesLibvirtMachine* machine,
                                       gint64 access_last_time,
                                       gboolean clone,
                                       GError** error);
VALA_EXTERN void boxes_libvirt_machine_set_vm_creator (BoxesLibvirtMachine* self,
                                           BoxesVMCreator* value);
VALA_EXTERN GType boxes_ui_state_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType boxes_ui_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesUI, g_object_unref)
VALA_EXTERN GType boxes_machine_connect_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BoxesInstalledMedia* boxes_vm_importer_get_source_media (BoxesVMImporter* self);
VALA_EXTERN gboolean boxes_installer_media_get_skip_import (BoxesInstallerMedia* self);
static void boxes_vm_importer_import_vm (BoxesVMImporter* self,
                                  BoxesLibvirtMachine* machine,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
static void boxes_vm_importer_import_vm_finish (BoxesVMImporter* self,
                                         GAsyncResult* _res_);
static void boxes_vm_importer_real_continue_installation_data_free (gpointer _data);
static void boxes_vm_importer_real_continue_installation (BoxesVMCreator* base,
                                                   BoxesLibvirtMachine* machine,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static gboolean boxes_vm_importer_real_continue_installation_co (BoxesVmImporterContinueInstallationData* _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 void boxes_media_manager_create_installer_media_from_config (BoxesMediaManager* self,
                                                             GVirConfigDomain* config,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN BoxesInstallerMedia* boxes_media_manager_create_installer_media_from_config_finish (BoxesMediaManager* self,
                                                                                    GAsyncResult* _res_);
VALA_EXTERN GVirConfigDomain* boxes_libvirt_machine_get_domain_config (BoxesLibvirtMachine* self);
static void boxes_vm_importer_continue_installation_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
VALA_EXTERN void boxes_vm_creator_set_install_media (BoxesVMCreator* self,
                                         BoxesInstallerMedia* value);
static void boxes_vm_importer_real_post_import_setup_data_free (gpointer _data);
static void boxes_vm_importer_real_post_import_setup (BoxesVMImporter* self,
                                               BoxesLibvirtMachine* machine,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean boxes_vm_importer_real_post_import_setup_co (BoxesVmImporterPostImportSetupData* _data_);
VALA_EXTERN void boxes_vm_creator_set_post_install_config (BoxesVMCreator* self,
                                               BoxesLibvirtMachine* machine);
VALA_EXTERN GVirDomain* boxes_libvirt_machine_get_domain (BoxesLibvirtMachine* self);
VALA_EXTERN GType boxes_app_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesApp, g_object_unref)
VALA_EXTERN GType boxes_app_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesAppWindow, g_object_unref)
VALA_EXTERN BoxesAppWindow* boxes_app_get_main_window (BoxesApp* self);
VALA_EXTERN void boxes_app_window_select_item (BoxesAppWindow* self,
                                   BoxesCollectionItem* item);
static void boxes_vm_importer_import_vm_data_free (gpointer _data);
static gboolean boxes_vm_importer_import_vm_co (BoxesVmImporterImportVmData* _data_);
VALA_EXTERN GVirStorageVol* boxes_libvirt_machine_get_storage_volume (BoxesLibvirtMachine* self);
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 void boxes_vm_importer_import_vm_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_);
VALA_EXTERN void boxes_ensure_storage_pool (GVirConnection* connection,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN GVirStoragePool* boxes_ensure_storage_pool_finish (GAsyncResult* _res_,
                                                   GError** error);
VALA_EXTERN GVirConnection* boxes_vm_creator_get_connection (BoxesVMCreator* self);
VALA_EXTERN const gchar* boxes_collection_item_get_name (BoxesCollectionItem* self);
VALA_EXTERN GType boxes_toast_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesToast, g_object_unref)
VALA_EXTERN void boxes_app_window_display_toast (BoxesAppWindow* self,
                                     BoxesToast* toast);
VALA_EXTERN BoxesToast* boxes_toast_new (const gchar* message);
VALA_EXTERN BoxesToast* boxes_toast_construct (GType object_type,
                                   const gchar* message);
VALA_EXTERN void boxes_machine_delete (BoxesMachine* self,
                           gboolean by_user);
VALA_EXTERN BoxesInstallerMedia* boxes_vm_creator_get_install_media (BoxesVMCreator* self);
static void boxes_vm_importer_finalize (GObject * obj);
static GType boxes_vm_importer_get_type_once (void);
static void _vala_boxes_vm_importer_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);

BoxesVMImporter*
boxes_vm_importer_construct (GType object_type,
                             BoxesInstalledMedia* source_media)
{
	BoxesVMImporter * self = NULL;
	g_return_val_if_fail (source_media != NULL, NULL);
	self = (BoxesVMImporter*) boxes_vm_creator_construct (object_type, (BoxesInstallerMedia*) source_media);
	return self;
}

BoxesVMImporter*
boxes_vm_importer_new (BoxesInstalledMedia* source_media)
{
	return boxes_vm_importer_construct (BOXES_TYPE_VM_IMPORTER, source_media);
}

BoxesVMImporter*
boxes_vm_importer_construct_for_import_completion (GType object_type,
                                                   BoxesLibvirtMachine* machine)
{
	BoxesVMImporter * self = NULL;
	g_return_val_if_fail (machine != NULL, NULL);
	self = (BoxesVMImporter*) boxes_vm_creator_construct_for_install_completion (object_type, machine);
	return self;
}

BoxesVMImporter*
boxes_vm_importer_new_for_import_completion (BoxesLibvirtMachine* machine)
{
	return boxes_vm_importer_construct_for_import_completion (BOXES_TYPE_VM_IMPORTER, machine);
}

static void
boxes_vm_importer_real_launch_vm (BoxesVMCreator* base,
                                  BoxesLibvirtMachine* machine,
                                  gint64 access_last_time,
                                  gboolean clone,
                                  GError** error)
{
	BoxesVMImporter * self;
	gint64 _tmp0_ = 0LL;
	BoxesBoxConfig* _tmp1_;
	gboolean _tmp2_ = FALSE;
	self = (BoxesVMImporter*) base;
	g_return_if_fail (machine != NULL);
	boxes_libvirt_machine_set_vm_creator (machine, (BoxesVMCreator*) self);
	if (access_last_time > ((gint64) 0)) {
		_tmp0_ = access_last_time;
	} else {
		_tmp0_ = g_get_real_time ();
	}
	_tmp1_ = ((BoxesMachine*) machine)->config;
	boxes_box_config_set_access_last_time (_tmp1_, _tmp0_);
	if (clone) {
		_tmp2_ = TRUE;
	} else {
		BoxesInstalledMedia* _tmp3_;
		BoxesInstalledMedia* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp3_ = boxes_vm_importer_get_source_media (self);
		_tmp4_ = _tmp3_;
		_tmp5_ = boxes_installer_media_get_skip_import ((BoxesInstallerMedia*) _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = !_tmp6_;
	}
	if (_tmp2_) {
		boxes_vm_importer_import_vm (self, machine, NULL, NULL);
	} else {
		boxes_vm_importer_post_import_setup (self, machine, NULL, NULL);
	}
}

static void
boxes_vm_importer_real_continue_installation_data_free (gpointer _data)
{
	BoxesVmImporterContinueInstallationData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->machine);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesVmImporterContinueInstallationData, _data_);
}

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

static void
boxes_vm_importer_real_continue_installation (BoxesVMCreator* base,
                                              BoxesLibvirtMachine* machine,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	BoxesVMImporter * self;
	BoxesVmImporterContinueInstallationData* _data_;
	BoxesVMImporter* _tmp0_;
	BoxesLibvirtMachine* _tmp1_;
	g_return_if_fail (machine != NULL);
	self = (BoxesVMImporter*) base;
	_data_ = g_slice_new0 (BoxesVmImporterContinueInstallationData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_vm_importer_real_continue_installation_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (machine);
	_g_object_unref0 (_data_->machine);
	_data_->machine = _tmp1_;
	boxes_vm_importer_real_continue_installation_co (_data_);
}

static void
boxes_vm_importer_continue_installation_finish (BoxesVMCreator* base,
                                                GAsyncResult* _res_)
{
	BoxesVmImporterContinueInstallationData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
boxes_vm_importer_continue_installation_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	BoxesVmImporterContinueInstallationData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_vm_importer_real_continue_installation_co (_data_);
}

static gboolean
boxes_vm_importer_real_continue_installation_co (BoxesVmImporterContinueInstallationData* _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_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = boxes_libvirt_machine_get_domain_config (_data_->machine);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_state_ = 1;
	boxes_media_manager_create_installer_media_from_config (_data_->_tmp1_, _data_->_tmp3_, boxes_vm_importer_continue_installation_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp4_ = boxes_media_manager_create_installer_media_from_config_finish (_data_->_tmp1_, _data_->_res_);
	_data_->_tmp5_ = _data_->_tmp4_;
	boxes_vm_creator_set_install_media ((BoxesVMCreator*) _data_->self, _data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp1_);
	boxes_libvirt_machine_set_vm_creator (_data_->machine, (BoxesVMCreator*) _data_->self);
	_data_->_state_ = 2;
	boxes_vm_importer_post_import_setup (_data_->self, _data_->machine, boxes_vm_importer_continue_installation_ready, _data_);
	return FALSE;
	_state_2:
	boxes_vm_importer_post_import_setup_finish (_data_->self, _data_->_res_);
	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_vm_importer_real_post_import_setup_data_free (gpointer _data)
{
	BoxesVmImporterPostImportSetupData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->machine);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesVmImporterPostImportSetupData, _data_);
}

static void
boxes_vm_importer_real_post_import_setup (BoxesVMImporter* self,
                                          BoxesLibvirtMachine* machine,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	BoxesVmImporterPostImportSetupData* _data_;
	BoxesVMImporter* _tmp0_;
	BoxesLibvirtMachine* _tmp1_;
	g_return_if_fail (machine != NULL);
	_data_ = g_slice_new0 (BoxesVmImporterPostImportSetupData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_vm_importer_real_post_import_setup_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (machine);
	_g_object_unref0 (_data_->machine);
	_data_->machine = _tmp1_;
	boxes_vm_importer_real_post_import_setup_co (_data_);
}

static void
boxes_vm_importer_real_post_import_setup_finish (BoxesVMImporter* self,
                                                 GAsyncResult* _res_)
{
	BoxesVmImporterPostImportSetupData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
boxes_vm_importer_real_post_import_setup_co (BoxesVmImporterPostImportSetupData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	boxes_vm_creator_set_post_install_config ((BoxesVMCreator*) _data_->self, _data_->machine);
	if (_data_->self->start_after_import) {
		{
			_data_->_tmp0_ = boxes_libvirt_machine_get_domain (_data_->machine);
			_data_->_tmp1_ = _data_->_tmp0_;
			gvir_domain_start (_data_->_tmp1_, (guint) 0, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp2_ = boxes_app_app;
			_data_->_tmp3_ = boxes_app_get_main_window (_data_->_tmp2_);
			_data_->_tmp4_ = _data_->_tmp3_;
			boxes_app_window_select_item (_data_->_tmp4_, (BoxesCollectionItem*) _data_->machine);
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->_error_ = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp5_ = boxes_libvirt_machine_get_domain (_data_->machine);
			_data_->_tmp6_ = _data_->_tmp5_;
			_data_->_tmp7_ = gvir_domain_get_name (_data_->_tmp6_);
			_data_->_tmp8_ = _data_->_error_;
			_data_->_tmp9_ = _data_->_tmp8_->message;
			g_warning ("vm-importer.vala:45: Failed to start domain '%s': %s", _data_->_tmp7_, _data_->_tmp9_);
			_g_error_free0 (_data_->_error_);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	boxes_libvirt_machine_set_vm_creator (_data_->machine, 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;
}

void
boxes_vm_importer_post_import_setup (BoxesVMImporter* self,
                                     BoxesLibvirtMachine* machine,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	BoxesVMImporterClass* _klass_;
	_klass_ = BOXES_VM_IMPORTER_GET_CLASS (self);
	if (_klass_->post_import_setup) {
		_klass_->post_import_setup (self, machine, _callback_, _user_data_);
	}
}

void
boxes_vm_importer_post_import_setup_finish (BoxesVMImporter* self,
                                            GAsyncResult* _res_)
{
	BoxesVMImporterClass* _klass_;
	_klass_ = BOXES_VM_IMPORTER_GET_CLASS (self);
	if (_klass_->post_import_setup_finish) {
		_klass_->post_import_setup_finish (self, _res_);
	}
}

static void
boxes_vm_importer_import_vm_data_free (gpointer _data)
{
	BoxesVmImporterImportVmData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->machine);
	_g_object_unref0 (_data_->self);
	g_slice_free (BoxesVmImporterImportVmData, _data_);
}

static void
boxes_vm_importer_import_vm (BoxesVMImporter* self,
                             BoxesLibvirtMachine* machine,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	BoxesVmImporterImportVmData* _data_;
	BoxesVMImporter* _tmp0_;
	BoxesLibvirtMachine* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (machine != NULL);
	_data_ = g_slice_new0 (BoxesVmImporterImportVmData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, boxes_vm_importer_import_vm_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (machine);
	_g_object_unref0 (_data_->machine);
	_data_->machine = _tmp1_;
	boxes_vm_importer_import_vm_co (_data_);
}

static void
boxes_vm_importer_import_vm_finish (BoxesVMImporter* self,
                                    GAsyncResult* _res_)
{
	BoxesVmImporterImportVmData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
boxes_vm_importer_import_vm_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_)
{
	BoxesVmImporterImportVmData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	boxes_vm_importer_import_vm_co (_data_);
}

static gboolean
boxes_vm_importer_import_vm_co (BoxesVmImporterImportVmData* _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_libvirt_machine_get_storage_volume (_data_->machine);
		_data_->_tmp1_ = _data_->_tmp0_;
		_data_->_tmp2_ = gvir_storage_vol_get_path (_data_->_tmp1_, &_data_->_inner_error0_);
		_data_->_tmp3_ = g_strdup (_data_->_tmp2_);
		_data_->destination_path = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = boxes_vm_importer_get_source_media (_data_->self);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = _data_->destination_path;
		_data_->_state_ = 1;
		boxes_installed_media_copy (_data_->_tmp5_, _data_->_tmp6_, boxes_vm_importer_import_vm_ready, _data_);
		return FALSE;
		_state_1:
		boxes_installed_media_copy_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->destination_path);
			goto __catch0_g_error;
		}
		_data_->_tmp7_ = boxes_vm_creator_get_connection ((BoxesVMCreator*) _data_->self);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_state_ = 2;
		boxes_ensure_storage_pool (_data_->_tmp9_, boxes_vm_importer_import_vm_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp10_ = boxes_ensure_storage_pool_finish (_data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_g_object_unref0 (_data_->_tmp11_);
		_g_object_unref0 (_data_->_tmp9_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->destination_path);
			goto __catch0_g_error;
		}
		_g_free0 (_data_->destination_path);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp12_ = boxes_collection_item_get_name ((BoxesCollectionItem*) _data_->machine);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = boxes_vm_importer_get_source_media (_data_->self);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = ((BoxesInstallerMedia*) _data_->_tmp15_)->device_file;
		_data_->_tmp17_ = _data_->_error_;
		_data_->_tmp18_ = _data_->_tmp17_->message;
		g_warning ("vm-importer.vala:60: Failed to import box '%s' from file '%s': %s", _data_->_tmp13_, _data_->_tmp16_, _data_->_tmp18_);
		_data_->_tmp19_ = boxes_vm_importer_get_source_media (_data_->self);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = ((BoxesInstallerMedia*) _data_->_tmp20_)->device_file;
		_data_->_tmp22_ = _data_->_error_;
		_data_->_tmp23_ = _data_->_tmp22_->message;
		_data_->_tmp24_ = g_strdup_printf (_ ("Box import from file “%s” failed: %s"), _data_->_tmp21_, _data_->_tmp23_);
		_data_->message = _data_->_tmp24_;
		_data_->_tmp25_ = boxes_app_app;
		_data_->_tmp26_ = boxes_app_get_main_window (_data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		_data_->_tmp28_ = _data_->message;
		_data_->_tmp29_ = boxes_toast_new (_data_->_tmp28_);
		g_object_ref_sink (_data_->_tmp29_);
		_data_->_tmp30_ = _data_->_tmp29_;
		boxes_app_window_display_toast (_data_->_tmp27_, _data_->_tmp30_);
		_g_object_unref0 (_data_->_tmp30_);
		boxes_machine_delete ((BoxesMachine*) _data_->machine, TRUE);
		_g_free0 (_data_->message);
		_g_error_free0 (_data_->_error_);
		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;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_state_ = 3;
	boxes_vm_importer_post_import_setup (_data_->self, _data_->machine, boxes_vm_importer_import_vm_ready, _data_);
	return FALSE;
	_state_3:
	boxes_vm_importer_post_import_setup_finish (_data_->self, _data_->_res_);
	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;
}

BoxesInstalledMedia*
boxes_vm_importer_get_source_media (BoxesVMImporter* self)
{
	BoxesInstalledMedia* result;
	BoxesInstallerMedia* _tmp0_;
	BoxesInstallerMedia* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = boxes_vm_creator_get_install_media ((BoxesVMCreator*) self);
	_tmp1_ = _tmp0_;
	result = BOXES_IS_INSTALLED_MEDIA (_tmp1_) ? ((BoxesInstalledMedia*) _tmp1_) : NULL;
	return result;
}

static void
boxes_vm_importer_class_init (BoxesVMImporterClass * klass,
                              gpointer klass_data)
{
	boxes_vm_importer_parent_class = g_type_class_peek_parent (klass);
	((BoxesVMCreatorClass *) klass)->launch_vm = (void (*) (BoxesVMCreator*, BoxesLibvirtMachine*, gint64, gboolean, GError**)) boxes_vm_importer_real_launch_vm;
	((BoxesVMCreatorClass *) klass)->continue_installation = (void (*) (BoxesVMCreator*, BoxesLibvirtMachine*, GAsyncReadyCallback, gpointer)) boxes_vm_importer_real_continue_installation;
	((BoxesVMCreatorClass *) klass)->continue_installation_finish = (void (*) (BoxesVMCreator*, GAsyncResult*)) boxes_vm_importer_continue_installation_finish;
	((BoxesVMImporterClass *) klass)->post_import_setup = (void (*) (BoxesVMImporter*, BoxesLibvirtMachine*, GAsyncReadyCallback, gpointer)) boxes_vm_importer_real_post_import_setup;
	((BoxesVMImporterClass *) klass)->post_import_setup_finish = (void (*) (BoxesVMImporter*, GAsyncResult*)) boxes_vm_importer_real_post_import_setup_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_vm_importer_get_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_vm_importer_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_VM_IMPORTER_SOURCE_MEDIA_PROPERTY, boxes_vm_importer_properties[BOXES_VM_IMPORTER_SOURCE_MEDIA_PROPERTY] = g_param_spec_object ("source-media", "source-media", "source-media", BOXES_TYPE_INSTALLED_MEDIA, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
boxes_vm_importer_instance_init (BoxesVMImporter * self,
                                 gpointer klass)
{
	self->start_after_import = TRUE;
}

static void
boxes_vm_importer_finalize (GObject * obj)
{
	BoxesVMImporter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_VM_IMPORTER, BoxesVMImporter);
	G_OBJECT_CLASS (boxes_vm_importer_parent_class)->finalize (obj);
}

static GType
boxes_vm_importer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesVMImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_vm_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesVMImporter), 0, (GInstanceInitFunc) boxes_vm_importer_instance_init, NULL };
	GType boxes_vm_importer_type_id;
	boxes_vm_importer_type_id = g_type_register_static (BOXES_TYPE_VM_CREATOR, "BoxesVMImporter", &g_define_type_info, 0);
	return boxes_vm_importer_type_id;
}

GType
boxes_vm_importer_get_type (void)
{
	static volatile gsize boxes_vm_importer_type_id__once = 0;
	if (g_once_init_enter (&boxes_vm_importer_type_id__once)) {
		GType boxes_vm_importer_type_id;
		boxes_vm_importer_type_id = boxes_vm_importer_get_type_once ();
		g_once_init_leave (&boxes_vm_importer_type_id__once, boxes_vm_importer_type_id);
	}
	return boxes_vm_importer_type_id__once;
}

static void
_vala_boxes_vm_importer_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	BoxesVMImporter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_VM_IMPORTER, BoxesVMImporter);
	switch (property_id) {
		case BOXES_VM_IMPORTER_SOURCE_MEDIA_PROPERTY:
		g_value_set_object (value, boxes_vm_importer_get_source_media (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

