[gnome-boxes/gnome-3-20] spice-display: Special constructor for private connection



commit b007eef1aee3b1408be556881e8b1d7266012ede
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Apr 21 16:56:49 2016 +0100

    spice-display: Special constructor for private connection
    
    If SPICE is not exposed on TCP, we end up with SpiceDisplay constructor
    failing due to port and tls_port both being 0. Let's add a special
    constructor for the case of local private SPICE connection.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738573

 src/libvirt-machine.vala |   12 ++++++++----
 src/spice-display.vala   |    9 +++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index ce72c57..056ac52 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -400,23 +400,27 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     }
 
     private Display? create_display () throws Boxes.Error {
-        string type, port, socket, host;
+        string type, port_str, socket, host;
 
         var xmldoc = domain_config.to_xml ();
         type = extract_xpath (xmldoc, "string(/domain/devices/graphics/@type)", true);
-        port = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@port)");
+        port_str = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@port)");
         socket = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@socket)");
         host = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@listen)");
+        var port = int.parse (port_str);
 
         if (host == null || host == "")
             host = "localhost";
 
         switch (type) {
         case "spice":
-            return new SpiceDisplay (this, config, host, int.parse (port));
+            if (port > 0)
+                return new SpiceDisplay (this, config, host, port);
+            else
+                return new SpiceDisplay.priv (this, config);
 
         case "vnc":
-            return new VncDisplay (config, host, int.parse (port));
+            return new VncDisplay (config, host, port);
 
         default:
             throw new Boxes.Error.INVALID ("unsupported display of type " + type);
diff --git a/src/spice-display.vala b/src/spice-display.vala
index f632352..8e8ab3f 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -133,6 +133,15 @@ private class Boxes.SpiceDisplay: Boxes.Display {
         config.save_properties (gtk_session, gtk_session_saved_properties);
     }
 
+    public SpiceDisplay.priv (Machine machine, BoxConfig config) {
+        this.machine = machine;
+        machine.notify["ui-state"].connect (ui_state_changed);
+
+        this.config = config;
+
+        config.save_properties (gtk_session, gtk_session_saved_properties);
+    }
+
     public override Gtk.Widget get_display (int n) {
         var display = displays.lookup (n) as Spice.Display;
 


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