[spice-gtk v4 2/4] usb-device-manager: Handle connectionless channel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

As we are not able to redirect anything in case that usbredir channel
is not connected.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1625550
Signed-off-by: Victor Toso <victortoso@xxxxxxxxx>
---
 src/usb-device-manager.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 50fb491..45adf5a 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -158,6 +158,8 @@ static void channel_new(SpiceSession *session, SpiceChannel *channel,
                         gpointer user_data);
 static void channel_destroy(SpiceSession *session, SpiceChannel *channel,
                             gpointer user_data);
+static void channel_event(SpiceChannel *channel, SpiceChannelEvent event,
+                          gpointer user_data);
 #ifdef USE_GUDEV
 static void spice_usb_device_manager_uevent_cb(GUdevClient     *client,
                                                const gchar     *action,
@@ -849,6 +851,8 @@ static void channel_new(SpiceSession *session, SpiceChannel *channel,
     spice_channel_connect(channel);
     g_ptr_array_add(self->priv->channels, channel);
 
+    g_signal_connect(channel, "channel-event", G_CALLBACK(channel_event), self);
+
     spice_usb_device_manager_check_redir_on_connect(self, channel);
 
     /*
@@ -871,6 +875,34 @@ static void channel_destroy(SpiceSession *session, SpiceChannel *channel,
     g_ptr_array_remove(self->priv->channels, channel);
 }
 
+static void channel_event(SpiceChannel *channel, SpiceChannelEvent event,
+                          gpointer user_data)
+
+{
+    SpiceUsbDeviceManager *self = user_data;
+
+    switch (event) {
+    case SPICE_CHANNEL_NONE:
+    case SPICE_CHANNEL_OPENED:
+        return;
+
+    case SPICE_CHANNEL_SWITCHING:
+    case SPICE_CHANNEL_CLOSED:
+    case SPICE_CHANNEL_ERROR_CONNECT:
+    case SPICE_CHANNEL_ERROR_TLS:
+    case SPICE_CHANNEL_ERROR_LINK:
+    case SPICE_CHANNEL_ERROR_AUTH:
+    case SPICE_CHANNEL_ERROR_IO:
+        g_signal_handlers_disconnect_by_func(channel, channel_event, user_data);
+        g_ptr_array_remove(self->priv->channels, channel);
+        return;
+    default:
+        g_warning("Unhandled SpiceChannelEvent %d, disconnecting usbredir %p", event, channel);
+        g_signal_handlers_disconnect_by_func(channel, channel_event, user_data);
+        g_ptr_array_remove(self->priv->channels, channel);
+    }
+}
+
 static void spice_usb_device_manager_auto_connect_cb(GObject      *gobject,
                                                      GAsyncResult *res,
                                                      gpointer      user_data)
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]