[Spice-devel] [PATCH spice-gtk 9/9] spicy: deal with spice+unix:// URI
Marc-André Lureau
mlureau at redhat.com
Mon Jan 26 09:46:11 PST 2015
----- Original Message -----
> On Tue, Jan 13, 2015 at 05:38:28PM +0100, Marc-André Lureau wrote:
> > ---
> > gtk/spicy.c | 15 ++++++++++-----
> > 1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/gtk/spicy.c b/gtk/spicy.c
> > index 2fcd529..4c7d2c8 100644
> > --- a/gtk/spicy.c
> > +++ b/gtk/spicy.c
> > @@ -1193,10 +1193,14 @@ static void recent_add(SpiceSession *session)
> > g_object_get(session, "uri", &uri, NULL);
> > SPICE_DEBUG("%s: %s", __FUNCTION__, uri);
> >
> > - g_return_if_fail(g_str_has_prefix(uri, "spice://"));
> > -
> > recent = gtk_recent_manager_get_default();
> > - meta.display_name = uri + 8;
> > + if (g_str_has_prefix(uri, "spice://"))
> > + meta.display_name = uri + 8;
> > + else if (g_str_has_prefix(uri, "spice+unix://"))
> > + meta.display_name = uri + 13;
> > + else
> > + g_return_if_reached();
> > +
> > if (!gtk_recent_manager_add_full(recent, uri, &meta))
> > g_warning("Recent item couldn't be added successfully");
> >
> > @@ -1788,7 +1792,7 @@ int main(int argc, char *argv[])
> > GOptionContext *context;
> > spice_connection *conn;
> > gchar *conf_file, *conf;
> > - char *host = NULL, *port = NULL, *tls_port = NULL;
> > + char *host = NULL, *port = NULL, *tls_port = NULL, *unix_path = NULL;
> >
> > #if !GLIB_CHECK_VERSION(2,31,18)
> > g_thread_init(NULL);
> > @@ -1853,13 +1857,14 @@ int main(int argc, char *argv[])
> > spice_cmdline_session_setup(conn->session);
> >
> > g_object_get(conn->session,
> > + "unix-path", &unix_path,
> > "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)) {
> > + if (host == NULL && unix_path == NULL) {
>
> Did you intentionally drop the port/tls_port test?
No, I guess I should write:
if ((host == NULL || (port == NULL && tls_port == NULL) && unix_path == NULL)
> You need to free 'unix_path' when you no longer need it.
right
> Looks good otherwise.
>
> Christophe
>
More information about the Spice-devel
mailing list