[virt-tools-list] [PATCH virt-viewer 1/7] session: add virt_viewer_session_mime_type()

Marc-André Lureau marcandre.lureau at gmail.com
Fri Nov 23 12:41:06 UTC 2012


---
 src/virt-viewer-session-spice.c |  7 +++++++
 src/virt-viewer-session-vnc.c   |  6 ++++++
 src/virt-viewer-session.c       | 12 ++++++++++++
 src/virt-viewer-session.h       |  2 ++
 4 files changed, 27 insertions(+)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index b1686c5..3d48ba3 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -123,6 +123,12 @@ virt_viewer_session_spice_dispose(GObject *obj)
 }
 
 
+static const gchar*
+virt_viewer_session_spice_mime_type(VirtViewerSession *self G_GNUC_UNUSED)
+{
+    return "application/x-spice";
+}
+
 static void
 virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 {
@@ -142,6 +148,7 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
     dclass->usb_device_selection = virt_viewer_session_spice_usb_device_selection;
     dclass->smartcard_insert = virt_viewer_session_spice_smartcard_insert;
     dclass->smartcard_remove = virt_viewer_session_spice_smartcard_remove;
+    dclass->mime_type = virt_viewer_session_spice_mime_type;
 
     g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
 
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 52baf5c..3245de3 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -64,6 +64,11 @@ virt_viewer_session_vnc_finalize(GObject *obj)
     G_OBJECT_CLASS(virt_viewer_session_vnc_parent_class)->finalize(obj);
 }
 
+static const gchar*
+virt_viewer_session_vnc_mime_type(VirtViewerSession *self G_GNUC_UNUSED)
+{
+    return "application/x-vnc";
+}
 
 static void
 virt_viewer_session_vnc_class_init(VirtViewerSessionVncClass *klass)
@@ -78,6 +83,7 @@ virt_viewer_session_vnc_class_init(VirtViewerSessionVncClass *klass)
     dclass->open_host = virt_viewer_session_vnc_open_host;
     dclass->open_uri = virt_viewer_session_vnc_open_uri;
     dclass->channel_open_fd = virt_viewer_session_vnc_channel_open_fd;
+    dclass->mime_type = virt_viewer_session_vnc_mime_type;
 
     g_type_class_add_private(klass, sizeof(VirtViewerSessionVncPrivate));
 }
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index a1d96c2..6205e30 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -367,6 +367,18 @@ gboolean virt_viewer_session_open_uri(VirtViewerSession *session, const gchar *u
     return klass->open_uri(session, uri);
 }
 
+const gchar* virt_viewer_session_mime_type(VirtViewerSession *self)
+{
+    VirtViewerSessionClass *klass;
+
+    g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), NULL);
+
+    klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
+    g_return_val_if_fail(klass->mime_type != NULL, FALSE);
+
+    return klass->mime_type(self);
+}
+
 gboolean virt_viewer_session_channel_open_fd(VirtViewerSession *session,
                                              VirtViewerSessionChannel *channel, int fd)
 {
diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
index 38ed988..30def16 100644
--- a/src/virt-viewer-session.h
+++ b/src/virt-viewer-session.h
@@ -73,6 +73,7 @@ struct _VirtViewerSessionClass {
     void (* usb_device_selection) (VirtViewerSession* session, GtkWindow *parent);
     void (* smartcard_insert) (VirtViewerSession* session);
     void (* smartcard_remove) (VirtViewerSession* session);
+    const gchar* (* mime_type) (VirtViewerSession* session);
 
     /* signals */
     void (*session_connected)(VirtViewerSession *session);
@@ -98,6 +99,7 @@ struct _VirtViewerSessionClass {
 GType virt_viewer_session_get_type(void);
 
 GtkWidget *virt_viewer_session_new(void);
+const gchar* virt_viewer_session_mime_type(VirtViewerSession *session);
 
 void virt_viewer_session_add_display(VirtViewerSession *session,
                                      VirtViewerDisplay *display);
-- 
1.7.11.7




More information about the virt-tools-list mailing list