mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-01-06 13:17:45 +03:00
src: cancel auth dialog when closing session
This ensures that the application exits when the user presses Ctrl-C while an auth dialog is open. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
247d91d889
commit
1d11dd55da
@ -44,6 +44,7 @@
|
|||||||
struct _VirtViewerSessionSpice {
|
struct _VirtViewerSessionSpice {
|
||||||
VirtViewerSession parent;
|
VirtViewerSession parent;
|
||||||
GtkWindow *main_window;
|
GtkWindow *main_window;
|
||||||
|
VirtViewerAuth *auth;
|
||||||
SpiceSession *session;
|
SpiceSession *session;
|
||||||
SpiceGtkSession *gtk_session;
|
SpiceGtkSession *gtk_session;
|
||||||
SpiceMainChannel *main_channel;
|
SpiceMainChannel *main_channel;
|
||||||
@ -138,6 +139,7 @@ virt_viewer_session_spice_set_property(GObject *object, guint property_id,
|
|||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case PROP_MAIN_WINDOW:
|
case PROP_MAIN_WINDOW:
|
||||||
self->main_window = g_value_dup_object(value);
|
self->main_window = g_value_dup_object(value);
|
||||||
|
self->auth = virt_viewer_auth_new(self->main_window);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
@ -157,6 +159,7 @@ virt_viewer_session_spice_dispose(GObject *obj)
|
|||||||
|
|
||||||
self->audio = NULL;
|
self->audio = NULL;
|
||||||
|
|
||||||
|
gtk_widget_destroy(GTK_WIDGET(self->auth));
|
||||||
g_clear_object(&self->main_window);
|
g_clear_object(&self->main_window);
|
||||||
if (self->file_transfer_dialog) {
|
if (self->file_transfer_dialog) {
|
||||||
gtk_widget_destroy(GTK_WIDGET(self->file_transfer_dialog));
|
gtk_widget_destroy(GTK_WIDGET(self->file_transfer_dialog));
|
||||||
@ -480,6 +483,8 @@ virt_viewer_session_spice_close(VirtViewerSession *session)
|
|||||||
virt_viewer_session_spice_clear_displays(self);
|
virt_viewer_session_spice_clear_displays(self);
|
||||||
|
|
||||||
if (self->session) {
|
if (self->session) {
|
||||||
|
gtk_dialog_response(GTK_DIALOG(self->auth),
|
||||||
|
GTK_RESPONSE_CANCEL);
|
||||||
spice_session_disconnect(self->session);
|
spice_session_disconnect(self->session);
|
||||||
if (!self)
|
if (!self)
|
||||||
return;
|
return;
|
||||||
@ -720,7 +725,6 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel,
|
|||||||
{
|
{
|
||||||
const GError *error = NULL;
|
const GError *error = NULL;
|
||||||
gchar *host = NULL;
|
gchar *host = NULL;
|
||||||
VirtViewerAuth *auth = virt_viewer_auth_new(self->main_window);
|
|
||||||
g_debug("main channel: auth failure (wrong username/password?)");
|
g_debug("main channel: auth failure (wrong username/password?)");
|
||||||
|
|
||||||
error = spice_channel_get_error(channel);
|
error = spice_channel_get_error(channel);
|
||||||
@ -746,12 +750,12 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_object_get(self->session, "host", &host, NULL);
|
g_object_get(self->session, "host", &host, NULL);
|
||||||
ret = virt_viewer_auth_collect_credentials(auth,
|
ret = virt_viewer_auth_collect_credentials(self->auth,
|
||||||
"SPICE",
|
"SPICE",
|
||||||
host,
|
host,
|
||||||
username_required ? &user : NULL,
|
username_required ? &user : NULL,
|
||||||
&password);
|
&password);
|
||||||
gtk_widget_destroy(GTK_WIDGET(auth));
|
|
||||||
g_free(host);
|
g_free(host);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/* ret is false when dialog did not return GTK_RESPONSE_OK. We
|
/* ret is false when dialog did not return GTK_RESPONSE_OK. We
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
struct _VirtViewerSessionVnc {
|
struct _VirtViewerSessionVnc {
|
||||||
VirtViewerSession parent;
|
VirtViewerSession parent;
|
||||||
GtkWindow *main_window;
|
GtkWindow *main_window;
|
||||||
|
VirtViewerAuth *auth;
|
||||||
/* XXX we should really just have a VncConnection */
|
/* XXX we should really just have a VncConnection */
|
||||||
VncDisplay *vnc;
|
VncDisplay *vnc;
|
||||||
gboolean auth_dialog_cancelled;
|
gboolean auth_dialog_cancelled;
|
||||||
@ -62,6 +63,7 @@ virt_viewer_session_vnc_finalize(GObject *obj)
|
|||||||
vnc_display_close(self->vnc);
|
vnc_display_close(self->vnc);
|
||||||
g_object_unref(self->vnc);
|
g_object_unref(self->vnc);
|
||||||
}
|
}
|
||||||
|
gtk_widget_destroy(GTK_WIDGET(self->auth));
|
||||||
if (self->main_window)
|
if (self->main_window)
|
||||||
g_object_unref(self->main_window);
|
g_object_unref(self->main_window);
|
||||||
g_free(self->error_msg);
|
g_free(self->error_msg);
|
||||||
@ -324,12 +326,10 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wantUsername || wantPassword) {
|
if (wantUsername || wantPassword) {
|
||||||
VirtViewerAuth *auth = virt_viewer_auth_new(self->main_window);
|
gboolean ret = virt_viewer_auth_collect_credentials(self->auth,
|
||||||
gboolean ret = virt_viewer_auth_collect_credentials(auth,
|
|
||||||
"VNC", NULL,
|
"VNC", NULL,
|
||||||
wantUsername ? &username : NULL,
|
wantUsername ? &username : NULL,
|
||||||
wantPassword ? &password : NULL);
|
wantPassword ? &password : NULL);
|
||||||
gtk_widget_destroy(GTK_WIDGET(auth));
|
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
vnc_display_close(self->vnc);
|
vnc_display_close(self->vnc);
|
||||||
@ -389,6 +389,9 @@ virt_viewer_session_vnc_close(VirtViewerSession* session)
|
|||||||
|
|
||||||
g_debug("close vnc=%p", self->vnc);
|
g_debug("close vnc=%p", self->vnc);
|
||||||
if (self->vnc != NULL) {
|
if (self->vnc != NULL) {
|
||||||
|
gtk_dialog_response(GTK_DIALOG(self->auth),
|
||||||
|
GTK_RESPONSE_CANCEL);
|
||||||
|
|
||||||
virt_viewer_session_clear_displays(session);
|
virt_viewer_session_clear_displays(session);
|
||||||
vnc_display_close(self->vnc);
|
vnc_display_close(self->vnc);
|
||||||
g_object_unref(self->vnc);
|
g_object_unref(self->vnc);
|
||||||
@ -430,6 +433,7 @@ virt_viewer_session_vnc_new(VirtViewerApp *app, GtkWindow *main_window)
|
|||||||
self->vnc = VNC_DISPLAY(vnc_display_new());
|
self->vnc = VNC_DISPLAY(vnc_display_new());
|
||||||
g_object_ref_sink(self->vnc);
|
g_object_ref_sink(self->vnc);
|
||||||
self->main_window = g_object_ref(main_window);
|
self->main_window = g_object_ref(main_window);
|
||||||
|
self->auth = virt_viewer_auth_new(self->main_window);
|
||||||
|
|
||||||
vnc_display_set_shared_flag(self->vnc,
|
vnc_display_set_shared_flag(self->vnc,
|
||||||
virt_viewer_app_get_shared(app));
|
virt_viewer_app_get_shared(app));
|
||||||
|
Loading…
Reference in New Issue
Block a user