|
|
4a6991 |
From 866c00a73e802f8ebc347f4986d3a4044a93bc24 Mon Sep 17 00:00:00 2001
|
|
|
4a6991 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
|
|
|
4a6991 |
Date: Mon, 15 Jul 2013 20:52:15 +0200
|
|
|
4a6991 |
Subject: [PATCH] kiosk: add --kiosk-quit option
|
|
|
4a6991 |
|
|
|
4a6991 |
In kiosk mode, it's useful to keep the app alive, even if the remote
|
|
|
4a6991 |
session ended for example. Ie, we want to prevent the app from quiting
|
|
|
4a6991 |
itself, even if the remote end closed, lost network, or crashed etc.
|
|
|
4a6991 |
|
|
|
4a6991 |
(cherry picked from commit 91928798e45cd848585f33c269b4699cb26d8f1f)
|
|
|
4a6991 |
https://bugzilla.redhat.com/show_bug.cgi?id=1040926
|
|
|
4a6991 |
---
|
|
|
4a6991 |
man/remote-viewer.pod | 7 +++++++
|
|
|
4a6991 |
man/virt-viewer.pod | 8 ++++++++
|
|
|
4a6991 |
src/virt-viewer-app.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
|
|
|
4a6991 |
3 files changed, 58 insertions(+), 1 deletion(-)
|
|
|
4a6991 |
|
|
|
4a6991 |
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
|
|
|
4a6991 |
index 10fda2c..079def0 100644
|
|
|
4a6991 |
--- a/man/remote-viewer.pod
|
|
|
4a6991 |
+++ b/man/remote-viewer.pod
|
|
|
4a6991 |
@@ -90,6 +90,13 @@ to lock down the OS. In particular, you must configure or disable the
|
|
|
4a6991 |
window manager, limit the session capabilities, use some
|
|
|
4a6991 |
restart/watchdog mechanism, disable VT switching etc.
|
|
|
4a6991 |
|
|
|
4a6991 |
+=item --kiosk-quit <never|on-disconnect>
|
|
|
4a6991 |
+
|
|
|
4a6991 |
+By default, when kiosk mode is enabled, virt-viewer will remain open
|
|
|
4a6991 |
+when the connection to the remote server is terminated. By setting
|
|
|
4a6991 |
+kiosk-quit option to "on-disconnect" value, virt-viewer will quit
|
|
|
4a6991 |
+instead.
|
|
|
4a6991 |
+
|
|
|
4a6991 |
=back
|
|
|
4a6991 |
|
|
|
4a6991 |
=head1 HOTKEY
|
|
|
4a6991 |
diff --git a/man/virt-viewer.pod b/man/virt-viewer.pod
|
|
|
4a6991 |
index 9d0597a..fdaa631 100644
|
|
|
4a6991 |
--- a/man/virt-viewer.pod
|
|
|
4a6991 |
+++ b/man/virt-viewer.pod
|
|
|
4a6991 |
@@ -99,6 +99,14 @@ to lock down the OS. In particular, you must configure or disable the
|
|
|
4a6991 |
window manager, limit the session capabilities, use some
|
|
|
4a6991 |
restart/watchdog mechanism, disable VT switching etc.
|
|
|
4a6991 |
|
|
|
4a6991 |
+=item --kiosk-quit <never|on-disconnect>
|
|
|
4a6991 |
+
|
|
|
4a6991 |
+By default, when kiosk mode is enabled, virt-viewer will remain open
|
|
|
4a6991 |
+when the connection to the remote server is terminated. By setting
|
|
|
4a6991 |
+kiosk-quit option to "on-disconnect" value, virt-viewer will quit
|
|
|
4a6991 |
+instead. Please note that --reconnect takes precedence over this
|
|
|
4a6991 |
+option, and will attempt to do a reconnection before it quits.
|
|
|
4a6991 |
+
|
|
|
4a6991 |
=back
|
|
|
4a6991 |
|
|
|
4a6991 |
=head1 EXAMPLES
|
|
|
4a6991 |
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
|
|
|
4a6991 |
index 6ebff3e..f8c5117 100644
|
|
|
4a6991 |
--- a/src/virt-viewer-app.c
|
|
|
4a6991 |
+++ b/src/virt-viewer-app.c
|
|
|
4a6991 |
@@ -148,6 +148,7 @@ struct _VirtViewerAppPrivate {
|
|
|
4a6991 |
GdkModifierType insert_smartcard_accel_mods;
|
|
|
4a6991 |
guint remove_smartcard_accel_key;
|
|
|
4a6991 |
GdkModifierType remove_smartcard_accel_mods;
|
|
|
4a6991 |
+ gboolean quit_on_disconnect;
|
|
|
4a6991 |
};
|
|
|
4a6991 |
|
|
|
4a6991 |
|
|
|
4a6991 |
@@ -167,6 +168,7 @@ enum {
|
|
|
4a6991 |
PROP_HAS_FOCUS,
|
|
|
4a6991 |
PROP_FULLSCREEN_AUTO_CONF,
|
|
|
4a6991 |
PROP_KIOSK,
|
|
|
4a6991 |
+ PROP_QUIT_ON_DISCONNECT,
|
|
|
4a6991 |
};
|
|
|
4a6991 |
|
|
|
4a6991 |
enum {
|
|
|
4a6991 |
@@ -1130,7 +1132,8 @@ virt_viewer_app_default_deactivated(VirtViewerApp *self, gboolean connect_error)
|
|
|
4a6991 |
priv->guest_name);
|
|
|
4a6991 |
}
|
|
|
4a6991 |
|
|
|
4a6991 |
- gtk_main_quit();
|
|
|
4a6991 |
+ if (self->priv->quit_on_disconnect)
|
|
|
4a6991 |
+ gtk_main_quit();
|
|
|
4a6991 |
}
|
|
|
4a6991 |
|
|
|
4a6991 |
static void
|
|
|
4a6991 |
@@ -1339,6 +1342,10 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
|
|
|
4a6991 |
g_value_set_boolean(value, priv->kiosk);
|
|
|
4a6991 |
break;
|
|
|
4a6991 |
|
|
|
4a6991 |
+ case PROP_QUIT_ON_DISCONNECT:
|
|
|
4a6991 |
+ g_value_set_boolean(value, priv->quit_on_disconnect);
|
|
|
4a6991 |
+ break;
|
|
|
4a6991 |
+
|
|
|
4a6991 |
default:
|
|
|
4a6991 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
4a6991 |
}
|
|
|
4a6991 |
@@ -1388,6 +1395,10 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
|
|
|
4a6991 |
virt_viewer_app_set_kiosk(self, g_value_get_boolean(value));
|
|
|
4a6991 |
break;
|
|
|
4a6991 |
|
|
|
4a6991 |
+ case PROP_QUIT_ON_DISCONNECT:
|
|
|
4a6991 |
+ priv->quit_on_disconnect = g_value_get_boolean(value);
|
|
|
4a6991 |
+ break;
|
|
|
4a6991 |
+
|
|
|
4a6991 |
default:
|
|
|
4a6991 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
4a6991 |
}
|
|
|
4a6991 |
@@ -1456,6 +1467,7 @@ static gboolean opt_debug = FALSE;
|
|
|
4a6991 |
static gboolean opt_fullscreen = FALSE;
|
|
|
4a6991 |
static gboolean opt_fullscreen_auto_conf = FALSE;
|
|
|
4a6991 |
static gboolean opt_kiosk = FALSE;
|
|
|
4a6991 |
+static gboolean opt_kiosk_quit = FALSE;
|
|
|
4a6991 |
|
|
|
4a6991 |
static void
|
|
|
4a6991 |
virt_viewer_app_init (VirtViewerApp *self)
|
|
|
4a6991 |
@@ -1485,6 +1497,7 @@ virt_viewer_app_init (VirtViewerApp *self)
|
|
|
4a6991 |
|
|
|
4a6991 |
self->priv->verbose = opt_verbose;
|
|
|
4a6991 |
self->priv->fullscreen_auto_conf = opt_fullscreen_auto_conf;
|
|
|
4a6991 |
+ self->priv->quit_on_disconnect = opt_kiosk ? opt_kiosk_quit : TRUE;
|
|
|
4a6991 |
}
|
|
|
4a6991 |
|
|
|
4a6991 |
static void
|
|
|
4a6991 |
@@ -1682,6 +1695,15 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
|
|
|
4a6991 |
G_PARAM_READWRITE |
|
|
|
4a6991 |
G_PARAM_STATIC_STRINGS));
|
|
|
4a6991 |
|
|
|
4a6991 |
+ g_object_class_install_property(object_class,
|
|
|
4a6991 |
+ PROP_QUIT_ON_DISCONNECT,
|
|
|
4a6991 |
+ g_param_spec_boolean("quit-on-disconnect",
|
|
|
4a6991 |
+ "Quit on disconnect",
|
|
|
4a6991 |
+ "Quit on disconnect",
|
|
|
4a6991 |
+ TRUE,
|
|
|
4a6991 |
+ G_PARAM_READWRITE |
|
|
|
4a6991 |
+ G_PARAM_STATIC_STRINGS));
|
|
|
4a6991 |
+
|
|
|
4a6991 |
signals[SIGNAL_WINDOW_ADDED] =
|
|
|
4a6991 |
g_signal_new("window-added",
|
|
|
4a6991 |
G_OBJECT_CLASS_TYPE(object_class),
|
|
|
4a6991 |
@@ -2149,6 +2171,24 @@ option_fullscreen(G_GNUC_UNUSED const gchar *option_name,
|
|
|
4a6991 |
return FALSE;
|
|
|
4a6991 |
}
|
|
|
4a6991 |
|
|
|
4a6991 |
+static gboolean
|
|
|
4a6991 |
+option_kiosk_quit(G_GNUC_UNUSED const gchar *option_name,
|
|
|
4a6991 |
+ const gchar *value,
|
|
|
4a6991 |
+ G_GNUC_UNUSED gpointer data, GError **error)
|
|
|
4a6991 |
+{
|
|
|
4a6991 |
+ if (g_str_equal(value, "never")) {
|
|
|
4a6991 |
+ opt_kiosk_quit = FALSE;
|
|
|
4a6991 |
+ return TRUE;
|
|
|
4a6991 |
+ }
|
|
|
4a6991 |
+ if (g_str_equal(value, "on-disconnect")) {
|
|
|
4a6991 |
+ opt_kiosk_quit = TRUE;
|
|
|
4a6991 |
+ return TRUE;
|
|
|
4a6991 |
+ }
|
|
|
4a6991 |
+
|
|
|
4a6991 |
+ g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, _("Invalid kiosk-quit argument: %s"), value);
|
|
|
4a6991 |
+ return FALSE;
|
|
|
4a6991 |
+}
|
|
|
4a6991 |
+
|
|
|
4a6991 |
const GOptionEntry *
|
|
|
4a6991 |
virt_viewer_app_get_options(void)
|
|
|
4a6991 |
{
|
|
|
4a6991 |
@@ -2161,6 +2201,8 @@ virt_viewer_app_get_options(void)
|
|
|
4a6991 |
N_("Customise hotkeys"), NULL },
|
|
|
4a6991 |
{ "kiosk", 'k', 0, G_OPTION_ARG_NONE, &opt_kiosk,
|
|
|
4a6991 |
N_("Enable kiosk mode"), NULL },
|
|
|
4a6991 |
+ { "kiosk-quit", '\0', 0, G_OPTION_ARG_CALLBACK, option_kiosk_quit,
|
|
|
4a6991 |
+ N_("Quit on given condition in kiosk mode"), N_("<never|on-disconnect>") },
|
|
|
4a6991 |
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose,
|
|
|
4a6991 |
N_("Display verbose information"), NULL },
|
|
|
4a6991 |
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &opt_debug,
|