[gnome-boxes] installer-media: Add protected architecture property



commit 0b9da1b91d7ecaad61339426ef4ec8bcb74a4391
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Jun 11 23:05:55 2013 +0300

    installer-media: Add protected architecture property
    
    We keep this new property overridable as later we add subclass of
    InstallerMedia that can't get the architecture info from Libosinfo.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690757

 src/installer-media.vala |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index e400905..c687c10 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -34,6 +34,12 @@ private class Boxes.InstallerMedia : GLib.Object {
 
     public bool live { get { return os_media == null || os_media.live; } }
 
+    protected virtual string? architecture {
+        owned get {
+            return (os_media != null)? os_media.architecture : null;
+        }
+    }
+
     public InstallerMedia.from_iso_info (string           path,
                                          string           label,
                                          Os?              os,
@@ -65,7 +71,7 @@ private class Boxes.InstallerMedia : GLib.Object {
         label_setup ();
 
         // FIXME: these values could be made editable somehow
-        var architecture = (os_media != null) ? os_media.architecture : "i686";
+        var architecture = this.architecture ?? "i686";
         resources = media_manager.os_db.get_resources_for_os (os, architecture);
     }
 
@@ -98,10 +104,13 @@ private class Boxes.InstallerMedia : GLib.Object {
     }
 
     public bool is_architecture_compatible (string architecture) {
-        if (os_media == null) // Unknown media
+        if (this.architecture == null)
+            // Architecture unknown, Lets say all architectures are compatible so caller can choose the best 
available
+            // architecture instead. Although this is bound to fail but its still much better than us hard 
coding an
+            // architecture.
             return true;
 
-        var compatibility = compare_cpu_architectures (architecture, os_media.architecture);
+        var compatibility = compare_cpu_architectures (architecture, this.architecture);
 
         return compatibility != CPUArchCompatibility.INCOMPATIBLE;
     }


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