[Spice-devel] [spice-gtk PATCH] spicy.c: Don't attempt to connect automatically if hostname and port are not provided
riegamaths at gmail.com
riegamaths at gmail.com
Fri Aug 24 02:48:39 PDT 2012
From: Dunrong Huang <riegamaths at gmail.com>
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>
---
gtk/spicy.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/gtk/spicy.c b/gtk/spicy.c
index 5510f0c..ce788e5 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,20 @@ 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, NULL);
+ g_object_get(conn->session, "port", &port, NULL);
+ g_object_get(conn->session, "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);
+ }
+ }
+ connection_connect(conn);
if (connections > 0)
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);
--
1.7.8.6
More information about the Spice-devel
mailing list