Blame SOURCES/0024-session-remove-session-error-signal.patch

9ff4aa
From 8bc91ac80f9c5c7df30f25e35946be0869be3db5 Mon Sep 17 00:00:00 2001
9ff4aa
From: =?UTF-8?q?Jakub=20Jank=C5=AF?= <jjanku@redhat.com>
9ff4aa
Date: Wed, 10 Feb 2021 10:58:57 +0100
9ff4aa
Subject: [PATCH] session: remove "session-error" signal
9ff4aa
MIME-Version: 1.0
9ff4aa
Content-Type: text/plain; charset=UTF-8
9ff4aa
Content-Transfer-Encoding: 8bit
9ff4aa
9ff4aa
This partially reverts commit de5cd71.
9ff4aa
9ff4aa
Problem with that commit is, that it practically renders
9ff4aa
the "session-auth-*" signals from vnc session useless.
9ff4aa
That's because gtk-vnc currently emits "vnc-error" before each
9ff4aa
"vnc-auth-*" signal and the error callback in virt-viewer-app.c
9ff4aa
calls virt_viewer_app_disconnected(), which in turn closes
9ff4aa
the session.
9ff4aa
As a consequence, virt-viewer never retries authentication
9ff4aa
with vnc, it simply exits.
9ff4aa
9ff4aa
Since the last commit, vnc, similarly to spice, emits
9ff4aa
"session-disconnected" with the appropriate error message. Thus
9ff4aa
there's no need to maintain separate "session-error" signal
9ff4aa
for now.
9ff4aa
9ff4aa
With vnc, this error message is shown to the user in a dialog,
9ff4aa
if the disconnect happened during the init phase.
9ff4aa
"session-auth-*" callbacks create their own dialogs, so
9ff4aa
initialized must be set to TRUE to avoid having a dialog
9ff4aa
displayed twice.
9ff4aa
9ff4aa
Related:
9ff4aa
https://bugzilla.redhat.com/show_bug.cgi?id=1911224
9ff4aa
9ff4aa
Signed-off-by: Jakub Janků <jjanku@redhat.com>
9ff4aa
---
9ff4aa
 src/virt-viewer-app.c         | 33 +++++++++++----------------------
9ff4aa
 src/virt-viewer-session-vnc.c |  1 -
9ff4aa
 src/virt-viewer-session.c     |  9 ---------
9ff4aa
 3 files changed, 11 insertions(+), 32 deletions(-)
9ff4aa
9ff4aa
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
9ff4aa
index e42535b..2bb780f 100644
9ff4aa
--- a/src/virt-viewer-app.c
9ff4aa
+++ b/src/virt-viewer-app.c
9ff4aa
@@ -70,9 +70,6 @@ void virt_viewer_app_about_delete(GtkWidget *dialog, void *dummy, VirtViewerApp
9ff4aa
 /* Internal methods */
9ff4aa
 static void virt_viewer_app_connected(VirtViewerSession *session,
9ff4aa
                                       VirtViewerApp *self);
9ff4aa
-static void virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
9ff4aa
-                                  const gchar *msg,
9ff4aa
-                                  VirtViewerApp *self);
9ff4aa
 static void virt_viewer_app_initialized(VirtViewerSession *session,
9ff4aa
                                         VirtViewerApp *self);
9ff4aa
 static void virt_viewer_app_disconnected(VirtViewerSession *session,
9ff4aa
@@ -745,7 +742,8 @@ static void hide_one_window(gpointer value,
9ff4aa
 {
9ff4aa
     VirtViewerApp* self = VIRT_VIEWER_APP(user_data);
9ff4aa
     VirtViewerAppPrivate *priv = self->priv;
9ff4aa
-    gboolean connect_error = !priv->connected && !priv->cancelled;
9ff4aa
+    gboolean connect_error = !priv->cancelled &&
9ff4aa
+        !(VIRT_VIEWER_IS_SESSION_VNC(priv->session) ? priv->initialized : priv->connected);
9ff4aa
 
9ff4aa
     if (connect_error || self->priv->main_window != value)
9ff4aa
         virt_viewer_window_hide(VIRT_VIEWER_WINDOW(value));
9ff4aa
@@ -1342,8 +1340,6 @@ virt_viewer_app_create_session(VirtViewerApp *self, const gchar *type, GError **
9ff4aa
 
9ff4aa
     g_signal_connect(priv->session, "session-initialized",
9ff4aa
                      G_CALLBACK(virt_viewer_app_initialized), self);
9ff4aa
-    g_signal_connect(priv->session, "session-error",
9ff4aa
-                     G_CALLBACK(virt_viewer_app_error), self);
9ff4aa
     g_signal_connect(priv->session, "session-connected",
9ff4aa
                      G_CALLBACK(virt_viewer_app_connected), self);
9ff4aa
     g_signal_connect(priv->session, "session-disconnected",
9ff4aa
@@ -1721,7 +1717,8 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
9ff4aa
                              VirtViewerApp *self)
9ff4aa
 {
9ff4aa
     VirtViewerAppPrivate *priv = self->priv;
9ff4aa
-    gboolean connect_error = !priv->connected && !priv->cancelled;
9ff4aa
+    gboolean connect_error = !priv->cancelled &&
9ff4aa
+        !(VIRT_VIEWER_IS_SESSION_VNC(session) ? priv->initialized : priv->connected);
9ff4aa
 
9ff4aa
     if (!priv->kiosk)
9ff4aa
         virt_viewer_app_hide_all_windows(self);
9ff4aa
@@ -1744,21 +1741,6 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED, const gch
9ff4aa
     virt_viewer_app_deactivate(self, connect_error);
9ff4aa
 }
9ff4aa
 
9ff4aa
-static void
9ff4aa
-virt_viewer_app_error(VirtViewerSession *session G_GNUC_UNUSED,
9ff4aa
-                      const gchar *msg,
9ff4aa
-                      VirtViewerApp *self)
9ff4aa
-{
9ff4aa
-    VirtViewerAppPrivate *priv = self->priv;
9ff4aa
-
9ff4aa
-    /* Do not open a dialog if the connection was initialized
9ff4aa
-     * This happens when the VNC server closes the connection */
9ff4aa
-    if (!priv->initialized)
9ff4aa
-        priv->connected = FALSE; /* display error dialog */
9ff4aa
-
9ff4aa
-    virt_viewer_app_disconnected(session, msg, self);
9ff4aa
-}
9ff4aa
-
9ff4aa
 static void virt_viewer_app_cancelled(VirtViewerSession *session,
9ff4aa
                                       VirtViewerApp *self)
9ff4aa
 {
9ff4aa
@@ -1781,15 +1763,22 @@ static void virt_viewer_app_auth_refused(VirtViewerSession *session,
9ff4aa
      * VirtViewerApp needs to schedule a new connection to retry */
9ff4aa
     priv->authretry = (!virt_viewer_session_can_retry_auth(session) &&
9ff4aa
                        !virt_viewer_session_get_file(session));
9ff4aa
+
9ff4aa
+    /* don't display another dialog in virt_viewer_app_disconnected when using VNC */
9ff4aa
+    priv->initialized = TRUE;
9ff4aa
 }
9ff4aa
 
9ff4aa
 static void virt_viewer_app_auth_unsupported(VirtViewerSession *session G_GNUC_UNUSED,
9ff4aa
                                         const char *msg,
9ff4aa
                                         VirtViewerApp *self)
9ff4aa
 {
9ff4aa
+    VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
9ff4aa
     virt_viewer_app_simple_message_dialog(self,
9ff4aa
                                           _("Unable to authenticate with remote desktop server: %s"),
9ff4aa
                                           msg);
9ff4aa
+
9ff4aa
+    /* don't display another dialog in virt_viewer_app_disconnected when using VNC */
9ff4aa
+    priv->initialized = TRUE;
9ff4aa
 }
9ff4aa
 
9ff4aa
 static void virt_viewer_app_usb_failed(VirtViewerSession *session G_GNUC_UNUSED,
9ff4aa
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
9ff4aa
index 7d6dfb2..aa29d00 100644
9ff4aa
--- a/src/virt-viewer-session-vnc.c
9ff4aa
+++ b/src/virt-viewer-session-vnc.c
9ff4aa
@@ -136,7 +136,6 @@ virt_viewer_session_vnc_error(VncDisplay *vnc G_GNUC_UNUSED,
9ff4aa
                               VirtViewerSessionVnc *session)
9ff4aa
 {
9ff4aa
     g_warning("vnc-session: got vnc error %s", msg);
9ff4aa
-    g_signal_emit_by_name(session, "session-error", msg);
9ff4aa
     /* "vnc-error" is always followed by "vnc-disconnected",
9ff4aa
      * so save the error for that signal */
9ff4aa
     g_free(session->priv->error_msg);
9ff4aa
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
9ff4aa
index 639d7a4..4171f3d 100644
9ff4aa
--- a/src/virt-viewer-session.c
9ff4aa
+++ b/src/virt-viewer-session.c
9ff4aa
@@ -276,15 +276,6 @@ virt_viewer_session_class_init(VirtViewerSessionClass *class)
9ff4aa
                  G_TYPE_NONE,
9ff4aa
                  0);
9ff4aa
 
9ff4aa
-    g_signal_new("session-error",
9ff4aa
-                 G_OBJECT_CLASS_TYPE(object_class),
9ff4aa
-                 G_SIGNAL_RUN_FIRST,
9ff4aa
-                 0,
9ff4aa
-                 NULL, NULL,
9ff4aa
-                 g_cclosure_marshal_VOID__STRING,
9ff4aa
-                 G_TYPE_NONE,
9ff4aa
-                 1,
9ff4aa
-                 G_TYPE_STRING);
9ff4aa
     g_signal_new("session-disconnected",
9ff4aa
                  G_OBJECT_CLASS_TYPE(object_class),
9ff4aa
                  G_SIGNAL_RUN_FIRST,
9ff4aa
-- 
9ff4aa
2.29.2
9ff4aa