[Spice-devel] [PATCH spice-gtk 9/9] spicy: deal with spice+unix:// URI

Christophe Fergeau cfergeau at redhat.com
Mon Jan 26 09:42:46 PST 2015


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?
You need to free 'unix_path' when you no longer need it.

Looks good otherwise.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150126/befc4358/attachment-0001.sig>


More information about the Spice-devel mailing list