[gnome-boxes/wip/ostree] tmp



commit 52303ae650686c09eb238f3a01bcd711fea4b7ce
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 12 05:02:26 2013 +0300

    tmp

 src/installed-media.vala |   28 +++++++++++++++++++++++++++-
 src/installer-media.vala |    9 ++++++++-
 src/media-manager.vala   |    4 ++--
 src/os-database.vala     |   11 +++++++++++
 4 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/src/installed-media.vala b/src/installed-media.vala
index e707232..4ffac87 100644
--- a/src/installed-media.vala
+++ b/src/installed-media.vala
@@ -11,10 +11,26 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
                                                    ".vmdk", ".vmdk.gz",
                                                    ".vpc", ".vpc.gz",
                                                    ".cloop", ".cloop.gz" };
+    public const string[] gnome_ostree_devices =
+        { "http://pciids.sourceforge.net/v2.2/pci.ids/1b36/0100";, // QXL graphics
+          "http://pciids.sourceforge.net/v2.2/pci.ids/8086/2415";, // AC97 audio
+          "http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1000";, // virtio-net
+          "http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001";, // virtio-block
+          "http://www.linux-usb.org/usb.ids/80ee/0021"; };         // USB tablet
 
     public override bool need_user_input_for_vm_creation { get { return false; } }
     public override bool ready_to_create { get { return true; } }
     public override bool live { get { return false; } }
+    public override Osinfo.DeviceList supported_devices {
+        owned get {
+            return _supported_devices;
+        }
+
+        protected set {
+            _supported_devices = value;
+        }
+    }
+    private Osinfo.DeviceList _supported_devices;
 
     public string format { get { return device_file.has_suffix (".qcow2")? "qcow2" : "raw"; } }
 
@@ -36,7 +52,7 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
         }
     }
 
-    public InstalledMedia (string path) throws GLib.Error {
+    public async InstalledMedia (string path, MediaManager media_manager) throws GLib.Error {
         var supported = false;
         foreach (var extension in supported_extensions) {
             supported = path.has_suffix (extension);
@@ -52,6 +68,16 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
 
         resources = OSDatabase.get_default_resources ();
         label_setup ();
+
+        supported_devices = new Osinfo.DeviceList ();
+        if (device_file.contains ("gnome-continuous") || device_file.contains ("gnome-ostree")) {
+            var os_db = media_manager.os_db;
+
+            foreach (var id in gnome_ostree_devices) {
+                var device = yield os_db.get_device_by_id (id);
+                supported_devices.add (device);
+            }
+        }
     }
 
     public async void convert_to_native_format (string destination_path) throws GLib.Error {
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 86a8421..868a482 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -15,7 +15,14 @@ private class Boxes.InstallerMedia : GLib.Object {
 
     public virtual Osinfo.DeviceList supported_devices {
         owned get {
-            return (os != null)? os.get_all_devices (null) : new Osinfo.DeviceList ();
+            if (os != null)
+                return os.get_all_devices (null);
+            else
+                return new Osinfo.DeviceList ();
+        }
+
+        // This is unfortunately needed for subclasses to have setter
+        protected set {
         }
     }
 
diff --git a/src/media-manager.vala b/src/media-manager.vala
index ad4f5f1..d38bf1c 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -30,7 +30,7 @@ private class Boxes.MediaManager : Object {
         if (is_mime_type (path, "application/x-cd-image"))
             media = yield new InstallerMedia.for_path (path, this, cancellable);
         else
-            media = new InstalledMedia (path);
+            media = yield new InstalledMedia (path, this);
 
         return create_installer_media_from_media (media);
     }
@@ -42,7 +42,7 @@ private class Boxes.MediaManager : Object {
 
         if (VMConfigurator.is_import_config (config))
             try {
-                return new InstalledMedia (path);
+                return yield new InstalledMedia (path, this);
             } catch (GLib.Error error) {
                 debug ("%s", error.message);
 
diff --git a/src/os-database.vala b/src/os-database.vala
index 57be6c1..5277b44 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -81,6 +81,17 @@ private class Boxes.OSDatabase : GLib.Object {
         return os;
     }
 
+    public async Device get_device_by_id (string id) throws OSDatabaseError {
+        if (!yield ensure_db_loaded ())
+            throw new OSDatabaseError.UNKNOWN_OS_ID ("Unknown device ID '%s'", id);
+
+        var device = db.get_device (id);
+        if (device == null)
+            throw new OSDatabaseError.UNKNOWN_OS_ID ("Unknown device ID '%s'", id);
+
+        return device;
+    }
+
     public Media get_media_by_id (Os os, string id) throws OSDatabaseError {
         var medias = os.get_media_list ();
 


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