[gnome-boxes] installer: Don't automatically download drivers for all media



commit 5236c822d9bd20e941a4ce9102659d248807d933
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Mar 7 19:03:10 2013 +0200

    installer: Don't automatically download drivers for all media
    
    With this patch, we no longer start to download drivers as part of
    UnattendedInstaller construction but rather do it as part of a new
    general InstallerMedia.prepare method that is called as part of wizard's
    'preparation' stage.
    
    The reason for this change is that us automatically downloading all
    drivers for all ISOs/medias users have, could easily congest a slow
    network. So now we only download drivers for a media/OS when users
    create their first VM against the media/OS in question.
    
    This also fixes the issue of population of wizard's media menu getting
    blocked by driver downloads.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695335

 src/installer-media.vala      |    2 +
 src/media-manager.vala        |   27 ++++-----------------
 src/unattended-installer.vala |   11 ++++----
 src/wizard.vala               |   53 +++++++++++++++++++++--------------------
 4 files changed, 40 insertions(+), 53 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 21ff340..51e9bbe 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -66,6 +66,8 @@ private class Boxes.InstallerMedia : GLib.Object {
     }
 
     public virtual void set_direct_boot_params (DomainOs os) {}
+    public virtual async void prepare (ActivityProgress progress = new ActivityProgress (),
+                                       Cancellable? cancellable = null) {}
     public virtual async void prepare_for_installation (string vm_name, Cancellable? cancellable) throws 
GLib.Error {}
     public virtual void prepare_to_continue_installation (string vm_name) {}
     public virtual void clean_up () {}
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 3eca477..1e9576d 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -23,14 +23,11 @@ private class Boxes.MediaManager : Object {
         return media_manager;
     }
 
-    public async InstallerMedia create_installer_media_for_path
-                                (string               path,
-                                 InstallerRecognized? on_installer_recognized = null,
-                                 ActivityProgress     progress = new ActivityProgress (),
-                                 Cancellable?         cancellable = null) throws GLib.Error {
+    public async InstallerMedia create_installer_media_for_path (string       path,
+                                                                 Cancellable? cancellable = null) throws 
GLib.Error {
         var media = yield new InstallerMedia.for_path (path, this, cancellable);
 
-        return yield create_installer_media_from_media (media, on_installer_recognized, progress);
+        return yield create_installer_media_from_media (media);
     }
 
     public async InstallerMedia? create_installer_media_from_config (GVirConfig.Domain config) {
@@ -124,19 +121,10 @@ private class Boxes.MediaManager : Object {
         return list;
     }
 
-    public async InstallerMedia create_installer_media_from_media
-                                (InstallerMedia       media,
-                                 InstallerRecognized? on_installer_recognized = null,
-                                 ActivityProgress     progress = new ActivityProgress (),
-                                 Cancellable?         cancellable = null) throws GLib.Error {
+    public async InstallerMedia create_installer_media_from_media (InstallerMedia media) throws GLib.Error {
         if (media.os == null)
             return media;
 
-        if (on_installer_recognized != null)
-            on_installer_recognized (media.os_media, media.os);
-
-        progress.progress = 0.5;
-
         var install_scripts = media.os.get_install_script_list ();
         var filter = new Filter ();
         filter.add_constraint (INSTALL_SCRIPT_PROP_PROFILE, INSTALL_SCRIPT_PROFILE_DESKTOP);
@@ -144,15 +132,10 @@ private class Boxes.MediaManager : Object {
 
         InstallerMedia install_media;
         if (install_scripts.get_length () > 0) {
-            var unattended_progress = progress.add_child_activity (0.5);
-            unattended_progress.bind_property ("info", progress, "info");
-
-            install_media = yield new UnattendedInstaller.from_media (media, install_scripts, 
unattended_progress);
+            install_media = yield new UnattendedInstaller.from_media (media, install_scripts);
         } else
             install_media = media;
 
-        progress.progress = 1.0;
-
         return install_media;
     }
 
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 986b5ab..79ea62e 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -99,9 +99,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
         }
     }
 
-    public async UnattendedInstaller.from_media (InstallerMedia    media,
-                                                 InstallScriptList scripts,
-                                                 ActivityProgress  progress) throws GLib.Error {
+    public async UnattendedInstaller.from_media (InstallerMedia media, InstallScriptList scripts) throws 
GLib.Error {
         os = media.os;
         os_media = media.os_media;
         label = media.label;
@@ -131,8 +129,6 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
         product_key_format = get_product_key_format ();
 
         setup_ui ();
-
-        yield setup_drivers (progress);
     }
 
     public override void prepare_to_continue_installation (string vm_name) {
@@ -342,6 +338,11 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
         return get_user_pkgcache (filename);
     }
 
+    public override async void prepare (ActivityProgress progress = new ActivityProgress (),
+                                        Cancellable? cancellable = null) {
+        yield setup_drivers (progress, cancellable);
+    }
+
     private void setup_ui () {
         setup_label = new Gtk.Label (_("Choose express install to automatically preconfigure the box with 
optimal settings."));
         setup_label.wrap = true;
diff --git a/src/wizard.vala b/src/wizard.vala
index 8808346..b5c405f 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -271,33 +271,13 @@ private class Boxes.Wizard: Boxes.UI {
         prep_media_label.label = _("Unknown installer media");
         prep_status_label.label = _("Analyzing..."); // Translators: Analyzing installer media
 
-        var progress = new ActivityProgress ();
-        progress.notify["progress"].connect (() => {
-            if (progress.progress - prep_progress.fraction >= 0.01) // Only entertain >= 1% change
-                prep_progress.fraction = progress.progress;
-        });
-        progress.bind_property ("info", prep_status_label, "label");
-
-        media_manager.create_installer_media_for_path.begin (path,
-                                                             on_installer_recognized,
-                                                             progress,
-                                                             null,
-                                                             on_installer_media_instantiated);
-    }
-
-    private void on_installer_recognized (Osinfo.Media os_media, Osinfo.Os os) {
-        prep_media_label.label = os.name;
-        Downloader.fetch_os_logo.begin (installer_image, os, 128);
+        media_manager.create_installer_media_for_path.begin (path, null, on_installer_media_instantiated);
     }
 
     private void on_installer_media_instantiated (Object? source_object, AsyncResult result) {
-        next_button.sensitive = true;
-
         try {
             var install_media = media_manager.create_installer_media_for_path.end (result);
-            vm_creator = new VMCreator (install_media);
-            prep_progress.fraction = 1.0;
-            page = WizardPage.SETUP;
+            prepare_media.begin (install_media);
         } catch (IOError.CANCELLED cancel_error) { // We did this, so no warning!
         } catch (GLib.Error error) {
             debug("Failed to analyze installer image: %s", error.message);
@@ -306,14 +286,35 @@ private class Boxes.Wizard: Boxes.UI {
         }
     }
 
+    private async void prepare_media (InstallerMedia install_media) {
+        if (install_media.os != null) {
+            prep_media_label.label = install_media.os.name;
+            Downloader.fetch_os_logo.begin (installer_image, install_media.os, 128);
+        }
+
+        var progress = new ActivityProgress ();
+        progress.notify["progress"].connect (() => {
+            if (progress.progress - prep_progress.fraction >= 0.01) // Only entertain >= 1% change
+                prep_progress.fraction = progress.progress;
+        });
+        progress.bind_property ("info", prep_status_label, "label");
+
+        yield install_media.prepare (progress, null);
+
+        vm_creator = new VMCreator (install_media);
+        prep_progress.fraction = 1.0;
+        page = WizardPage.SETUP;
+        next_button.sensitive = true;
+    }
+
     private bool prepare () {
         installer_image.set_from_icon_name ("media-optical", 0); // Reset
 
         if (this.wizard_source.install_media != null) {
-            vm_creator = new VMCreator (this.wizard_source.install_media);
-            prep_progress.fraction = 1.0;
-            page = WizardPage.SETUP;
-            return false;
+            prep_media_label.label = _("Unknown installer media");
+            prep_status_label.label = _("Analyzing...");
+            prepare_media.begin (wizard_source.install_media);
+            return true;
         } else {
             try {
                 prepare_for_location (this.wizard_source.uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]