[gnome-boxes] remote-machine: verify the kind of remote is known



commit f36f5234a926f07017eb5297d262e496f90ec8df
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Oct 29 12:37:12 2012 +0100

    remote-machine: verify the kind of remote is known
    
    Warn only in the console if not, this is a programming error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684233

 src/app.vala            |    8 ++++++--
 src/remote-machine.vala |    6 +++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index afa2659..737cc9f 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -312,8 +312,12 @@ private class Boxes.App: Boxes.UI {
 
         case "vnc":
         case "spice":
-            var machine = new RemoteMachine (source);
-            collection.add_item (machine);
+            try {
+                var machine = new RemoteMachine (source);
+                collection.add_item (machine);
+            } catch (Boxes.Error error) {
+                warning (error.message);
+            }
             break;
 
         default:
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index b56a94f..1b4e6b9 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -3,7 +3,11 @@ using Gtk;
 
 private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
 
-    public RemoteMachine (CollectionSource source) {
+    public RemoteMachine (CollectionSource source) throws Boxes.Error {
+        if (source.source_type != "spice" &&
+            source.source_type != "vnc")
+            throw new Boxes.Error.INVALID ("source is not remote machine: %s", source.uri);
+
         base (source, source.name);
 
         // assume the remote is running for now



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