Blame SOURCES/0010-kiosk-add-app-kiosk-option-pass-it-down-to-window.patch

4a6991
From 8a8706418c08eb2d4b027e7d6bfe18087b62efe4 Mon Sep 17 00:00:00 2001
4a6991
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
4a6991
Date: Fri, 16 Aug 2013 20:54:52 +0200
4a6991
Subject: [PATCH] kiosk: add app kiosk option, pass it down to window
4a6991
4a6991
See man page update for details.
4a6991
4a6991
(cherry picked from commit 34eab7b91ee5349709e77e6ec85f92ab029a5350)
4a6991
https://bugzilla.redhat.com/show_bug.cgi?id=1040926
4a6991
---
4a6991
 man/remote-viewer.pod    | 13 +++++++++++++
4a6991
 man/virt-viewer.pod      | 13 +++++++++++++
4a6991
 src/virt-viewer-app.c    | 37 +++++++++++++++++++++++++++++++++++++
4a6991
 src/virt-viewer-window.c | 13 +++++++++++++
4a6991
 src/virt-viewer-window.h |  1 +
4a6991
 5 files changed, 77 insertions(+)
4a6991
4a6991
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
4a6991
index a4710c8..10fda2c 100644
4a6991
--- a/man/remote-viewer.pod
4a6991
+++ b/man/remote-viewer.pod
4a6991
@@ -77,6 +77,19 @@ smartcard-remove. Examples:
4a6991
 Note that hotkeys for which no binding is given are disabled, specifying an
4a6991
 empty string disables all hotkeys.
4a6991
 
4a6991
+=item -k, --kiosk
4a6991
+
4a6991
+Start in kiosk mode. In this mode, the application will start in
4a6991
+fullscreen with minimal UI. It will prevent the user from quitting or
4a6991
+performing any interaction outside of usage of the remote desktop
4a6991
+session.
4a6991
+
4a6991
+Note that it can't offer a complete secure solution by itself. Your
4a6991
+kiosk system must have additional configuration and security settings
4a6991
+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
 =back
4a6991
 
4a6991
 =head1 HOTKEY
4a6991
diff --git a/man/virt-viewer.pod b/man/virt-viewer.pod
4a6991
index 9187c2e..9d0597a 100644
4a6991
--- a/man/virt-viewer.pod
4a6991
+++ b/man/virt-viewer.pod
4a6991
@@ -86,6 +86,19 @@ smartcard-insert and smartcard-remove. Examples:
4a6991
 Note that hotkeys for which no binding is given are disabled, specifying an
4a6991
 empty string disables all hotkeys.
4a6991
 
4a6991
+=item -k, --kiosk
4a6991
+
4a6991
+Start in kiosk mode. In this mode, the application will start in
4a6991
+fullscreen with minimal UI. It will prevent the user from quitting or
4a6991
+performing any interaction outside of usage of the remote desktop
4a6991
+session.
4a6991
+
4a6991
+Note that it can't offer a complete secure solution by itself. Your
4a6991
+kiosk system must have additional configuration and security settings
4a6991
+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
 =back
4a6991
 
4a6991
 =head1 EXAMPLES
4a6991
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
4a6991
index fd98e62..d3755d8 100644
4a6991
--- a/src/virt-viewer-app.c
4a6991
+++ b/src/virt-viewer-app.c
4a6991
@@ -119,6 +119,7 @@ struct _VirtViewerAppPrivate {
4a6991
     gboolean fullscreen_auto_conf;
4a6991
     gboolean attach;
4a6991
     gboolean quiting;
4a6991
+    gboolean kiosk;
4a6991
 
4a6991
     VirtViewerSession *session;
4a6991
     gboolean active;
4a6991
@@ -165,6 +166,7 @@ enum {
4a6991
     PROP_ENABLE_ACCEL,
4a6991
     PROP_HAS_FOCUS,
4a6991
     PROP_FULLSCREEN_AUTO_CONF,
4a6991
+    PROP_KIOSK,
4a6991
 };
4a6991
 
4a6991
 enum {
4a6991
@@ -251,6 +253,11 @@ virt_viewer_app_quit(VirtViewerApp *self)
4a6991
     g_return_if_fail(VIRT_VIEWER_IS_APP(self));
4a6991
     VirtViewerAppPrivate *priv = self->priv;
4a6991
 
4a6991
+    if (self->priv->kiosk) {
4a6991
+        g_warning("The app is in kiosk mode and can't quit");
4a6991
+        return;
4a6991
+    }
4a6991
+
4a6991
     virt_viewer_app_save_config(self);
4a6991
 
4a6991
     if (priv->session) {
4a6991
@@ -663,6 +670,7 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
4a6991
         return window;
4a6991
 
4a6991
     window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
4a6991
+    virt_viewer_window_set_kiosk(window, self->priv->kiosk);
4a6991
     if (self->priv->main_window)
4a6991
         virt_viewer_window_set_zoom_level(window, virt_viewer_window_get_zoom_level(self->priv->main_window));
4a6991
     virt_viewer_app_set_nth_window(self, nth, window);
4a6991
@@ -1256,6 +1264,13 @@ static void virt_viewer_app_usb_failed(VirtViewerSession *session G_GNUC_UNUSED,
4a6991
 }
4a6991
 
4a6991
 static void
4a6991
+virt_viewer_app_set_kiosk(VirtViewerApp *self, gboolean enabled)
4a6991
+{
4a6991
+    self->priv->kiosk = enabled;
4a6991
+}
4a6991
+
4a6991
+
4a6991
+static void
4a6991
 virt_viewer_app_get_property (GObject *object, guint property_id,
4a6991
                               GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
4a6991
 {
4a6991
@@ -1300,6 +1315,10 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
4a6991
         g_value_set_boolean(value, virt_viewer_app_get_fullscreen_auto_conf(self));
4a6991
         break;
4a6991
 
4a6991
+    case PROP_KIOSK:
4a6991
+        g_value_set_boolean(value, priv->kiosk);
4a6991
+        break;
4a6991
+
4a6991
     default:
4a6991
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4a6991
     }
4a6991
@@ -1345,6 +1364,10 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
4a6991
         priv->fullscreen_auto_conf = g_value_get_boolean(value);
4a6991
         break;
4a6991
 
4a6991
+    case PROP_KIOSK:
4a6991
+        virt_viewer_app_set_kiosk(self, g_value_get_boolean(value));
4a6991
+        break;
4a6991
+
4a6991
     default:
4a6991
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
4a6991
     }
4a6991
@@ -1412,6 +1435,7 @@ static gboolean opt_verbose = FALSE;
4a6991
 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
 
4a6991
 static void
4a6991
 virt_viewer_app_init (VirtViewerApp *self)
4a6991
@@ -1520,6 +1544,7 @@ virt_viewer_app_constructor (GType gtype,
4a6991
     virt_viewer_window_set_zoom_level(priv->main_window, opt_zoom);
4a6991
     virt_viewer_app_set_fullscreen(self, opt_fullscreen);
4a6991
     virt_viewer_app_set_hotkeys(self, opt_hotkeys);
4a6991
+    virt_viewer_app_set_kiosk(self, opt_kiosk);
4a6991
 
4a6991
     return obj;
4a6991
 }
4a6991
@@ -1627,6 +1652,16 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
4a6991
                                                          G_PARAM_READABLE |
4a6991
                                                          G_PARAM_STATIC_STRINGS));
4a6991
 
4a6991
+    g_object_class_install_property(object_class,
4a6991
+                                    PROP_KIOSK,
4a6991
+                                    g_param_spec_boolean("kiosk",
4a6991
+                                                         "Kiosk",
4a6991
+                                                         "Kiosk mode",
4a6991
+                                                         FALSE,
4a6991
+                                                         G_PARAM_CONSTRUCT |
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
@@ -2104,6 +2139,8 @@ virt_viewer_app_get_options(void)
4a6991
           N_("Open in full screen mode (auto-conf adjusts guest resolution to fit the client's)"), N_("<auto-conf>") },
4a6991
         { "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &opt_hotkeys,
4a6991
           N_("Customise hotkeys"), NULL },
4a6991
+        { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &opt_kiosk,
4a6991
+          N_("Enable kiosk mode"), NULL },
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,
4a6991
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
4a6991
index 1fa3982..f4cdeed 100644
4a6991
--- a/src/virt-viewer-window.c
4a6991
+++ b/src/virt-viewer-window.c
4a6991
@@ -98,6 +98,7 @@ struct _VirtViewerWindowPrivate {
4a6991
     gboolean grabbed;
4a6991
     gint fullscreen_monitor;
4a6991
     gboolean desktop_resize_pending;
4a6991
+    gboolean kiosk;
4a6991
 
4a6991
     gint zoomlevel;
4a6991
     gboolean auto_resize;
4a6991
@@ -1337,6 +1338,18 @@ virt_viewer_window_get_display(VirtViewerWindow *self)
4a6991
     return self->priv->display;
4a6991
 }
4a6991
 
4a6991
+void
4a6991
+virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled)
4a6991
+{
4a6991
+    g_return_if_fail(VIRT_VIEWER_IS_WINDOW(self));
4a6991
+    g_return_if_fail(enabled == !!enabled);
4a6991
+
4a6991
+    if (self->priv->kiosk == enabled)
4a6991
+        return;
4a6991
+
4a6991
+    self->priv->kiosk = enabled;
4a6991
+}
4a6991
+
4a6991
 /*
4a6991
  * Local variables:
4a6991
  *  c-indent-level: 4
4a6991
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
4a6991
index 41ac5e2..33cf8f4 100644
4a6991
--- a/src/virt-viewer-window.h
4a6991
+++ b/src/virt-viewer-window.h
4a6991
@@ -74,6 +74,7 @@ void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
4a6991
 void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor);
4a6991
 GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
4a6991
 GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
4a6991
+void virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled);
4a6991
 
4a6991
 G_END_DECLS
4a6991