[virt-tools-list] [PATCHv2 virt-viewer 05/10] spice: enable/disable share folder

Fabiano Fidêncio fabiano at fidencio.org
Thu Mar 5 17:30:37 UTC 2015


On Wed, Mar 4, 2015 at 7:01 PM, Marc-André Lureau
<marcandre.lureau at gmail.com> wrote:
> Connect/disconnect webdav channel to enable or disable sharing folder
> ---
>  src/virt-viewer-session-spice.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
> index 4414212..227b02f 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -961,6 +961,30 @@ name_changed(GObject *gobject G_GNUC_UNUSED,
>      g_free(name);
>  }
>
> +static void
> +update_share_folder(VirtViewerSessionSpice *self)
> +{
> +    gboolean share;
> +    SpiceSession *session = self->priv->session;
> +
> +    g_object_get(self, "share-folder", &share, NULL);
> +
> +    GList *l, *channels = spice_session_get_channels(session);

Declare the GLists in the beginning of the function (before the
g_object_get()) ...

> +    for (l = channels; l != NULL; l = l->next) {
> +        SpiceChannel *channel = l->data;
> +
> +        if (!SPICE_IS_WEBDAV_CHANNEL(channel))
> +            continue;
> +
> +        if (share)
> +            spice_channel_connect(channel);
> +        else
> +            spice_channel_disconnect(channel, SPICE_CHANNEL_NONE);
> +    }
> +
> +    g_list_free(l);

You should g_list_free() the channels list and the l one.

> +}
> +
>  VirtViewerSession *
>  virt_viewer_session_spice_new(VirtViewerApp *app, GtkWindow *main_window)
>  {
> @@ -980,6 +1004,9 @@ virt_viewer_session_spice_new(VirtViewerApp *app, GtkWindow *main_window)
>                                        G_CALLBACK(uuid_changed), self, 0);
>      virt_viewer_signal_connect_object(self->priv->session, "notify::name",
>                                        G_CALLBACK(name_changed), self, 0);
> +    virt_viewer_signal_connect_object(self, "notify::share-folder",
> +                                      G_CALLBACK(update_share_folder), self,
> +                                      G_CONNECT_SWAPPED);
>
>      g_object_bind_property(self->priv->session, "shared-dir",
>                             self, "shared-folder",
> --
> 2.1.0
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list



-- 
Fabiano Fidêncio




More information about the virt-tools-list mailing list