Add a --shared / -s flag for shared session access
By default when connecting with VNC, an existing viewer will be kicked
off. This adds a --shared / -s flag which tells the server we are
willing the share the session with other clients.
This is wired up for VNC only.
https://bugzilla.redhat.com/show_bug.cgi?id=1060425
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Daniel P. Berrangé
3 years ago
56 | 56 | =item -t TITLE, --title TITLE |
57 | 57 | |
58 | 58 | Set the window title to B<TITLE> |
59 | ||
60 | =item -s, --shared | |
61 | ||
62 | Permitted a shared session with multiple clients | |
59 | 63 | |
60 | 64 | =item --debug |
61 | 65 |
77 | 77 | To specify which client monitors are used in fullscreen mode, see the |
78 | 78 | CONFIGURATION section below. |
79 | 79 | |
80 | =item -s, --shared | |
81 | ||
82 | Permitted a shared session with multiple clients | |
83 | ||
80 | 84 | =item --debug |
81 | 85 | |
82 | 86 | Print debugging information |
106 | 106 | |
107 | 107 | static gchar **opt_args = NULL; |
108 | 108 | static char *opt_title = NULL; |
109 | static gboolean opt_shared = FALSE; | |
109 | 110 | |
110 | 111 | static void |
111 | 112 | remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext *context, GOptionGroup *group) |
113 | 114 | static const GOptionEntry options[] = { |
114 | 115 | { "title", 't', 0, G_OPTION_ARG_STRING, &opt_title, |
115 | 116 | N_("Set window title"), NULL }, |
117 | { "shared", 's', 0, G_OPTION_ARG_NONE, &opt_shared, | |
118 | N_("Share client session"), NULL }, | |
116 | 119 | { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &opt_args, |
117 | 120 | NULL, "URI|VV-FILE" }, |
118 | 121 | { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } |
156 | 159 | if (opt_title) |
157 | 160 | g_object_set(app, "title", opt_title, NULL); |
158 | 161 | |
159 | end: | |
162 | virt_viewer_app_set_shared(app, opt_shared); | |
163 | ||
164 | end: | |
160 | 165 | if (ret && *status) |
161 | 166 | g_printerr(_("Run '%s --help' to see a full list of available command line options\n"), g_get_prgname()); |
162 | 167 |
132 | 132 | gboolean started; |
133 | 133 | gboolean fullscreen; |
134 | 134 | gboolean attach; |
135 | gboolean shared; | |
135 | 136 | gboolean quitting; |
136 | 137 | gboolean kiosk; |
137 | 138 | gboolean vm_ui; |
2476 | 2477 | return self->priv->attach; |
2477 | 2478 | } |
2478 | 2479 | |
2480 | void | |
2481 | virt_viewer_app_set_shared(VirtViewerApp *self, gboolean shared) | |
2482 | { | |
2483 | g_return_if_fail(VIRT_VIEWER_IS_APP(self)); | |
2484 | ||
2485 | self->priv->shared = shared; | |
2486 | } | |
2487 | ||
2488 | gboolean | |
2489 | virt_viewer_app_get_shared(VirtViewerApp *self) | |
2490 | { | |
2491 | g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE); | |
2492 | ||
2493 | return self->priv->shared; | |
2494 | } | |
2495 | ||
2479 | 2496 | gboolean |
2480 | 2497 | virt_viewer_app_is_active(VirtViewerApp *self) |
2481 | 2498 | { |
79 | 79 | void virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys); |
80 | 80 | void virt_viewer_app_set_attach(VirtViewerApp *self, gboolean attach); |
81 | 81 | gboolean virt_viewer_app_get_attach(VirtViewerApp *self); |
82 | void virt_viewer_app_set_shared(VirtViewerApp *self, gboolean shared); | |
83 | gboolean virt_viewer_app_get_shared(VirtViewerApp *self); | |
82 | 84 | gboolean virt_viewer_app_has_session(VirtViewerApp *self); |
83 | 85 | void virt_viewer_app_set_connect_info(VirtViewerApp *self, |
84 | 86 | const gchar *host, |
422 | 422 | g_object_ref_sink(session->priv->vnc); |
423 | 423 | session->priv->main_window = g_object_ref(main_window); |
424 | 424 | |
425 | vnc_display_set_shared_flag(session->priv->vnc, | |
426 | virt_viewer_app_get_shared(app)); | |
427 | ||
425 | 428 | g_signal_connect(session->priv->vnc, "vnc-connected", |
426 | 429 | G_CALLBACK(virt_viewer_session_vnc_connected), session); |
427 | 430 | g_signal_connect(session->priv->vnc, "vnc-initialized", |
82 | 82 | static gboolean opt_attach = FALSE; |
83 | 83 | static gboolean opt_waitvm = FALSE; |
84 | 84 | static gboolean opt_reconnect = FALSE; |
85 | static gboolean opt_shared = FALSE; | |
85 | 86 | |
86 | 87 | typedef enum { |
87 | 88 | DOMAIN_SELECTION_ID = (1 << 0), |
142 | 143 | N_("Select the virtual machine only by its ID"), NULL }, |
143 | 144 | { "uuid", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, opt_domain_selection_cb, |
144 | 145 | N_("Select the virtual machine only by its UUID"), NULL }, |
146 | { "shared", 's', 0, G_OPTION_ARG_NONE, &opt_shared, | |
147 | N_("Share client session"), NULL }, | |
145 | 148 | { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &opt_args, |
146 | 149 | NULL, "-- ID|UUID|DOMAIN-NAME" }, |
147 | 150 | { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } |
191 | 194 | |
192 | 195 | virt_viewer_app_set_direct(app, opt_direct); |
193 | 196 | virt_viewer_app_set_attach(app, opt_attach); |
197 | virt_viewer_app_set_shared(app, opt_shared); | |
194 | 198 | self->priv->reconnect = opt_reconnect; |
195 | 199 | self->priv->uri = g_strdup(opt_uri); |
196 | 200 |