[virt-tools-list] [PATCH virt-viewer v2 2/7] Session: add vfunc to check auth retry capability

Jonathon Jongsma jjongsma at redhat.com
Thu Jun 18 20:15:25 UTC 2015


The spice session implementation can retry authentication on its own,
whereas the vnc session needs to tear down the session and re-connect in
order to retry a failed authentication. Add API to determine this so
that we can clean up some code related to authentication failures.
---
 src/virt-viewer-session-spice.c |  7 +++++++
 src/virt-viewer-session.c       | 11 +++++++++++
 src/virt-viewer-session.h       |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 9fe5396..ec6ffa5 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -165,6 +165,12 @@ virt_viewer_session_spice_can_share_folder(VirtViewerSession *session)
     return spice_session_has_channel_type(self->priv->session, SPICE_CHANNEL_WEBDAV);
 }
 
+static gboolean
+virt_viewer_session_spice_can_retry_auth(VirtViewerSession *session G_GNUC_UNUSED)
+{
+    return TRUE;
+}
+
 static void
 virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 {
@@ -186,6 +192,7 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
     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;
+    dclass->can_retry_auth = virt_viewer_session_spice_can_retry_auth;
 
     g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
 
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 131a500..67fa0fd 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -678,6 +678,17 @@ gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self)
     return klass->can_share_folder ? klass->can_share_folder(self) : FALSE;
 }
 
+gboolean virt_viewer_session_can_retry_auth(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_retry_auth ? klass->can_retry_auth(self) : FALSE;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
index 533d79a..ea64bae 100644
--- a/src/virt-viewer-session.h
+++ b/src/virt-viewer-session.h
@@ -96,6 +96,7 @@ struct _VirtViewerSessionClass {
     void (*session_cancelled)(VirtViewerSession *session);
     void (*apply_monitor_geometry)(VirtViewerSession *session, GdkRectangle* monitors, guint nmonitors);
     gboolean (*can_share_folder)(VirtViewerSession *session);
+    gboolean (*can_retry_auth)(VirtViewerSession *session);
 };
 
 GType virt_viewer_session_get_type(void);
@@ -132,6 +133,7 @@ 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);
+gboolean virt_viewer_session_can_retry_auth(VirtViewerSession *self);
 
 G_END_DECLS
 
-- 
2.1.0




More information about the virt-tools-list mailing list