[Spice-commits] gtk/spicy.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Sat Aug 25 15:18:26 PDT 2012


 gtk/spicy.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 836a18df1fdf1c279cdbd3e18528d3d098615473
Author: Dunrong Huang <riegamaths at gmail.com>
Date:   Sat Aug 25 11:18:36 2012 +0800

    spicy: connect from cli only if hostname and port are provided
    
    This patch will fix following error:
    $ spicy --spice-debug
    ......
    (spicy:21981): GSpice-DEBUG: spice-session.c:1618 new main channel, switching
    (spicy:21981): GSpice-DEBUG: spice-gtk-session.c:811 Changing main channel from (nil) to 0x8534b0
    (spicy:21981): GSpice-DEBUG: spicy.c:1587 new channel (#0)
    (spicy:21981): GSpice-DEBUG: spicy.c:1590 new main channel
    (spicy:21981): GSpice-DEBUG: spice-channel.c:2255 Open coroutine starting 0x8534b0
    (spicy:21981): GSpice-DEBUG: spice-channel.c:2098 Started background coroutine 0x853538 for main-1:0
    (spicy:21981): GSpice-DEBUG: spice-channel.c:2122 connection failed, trying with TLS port
    (spicy:21981): GSpice-DEBUG: spice-channel.c:2126 Connect error
    GSpice-Message: main channel: failed to connect
    ......
    
    When user starts spicy without any command-line arguments, spicy
    should not attempt to connected to server automatically because
    hostname or port are unknown at the moment.
    
    What this patch changes is to show the dialog window instead of
    connecting to server automatically if no hostname or port are found.
    
    Signed-off-by: Dunrong Huang <riegamaths at gmail.com>

diff --git a/gtk/spicy.c b/gtk/spicy.c
index 5510f0c..8b3b087 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1804,6 +1804,7 @@ int main(int argc, char *argv[])
     GOptionContext *context;
     spice_connection *conn;
     gchar *conf_file, *conf;
+    char *host = NULL, *port = NULL, *tls_port = NULL;
 
 #if !GLIB_CHECK_VERSION(2,31,18)
     g_thread_init(NULL);
@@ -1869,8 +1870,25 @@ int main(int argc, char *argv[])
     conn = connection_new();
     spice_set_session_option(conn->session);
     spice_cmdline_session_setup(conn->session);
-    connection_connect(conn);
 
+    g_object_get(conn->session,
+                 "host", &host,
+                 "port", &port,
+                 "tls-port", &tls_port,
+                 NULL);
+    /* If user doesn't provide hostname and port, show the dialog window
+       instead of connecting to server automatically */
+    if (host == NULL || (port == NULL && tls_port == NULL)) {
+        int ret = connect_dialog(conn->session);
+        if (ret != 0) {
+            exit(0);
+        }
+    }
+    g_free(host);
+    g_free(port);
+    g_free(tls_port);
+
+    connection_connect(conn);
     if (connections > 0)
         g_main_loop_run(mainloop);
     g_main_loop_unref(mainloop);


More information about the Spice-commits mailing list