[virt-tools-list] [PATCHv2 virt-viewer 05/10] spice: enable/disable share folder
Marc-André Lureau
marcandre.lureau at gmail.com
Wed Mar 4 18:01:11 UTC 2015
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);
+ 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);
+}
+
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
More information about the virt-tools-list
mailing list