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

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <libvirt-gconfig/libvirt-gconfig.h>
#include <gio/gio.h>
#include "common.h"
#include <stdlib.h>
#include <string.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_ASSISTANT_MEDIA_ENTRY (boxes_assistant_media_entry_get_type ())
#define BOXES_ASSISTANT_MEDIA_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntry))
#define BOXES_ASSISTANT_MEDIA_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntryClass))
#define BOXES_IS_ASSISTANT_MEDIA_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY))
#define BOXES_IS_ASSISTANT_MEDIA_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY))
#define BOXES_ASSISTANT_MEDIA_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntryClass))

typedef struct _BoxesAssistantMediaEntry BoxesAssistantMediaEntry;
typedef struct _BoxesAssistantMediaEntryClass BoxesAssistantMediaEntryClass;
typedef struct _BoxesAssistantMediaEntryPrivate BoxesAssistantMediaEntryPrivate;

#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;
enum  {
	BOXES_ASSISTANT_MEDIA_ENTRY_0_PROPERTY,
	BOXES_ASSISTANT_MEDIA_ENTRY_NUM_PROPERTIES
};
static GParamSpec* boxes_assistant_media_entry_properties[BOXES_ASSISTANT_MEDIA_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _BoxesInstallerMediaPrivate BoxesInstallerMediaPrivate;

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

typedef struct _BoxesVMCreator BoxesVMCreator;
typedef struct _BoxesVMCreatorClass BoxesVMCreatorClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BoxesAssistantMediaEntry {
	HdyActionRow parent_instance;
	BoxesAssistantMediaEntryPrivate * priv;
	BoxesInstallerMedia* media;
	GtkImage* media_image;
};

struct _BoxesAssistantMediaEntryClass {
	HdyActionRowClass parent_class;
};

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);
};

static gpointer boxes_assistant_media_entry_parent_class = NULL;

VALA_EXTERN GType boxes_assistant_media_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesAssistantMediaEntry, g_object_unref)
VALA_EXTERN GType boxes_installer_media_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesInstallerMedia, g_object_unref)
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_new_from_installer_media (BoxesInstallerMedia* media);
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_construct_from_installer_media (GType object_type,
                                                                                      BoxesInstallerMedia* media);
VALA_EXTERN GType boxes_vm_creator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesVMCreator, g_object_unref)
VALA_EXTERN void boxes_downloader_fetch_os_logo (GtkImage* image,
                                     OsinfoOs* os,
                                     gint size,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void boxes_downloader_fetch_os_logo_finish (GAsyncResult* _res_);
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_new (void);
VALA_EXTERN BoxesAssistantMediaEntry* boxes_assistant_media_entry_construct (GType object_type);
static void boxes_assistant_media_entry_finalize (GObject * obj);
static GType boxes_assistant_media_entry_get_type_once (void);

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

BoxesAssistantMediaEntry*
boxes_assistant_media_entry_construct_from_installer_media (GType object_type,
                                                            BoxesInstallerMedia* media)
{
	BoxesAssistantMediaEntry * self = NULL;
	BoxesInstallerMedia* _tmp0_;
	OsinfoOs* _tmp1_;
	const gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	OsinfoMedia* _tmp6_;
	const gchar* _tmp18_;
	OsinfoMedia* _tmp19_;
	g_return_val_if_fail (media != NULL, NULL);
	self = (BoxesAssistantMediaEntry*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (media);
	_g_object_unref0 (self->media);
	self->media = _tmp0_;
	_tmp1_ = media->os;
	if (_tmp1_ != NULL) {
		GtkImage* _tmp2_;
		OsinfoOs* _tmp3_;
		_tmp2_ = self->media_image;
		_tmp3_ = media->os;
		boxes_downloader_fetch_os_logo (_tmp2_, _tmp3_, 64, NULL, NULL);
	}
	_tmp4_ = media->label;
	hdy_preferences_row_set_title ((HdyPreferencesRow*) self, _tmp4_);
	_tmp6_ = media->os_media;
	if (_tmp6_ != NULL) {
		OsinfoMedia* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = media->os_media;
		g_object_get (_tmp7_, "live", &_tmp8_, NULL);
		_tmp9_ = _tmp8_;
		_tmp5_ = _tmp9_;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		_tmp10_ = hdy_preferences_row_get_title ((HdyPreferencesRow*) self);
		_tmp11_ = _tmp10_;
		_tmp12_ = g_strconcat (" (", _ ("Live"), NULL);
		_tmp13_ = _tmp12_;
		_tmp14_ = g_strconcat (_tmp13_, ")", NULL);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strconcat (_tmp11_, _tmp15_, NULL);
		_tmp17_ = _tmp16_;
		hdy_preferences_row_set_title ((HdyPreferencesRow*) self, _tmp17_);
		_g_free0 (_tmp17_);
		_g_free0 (_tmp15_);
		_g_free0 (_tmp13_);
	}
	_tmp18_ = media->device_file;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp18_);
	_tmp19_ = media->os_media;
	if (_tmp19_ != NULL) {
		const gchar* _tmp20_ = NULL;
		gboolean _tmp21_ = FALSE;
		OsinfoMedia* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gboolean _tmp26_;
		gchar* architecture = NULL;
		gchar* _tmp31_;
		const gchar* _tmp32_;
		OsinfoOs* _tmp33_;
		const gchar* _tmp34_;
		const gchar* _tmp35_;
		_tmp22_ = media->os_media;
		g_object_get (_tmp22_, "architecture", &_tmp23_, NULL);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strcmp0 (_tmp25_, "i386") == 0;
		_g_free0 (_tmp25_);
		if (_tmp26_) {
			_tmp21_ = TRUE;
		} else {
			OsinfoMedia* _tmp27_;
			gchar* _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
			_tmp27_ = media->os_media;
			g_object_get (_tmp27_, "architecture", &_tmp28_, NULL);
			_tmp29_ = _tmp28_;
			_tmp30_ = _tmp29_;
			_tmp21_ = g_strcmp0 (_tmp30_, "i686") == 0;
			_g_free0 (_tmp30_);
		}
		if (_tmp21_) {
			_tmp20_ = _ ("32-bit x86 system");
		} else {
			_tmp20_ = _ ("64-bit x86 system");
		}
		_tmp31_ = g_strdup (_tmp20_);
		architecture = _tmp31_;
		_tmp32_ = architecture;
		hdy_action_row_set_subtitle ((HdyActionRow*) self, _tmp32_);
		_tmp33_ = media->os;
		_tmp34_ = osinfo_product_get_vendor ((OsinfoProduct*) _tmp33_);
		_tmp35_ = _tmp34_;
		if (_tmp35_ != NULL) {
			const gchar* _tmp36_;
			const gchar* _tmp37_;
			OsinfoOs* _tmp38_;
			const gchar* _tmp39_;
			const gchar* _tmp40_;
			gchar* _tmp41_;
			gchar* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			_tmp36_ = hdy_action_row_get_subtitle ((HdyActionRow*) self);
			_tmp37_ = _tmp36_;
			_tmp38_ = media->os;
			_tmp39_ = osinfo_product_get_vendor ((OsinfoProduct*) _tmp38_);
			_tmp40_ = _tmp39_;
			_tmp41_ = g_strdup_printf (_ (" from %s"), _tmp40_);
			_tmp42_ = _tmp41_;
			_tmp43_ = g_strconcat (_tmp37_, _tmp42_, NULL);
			_tmp44_ = _tmp43_;
			hdy_action_row_set_subtitle ((HdyActionRow*) self, _tmp44_);
			_g_free0 (_tmp44_);
			_g_free0 (_tmp42_);
		}
		_g_free0 (architecture);
	}
	return self;
}

BoxesAssistantMediaEntry*
boxes_assistant_media_entry_new_from_installer_media (BoxesInstallerMedia* media)
{
	return boxes_assistant_media_entry_construct_from_installer_media (BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, media);
}

BoxesAssistantMediaEntry*
boxes_assistant_media_entry_construct (GType object_type)
{
	BoxesAssistantMediaEntry * self = NULL;
	self = (BoxesAssistantMediaEntry*) g_object_new (object_type, NULL);
	return self;
}

BoxesAssistantMediaEntry*
boxes_assistant_media_entry_new (void)
{
	return boxes_assistant_media_entry_construct (BOXES_TYPE_ASSISTANT_MEDIA_ENTRY);
}

static void
boxes_assistant_media_entry_class_init (BoxesAssistantMediaEntryClass * klass,
                                        gpointer klass_data)
{
	boxes_assistant_media_entry_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = boxes_assistant_media_entry_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/assistant/media-entry.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "media_image", FALSE, G_STRUCT_OFFSET (BoxesAssistantMediaEntry, media_image));
}

static void
boxes_assistant_media_entry_instance_init (BoxesAssistantMediaEntry * self,
                                           gpointer klass)
{
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_assistant_media_entry_finalize (GObject * obj)
{
	BoxesAssistantMediaEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_ASSISTANT_MEDIA_ENTRY, BoxesAssistantMediaEntry);
	_g_object_unref0 (self->media);
	G_OBJECT_CLASS (boxes_assistant_media_entry_parent_class)->finalize (obj);
}

static GType
boxes_assistant_media_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesAssistantMediaEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_assistant_media_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesAssistantMediaEntry), 0, (GInstanceInitFunc) boxes_assistant_media_entry_instance_init, NULL };
	GType boxes_assistant_media_entry_type_id;
	boxes_assistant_media_entry_type_id = g_type_register_static (hdy_action_row_get_type (), "BoxesAssistantMediaEntry", &g_define_type_info, 0);
	return boxes_assistant_media_entry_type_id;
}

GType
boxes_assistant_media_entry_get_type (void)
{
	static volatile gsize boxes_assistant_media_entry_type_id__once = 0;
	if (g_once_init_enter (&boxes_assistant_media_entry_type_id__once)) {
		GType boxes_assistant_media_entry_type_id;
		boxes_assistant_media_entry_type_id = boxes_assistant_media_entry_get_type_once ();
		g_once_init_leave (&boxes_assistant_media_entry_type_id__once, boxes_assistant_media_entry_type_id);
	}
	return boxes_assistant_media_entry_type_id__once;
}

