[virt-tools-list] [PATCHv2 virt-viewer 09/10] Add virt_viewer_session_can_share_folder()

Marc-André Lureau marcandre.lureau at gmail.com
Wed Mar 4 18:01:15 UTC 2015


Functions name says it all, it is only implement for Spice, checking
for webdav channel presence.
---
 src/virt-viewer-session-spice.c |  9 +++++++++
 src/virt-viewer-session.c       | 11 +++++++++++
 src/virt-viewer-session.h       |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 227b02f..c177059 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -145,6 +145,14 @@ virt_viewer_session_spice_mime_type(VirtViewerSession *self G_GNUC_UNUSED)
     return "application/x-spice";
 }
 
+static gboolean
+virt_viewer_session_spice_can_share_folder(VirtViewerSession *session)
+{
+    VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
+
+    return spice_session_has_channel_type(self->priv->session, SPICE_CHANNEL_WEBDAV);
+}
+
 static void
 virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 {
@@ -165,6 +173,7 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
     dclass->smartcard_remove = virt_viewer_session_spice_smartcard_remove;
     dclass->mime_type = virt_viewer_session_spice_mime_type;
     dclass->apply_monitor_geometry = virt_viewer_session_spice_apply_monitor_geometry;
+    dclass->can_share_folder = virt_viewer_session_spice_can_share_folder;
 
     g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
 
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index e4b05ab..131a500 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -667,6 +667,17 @@ VirtViewerFile* virt_viewer_session_get_file(VirtViewerSession *self)
     return self->priv->file;
 }
 
+gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self)
+{
+    VirtViewerSessionClass *klass;
+
+    g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
+
+    klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
+
+    return klass->can_share_folder ? klass->can_share_folder(self) : FALSE;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
index ba0f6b2..533d79a 100644
--- a/src/virt-viewer-session.h
+++ b/src/virt-viewer-session.h
@@ -95,6 +95,7 @@ struct _VirtViewerSessionClass {
     void (*session_bell)(VirtViewerSession *session);
     void (*session_cancelled)(VirtViewerSession *session);
     void (*apply_monitor_geometry)(VirtViewerSession *session, GdkRectangle* monitors, guint nmonitors);
+    gboolean (*can_share_folder)(VirtViewerSession *session);
 };
 
 GType virt_viewer_session_get_type(void);
@@ -130,6 +131,7 @@ VirtViewerApp* virt_viewer_session_get_app(VirtViewerSession *self);
 gchar* virt_viewer_session_get_uri(VirtViewerSession *self);
 void virt_viewer_session_set_file(VirtViewerSession *self, VirtViewerFile *file);
 VirtViewerFile* virt_viewer_session_get_file(VirtViewerSession *self);
+gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self);
 
 G_END_DECLS
 
-- 
2.1.0




More information about the virt-tools-list mailing list