summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDunrong Huang <riegamaths@gmail.com>2012-08-25 11:18:36 +0800
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-08-26 00:15:44 +0200
commit836a18df1fdf1c279cdbd3e18528d3d098615473 (patch)
tree3274ff56a4f6f73b8cd43520a659bfc2735e153a
parent82c367bdd543a01fa2f7f39113f51272f4f7a9e0 (diff)
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@gmail.com>
-rw-r--r--gtk/spicy.c20
1 files changed, 19 insertions, 1 deletions
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);