87 lines
3.4 KiB
Diff
87 lines
3.4 KiB
Diff
From 99d4b13ecea8c16987b2b4aa68a0829a21130e30 Mon Sep 17 00:00:00 2001
|
|
From: Hans de Goede <hdegoede@redhat.com>
|
|
Date: Fri, 21 Sep 2012 15:32:24 +0000
|
|
Subject: [PATCH 10/21] UsbDeviceManager: Hookup redirect-on-connect property
|
|
|
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Resolves: rhbz#820964
|
|
---
|
|
gtk/usb-device-manager.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 47 insertions(+)
|
|
|
|
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
|
|
index c30e67b..539cefe 100644
|
|
--- a/gtk/usb-device-manager.c
|
|
+++ b/gtk/usb-device-manager.c
|
|
@@ -147,6 +147,8 @@ static void spice_usb_device_manager_uevent_cb(GUdevClient *client,
|
|
gpointer user_data);
|
|
static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager *self,
|
|
GUdevDevice *udev);
|
|
+static void spice_usb_device_manager_check_redir_on_connect(
|
|
+ SpiceUsbDeviceManager *self, SpiceChannel *channel);
|
|
|
|
static SpiceUsbDeviceInfo *spice_usb_device_new(libusb_device *libdev);
|
|
static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *device);
|
|
@@ -611,6 +613,8 @@ static void channel_new(SpiceSession *session, SpiceChannel *channel,
|
|
self->priv->context);
|
|
spice_channel_connect(channel);
|
|
g_ptr_array_add(self->priv->channels, channel);
|
|
+
|
|
+ spice_usb_device_manager_check_redir_on_connect(self, channel);
|
|
}
|
|
}
|
|
|
|
@@ -962,6 +966,49 @@ void spice_usb_device_manager_stop_event_listening(
|
|
priv->event_thread_run = FALSE;
|
|
}
|
|
|
|
+static void spice_usb_device_manager_check_redir_on_connect(
|
|
+ SpiceUsbDeviceManager *self, SpiceChannel *channel)
|
|
+{
|
|
+ SpiceUsbDeviceManagerPrivate *priv = self->priv;
|
|
+ GSimpleAsyncResult *result;
|
|
+ SpiceUsbDevice *device;
|
|
+ libusb_device *libdev;
|
|
+ guint i;
|
|
+
|
|
+ if (priv->redirect_on_connect == NULL)
|
|
+ return;
|
|
+
|
|
+ for (i = 0; i < priv->devices->len; i++) {
|
|
+ device = g_ptr_array_index(priv->devices, i);
|
|
+
|
|
+ if (spice_usb_device_manager_is_device_connected(self, device))
|
|
+ continue;
|
|
+
|
|
+ libdev = spice_usb_device_manager_device_to_libdev(self, device);
|
|
+
|
|
+ if (usbredirhost_check_device_filter(
|
|
+ priv->redirect_on_connect_rules,
|
|
+ priv->redirect_on_connect_rules_count,
|
|
+ libdev, 0) == 0) {
|
|
+ /* Note: re-uses spice_usb_device_manager_connect_device_async's
|
|
+ completion handling code! */
|
|
+ result = g_simple_async_result_new(G_OBJECT(self),
|
|
+ spice_usb_device_manager_auto_connect_cb,
|
|
+ spice_usb_device_ref(device),
|
|
+ spice_usb_device_manager_connect_device_async);
|
|
+ spice_usbredir_channel_connect_device_async(
|
|
+ SPICE_USBREDIR_CHANNEL(channel),
|
|
+ libdev, device, NULL,
|
|
+ spice_usb_device_manager_channel_connect_cb,
|
|
+ result);
|
|
+ libusb_unref_device(libdev);
|
|
+ return; /* We've taken the channel! */
|
|
+ }
|
|
+
|
|
+ libusb_unref_device(libdev);
|
|
+ }
|
|
+}
|
|
+
|
|
void spice_usb_device_manager_device_error(
|
|
SpiceUsbDeviceManager *self, SpiceUsbDevice *device, GError *err)
|
|
{
|
|
--
|
|
1.7.12.1
|
|
|