session: remove "session-error" signal

This partially reverts commit de5cd71.

Problem with that commit is, that it practically renders
the "session-auth-*" signals from vnc session useless.
That's because gtk-vnc currently emits "vnc-error" before each
"vnc-auth-*" signal and the error callback in virt-viewer-app.c
calls virt_viewer_app_disconnected(), which in turn closes
the session.
As a consequence, virt-viewer never retries authentication
with vnc, it simply exits.

Since the last commit, vnc, similarly to spice, emits
"session-disconnected" with the appropriate error message. Thus
there's no need to maintain separate "session-error" signal
for now.

With vnc, this error message is shown to the user in a dialog,
if the disconnect happened during the init phase.
"session-auth-*" callbacks create their own dialogs, so
initialized must be set to TRUE to avoid having a dialog
displayed twice.

Related:
https://bugzilla.redhat.com/show_bug.cgi?id=1911224

Signed-off-by: Jakub Janků <jjanku@redhat.com>
This commit is contained in:
Jakub Janků 2021-02-10 10:58:57 +01:00
parent 11ec065ce2
commit 8bc91ac80f
3 changed files with 11 additions and 32 deletions

View File

@ -70,9 +70,6 @@ void virt_viewer_app_about_delete(GtkWidget *dialog, void *dummy, VirtViewerApp
/* Internal methods */
static void virt_viewer_app_connected(VirtViewerSession *session,
VirtViewerApp *self);
static void virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
const gchar *msg,
VirtViewerApp *self);
static void virt_viewer_app_initialized(VirtViewerSession *session,
VirtViewerApp *self);
static void virt_viewer_app_disconnected(VirtViewerSession *session,
@ -745,7 +742,8 @@ static void hide_one_window(gpointer value,
{
VirtViewerApp* self = VIRT_VIEWER_APP(user_data);
VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
gboolean connect_error = !priv->connected && !priv->cancelled;
gboolean connect_error = !priv->cancelled &&
!(VIRT_VIEWER_IS_SESSION_VNC(priv->session) ? priv->initialized : priv->connected);
if (connect_error || priv->main_window != value)
virt_viewer_window_hide(VIRT_VIEWER_WINDOW(value));
@ -1342,8 +1340,6 @@ virt_viewer_app_create_session(VirtViewerApp *self, const gchar *type, GError **
g_signal_connect(priv->session, "session-initialized",
G_CALLBACK(virt_viewer_app_initialized), self);
g_signal_connect(priv->session, "session-error",
G_CALLBACK(virt_viewer_app_error), self);
g_signal_connect(priv->session, "session-connected",
G_CALLBACK(virt_viewer_app_connected), self);
g_signal_connect(priv->session, "session-disconnected",
@ -1721,7 +1717,8 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
VirtViewerApp *self)
{
VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
gboolean connect_error = !priv->connected && !priv->cancelled;
gboolean connect_error = !priv->cancelled &&
!(VIRT_VIEWER_IS_SESSION_VNC(session) ? priv->initialized : priv->connected);
if (!priv->kiosk)
virt_viewer_app_hide_all_windows(self);
@ -1744,21 +1741,6 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
virt_viewer_app_deactivate(self, connect_error);
}
static void
virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
const gchar *msg,
VirtViewerApp *self)
{
VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
/* Do not open a dialog if the connection was initialized
* This happens when the VNC server closes the connection */
if (!priv->initialized)
priv->connected = FALSE; /* display error dialog */
virt_viewer_app_disconnected(session, msg, self);
}
static void virt_viewer_app_cancelled(VirtViewerSession *session,
VirtViewerApp *self)
{
@ -1781,15 +1763,22 @@ static void virt_viewer_app_auth_refused(VirtViewerSession *session,
* VirtViewerApp needs to schedule a new connection to retry */
priv->authretry = (!virt_viewer_session_can_retry_auth(session) &&
!virt_viewer_session_get_file(session));
/* don't display another dialog in virt_viewer_app_disconnected when using VNC */
priv->initialized = TRUE;
}
static void virt_viewer_app_auth_unsupported(VirtViewerSession *session G_GNUC_UNUSED,
const char *msg,
VirtViewerApp *self)
{
VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
virt_viewer_app_simple_message_dialog(self,
_("Unable to authenticate with remote desktop server: %s"),
msg);
/* don't display another dialog in virt_viewer_app_disconnected when using VNC */
priv->initialized = TRUE;
}
static void virt_viewer_app_usb_failed(VirtViewerSession *session G_GNUC_UNUSED,

View File

@ -136,7 +136,6 @@ virt_viewer_session_vnc_error(VncDisplay *vnc G_GNUC_UNUSED,
VirtViewerSessionVnc *session)
{
g_warning("vnc-session: got vnc error %s", msg);
g_signal_emit_by_name(session, "session-error", msg);
/* "vnc-error" is always followed by "vnc-disconnected",
* so save the error for that signal */
g_free(session->error_msg);

View File

@ -276,15 +276,6 @@ virt_viewer_session_class_init(VirtViewerSessionClass *class)
G_TYPE_NONE,
0);
g_signal_new("session-error",
G_OBJECT_CLASS_TYPE(object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
1,
G_TYPE_STRING);
g_signal_new("session-disconnected",
G_OBJECT_CLASS_TYPE(object_class),
G_SIGNAL_RUN_FIRST,