Blame SOURCES/0050-remote-viewer-Pass-guri-to-remote_viewer_session_con.patch

48c875
From 8f1b485ddf106aae94ccdf14c26ad11a19c471b4 Mon Sep 17 00:00:00 2001
48c875
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
48c875
Date: Fri, 20 Oct 2017 15:00:46 -0200
48c875
Subject: [PATCH] remote-viewer: Pass guri to remote_viewer_session_connected
48c875
48c875
When connecting to a VM via oVirt instance, the original uri can not be
48c875
retrieved using virt_viewer_session_get_uri(). Consequently, it was
48c875
never saved, even though the connection succeeds and the actual callback
48c875
for "session-connected" signal, which saves the URI, is invoked.
48c875
48c875
To solve this problem, we always pass a copy of the guri as user-data
48c875
parameter for the callback, and if the call to
48c875
virt_viewer_session_get_uri() returns NULL, the parameter is used
48c875
instead.
48c875
48c875
Resolves: https://bugzilla.redhat.com/1459792
48c875
48c875
Backport from upstream 6608c0dd60fbf3a762a21a4d039fefc75c040406
48c875
48c875
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
48c875
---
48c875
 src/remote-viewer.c | 11 +++++++----
48c875
 1 file changed, 7 insertions(+), 4 deletions(-)
48c875
48c875
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
48c875
index 7834dac..429f38c 100644
48c875
--- a/src/remote-viewer.c
48c875
+++ b/src/remote-viewer.c
48c875
@@ -1064,8 +1064,7 @@ remote_viewer_recent_add(gchar *uri, const gchar *mime_type)
48c875
         .mime_type    = (char*)mime_type,
48c875
     };
48c875
 
48c875
-    if (uri == NULL)
48c875
-        return;
48c875
+    g_return_if_fail(uri != NULL);
48c875
 
48c875
     recent = gtk_recent_manager_get_default();
48c875
     meta.display_name = uri;
48c875
@@ -1075,13 +1074,17 @@ remote_viewer_recent_add(gchar *uri, const gchar *mime_type)
48c875
 
48c875
 static void
48c875
 remote_viewer_session_connected(VirtViewerSession *session,
48c875
-                                VirtViewerApp *self G_GNUC_UNUSED)
48c875
+                                gchar *guri)
48c875
 {
48c875
     gchar *uri = virt_viewer_session_get_uri(session);
48c875
     const gchar *mime = virt_viewer_session_mime_type(session);
48c875
 
48c875
+    if (uri == NULL)
48c875
+        uri = g_strdup(guri);
48c875
+
48c875
     remote_viewer_recent_add(uri, mime);
48c875
     g_free(uri);
48c875
+    g_free(guri);
48c875
 }
48c875
 
48c875
 static gboolean
48c875
@@ -1169,7 +1172,7 @@ retry_dialog:
48c875
         }
48c875
 
48c875
         g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
48c875
-                         G_CALLBACK(remote_viewer_session_connected), app);
48c875
+                         G_CALLBACK(remote_viewer_session_connected), g_strdup(guri));
48c875
 
48c875
         virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
48c875
 #ifdef HAVE_OVIRT
48c875
-- 
48c875
2.13.6
48c875