From 27aa8539815ba8b14f4808efdc7887996fce2edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 10 Mar 2021 15:42:06 +0000 Subject: [PATCH] src: add method to test whether a VM action is supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SPICE provides a number of VM actions, but they are only supported if the QMP tunnel is available. VNC doesn't currently support any, but in future it will support some. Signed-off-by: Daniel P. Berrangé --- src/virt-viewer-session.c | 13 +++++++++++++ src/virt-viewer-session.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c index 4171f3d..5d67574 100644 --- a/src/virt-viewer-session.c +++ b/src/virt-viewer-session.c @@ -731,3 +731,16 @@ void virt_viewer_session_vm_action(VirtViewerSession *self, gint action) if (klass->vm_action) klass->vm_action(self, action); } + +gboolean virt_viewer_session_has_vm_action(VirtViewerSession *self, gint action) +{ + VirtViewerSessionClass *klass; + + g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE); + + klass = VIRT_VIEWER_SESSION_GET_CLASS(self); + + if (klass->has_vm_action) + return klass->has_vm_action(self, action); + return FALSE; +} diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h index b772ab1..650bca3 100644 --- a/src/virt-viewer-session.h +++ b/src/virt-viewer-session.h @@ -68,6 +68,7 @@ struct _VirtViewerSessionClass { gboolean (*can_share_folder)(VirtViewerSession *session); gboolean (*can_retry_auth)(VirtViewerSession *session); void (*vm_action)(VirtViewerSession *session, gint action); + gboolean (*has_vm_action)(VirtViewerSession *session, gint action); }; GType virt_viewer_session_get_type(void); @@ -107,3 +108,4 @@ gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self); gboolean virt_viewer_session_can_retry_auth(VirtViewerSession *self); void virt_viewer_session_vm_action(VirtViewerSession *self, gint action); +gboolean virt_viewer_session_has_vm_action(VirtViewerSession *self, gint action);