[Spice-devel] [PATCH spice-gtk 1/2] proxy: initialize proxy at session construct time

Christophe Fergeau cfergeau at redhat.com
Tue Jan 29 02:52:03 PST 2013


Looks good, you moved the code out of a #if GLIB_CHECK_VERSION(2,26,0)
block, this seems ok, but I prefer to mention it.

Christophe

On Mon, Jan 28, 2013 at 09:19:32PM +0100, Marc-André Lureau wrote:
> ---
>  gtk/spice-session-priv.h |  2 ++
>  gtk/spice-session.c      | 40 +++++++++++++++++++++++-----------------
>  2 files changed, 25 insertions(+), 17 deletions(-)
> 
> diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
> index 804658d..7ee6b6c 100644
> --- a/gtk/spice-session-priv.h
> +++ b/gtk/spice-session-priv.h
> @@ -22,6 +22,7 @@
>  #include <gio/gio.h>
>  #include "desktop-integration.h"
>  #include "spice-session.h"
> +#include "spice-proxy.h"
>  #include "spice-gtk-session.h"
>  #include "spice-channel-cache.h"
>  #include "decode.h"
> @@ -44,6 +45,7 @@ struct _SpiceSessionPrivate {
>      char              *cert_subject;
>      guint             verify;
>      gboolean          read_only;
> +    SpiceProxy        *proxy;
>  
>      /* whether to enable audio */
>      gboolean          audio;
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index 0e405bc..5beb6a1 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -118,6 +118,26 @@ enum {
>  static guint signals[SPICE_SESSION_LAST_SIGNAL];
>  
>  
> +static SpiceProxy* get_proxy(void)
> +{
> +    GError *error = NULL;
> +    SpiceProxy *proxy;
> +
> +    const gchar *proxy_env = g_getenv("SPICE_PROXY");
> +    if (proxy_env == NULL || strlen(proxy_env) == 0)
> +        return NULL;
> +
> +    proxy = spice_proxy_new();
> +    if (!spice_proxy_parse(proxy, proxy_env, &error))
> +        g_clear_object(&proxy);
> +    if (error) {
> +        g_warning ("%s", error->message);
> +        g_clear_error (&error);
> +    }
> +
> +    return proxy;
> +}
> +
>  static void spice_session_init(SpiceSession *session)
>  {
>      SpiceSessionPrivate *s;
> @@ -147,6 +167,7 @@ static void spice_session_init(SpiceSession *session)
>      cache_init(&s->images, "image");
>      cache_init(&s->palettes, "palette");
>      s->glz_window = glz_decoder_window_new();
> +    s->proxy = get_proxy();
>  }
>  
>  static void
> @@ -179,6 +200,7 @@ spice_session_dispose(GObject *gobject)
>      g_clear_object(&s->desktop_integration);
>      g_clear_object(&s->gtk_session);
>      g_clear_object(&s->usb_manager);
> +    g_clear_object(&s->proxy);
>  
>      /* Chain up to the parent class */
>      if (G_OBJECT_CLASS(spice_session_parent_class)->dispose)
> @@ -1647,21 +1669,6 @@ static void proxy_lookup_ready(GObject *source_object, GAsyncResult *result,
>      open_host_connectable_connect(open_host, G_SOCKET_CONNECTABLE(address));
>      g_resolver_free_addresses(addresses);
>  }
> -
> -static SpiceProxy* get_proxy(GError **error)
> -{
> -    SpiceProxy *proxy;
> -
> -    const gchar *proxy_env = g_getenv("SPICE_PROXY");
> -    if (proxy_env == NULL || strlen(proxy_env) == 0)
> -        return NULL;
> -
> -    proxy = spice_proxy_new();
> -    if (!spice_proxy_parse(proxy, proxy_env, error))
> -        g_clear_object(&proxy);
> -
> -    return proxy;
> -}
>  #endif
>  
>  /* main context */
> @@ -1674,7 +1681,7 @@ static gboolean open_host_idle_cb(gpointer data)
>      g_return_val_if_fail(open_host->socket == NULL, FALSE);
>  
>  #if GLIB_CHECK_VERSION(2,26,0)
> -    open_host->proxy = get_proxy(&open_host->error);
> +    open_host->proxy = s->proxy;
>      if (open_host->error != NULL) {
>          coroutine_yieldto(open_host->from, NULL);
>          return FALSE;
> @@ -1729,7 +1736,6 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
>      }
>  
>      g_clear_object(&open_host.client);
> -    g_clear_object(&open_host.proxy);
>      return open_host.socket;
>  }
>  
> -- 
> 1.8.1.1.439.g50a6b54
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130129/6637d08c/attachment-0001.pgp>


More information about the Spice-devel mailing list