Signed-off-by: Dmitry Fleytman <dmitry@xxxxxxxxxx> --- spice-common | 2 +- src/usb-device-manager.c | 108 ++++++++++++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 44 deletions(-) diff --git a/spice-common b/spice-common index f7ec855..2d054e0 160000 --- a/spice-common +++ b/spice-common @@ -1 +1 @@ -Subproject commit f7ec855af3deff18aeb43ddbf2467c565f4bf346 +Subproject commit 2d054e0e6901a1cfbe396f30d9899da46ff533d9 diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c index 4930613..78f038e 100644 --- a/src/usb-device-manager.c +++ b/src/usb-device-manager.c @@ -1396,6 +1396,68 @@ gboolean spice_usb_device_manager_is_device_connected(SpiceUsbDeviceManager *sel return !!spice_usb_device_manager_get_channel_for_dev(self, device); } +#if defined(USE_USBREDIR) && defined(G_OS_WIN32) + +static void +_spice_usb_device_manager_install_driver_async(SpiceUsbDeviceManager *self, + SpiceUsbDevice *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + SpiceWinUsbDriver *installer; + UsbInstallCbInfo *cbinfo; + + g_return_if_fail(self->priv->installer); + + spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_INSTALLING); + + installer = self->priv->installer; + cbinfo = g_new0(UsbInstallCbInfo, 1); + cbinfo->manager = self; + cbinfo->device = spice_usb_device_ref(device); + cbinfo->installer = installer; + cbinfo->cancellable = cancellable; + cbinfo->callback = callback; + cbinfo->user_data = user_data; + + spice_win_usb_driver_install_async(installer, device, cancellable, + spice_usb_device_manager_drv_install_cb, + cbinfo); +} + +static void +_spice_usb_device_manager_uninstall_driver_async(SpiceUsbDeviceManager *self, + SpiceUsbDevice *device) +{ + SpiceWinUsbDriver *installer; + UsbInstallCbInfo *cbinfo; + guint8 state; + + g_warn_if_fail(device != NULL); + g_return_if_fail(self->priv->installer); + + state = spice_usb_device_get_state(device); + if ((state != SPICE_USB_DEVICE_STATE_INSTALLED) && + (state != SPICE_USB_DEVICE_STATE_CONNECTED)) { + return; + } + + spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING); + + installer = self->priv->installer; + cbinfo = g_new0(UsbInstallCbInfo, 1); + cbinfo->manager = self; + cbinfo->device = spice_usb_device_ref(device); + cbinfo->installer = installer; + + spice_win_usb_driver_uninstall_async(installer, device, NULL, + spice_usb_device_manager_drv_uninstall_cb, + cbinfo); +} + +#endif + static void _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, SpiceUsbDevice *device, @@ -1491,25 +1553,8 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, { #if defined(USE_USBREDIR) && defined(G_OS_WIN32) - SpiceWinUsbDriver *installer; - UsbInstallCbInfo *cbinfo; - - g_return_if_fail(self->priv->installer); - - spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_INSTALLING); - - installer = self->priv->installer; - cbinfo = g_new0(UsbInstallCbInfo, 1); - cbinfo->manager = self; - cbinfo->device = spice_usb_device_ref(device); - cbinfo->installer = installer; - cbinfo->cancellable = cancellable; - cbinfo->callback = callback; - cbinfo->user_data = user_data; - - spice_win_usb_driver_install_async(installer, device, cancellable, - spice_usb_device_manager_drv_install_cb, - cbinfo); + _spice_usb_device_manager_install_driver_async(self, device, cancellable, + callback, user_data); #else _spice_usb_device_manager_connect_device_async(self, device, @@ -1569,30 +1614,7 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self, spice_usbredir_channel_disconnect_device(channel); #ifdef G_OS_WIN32 - SpiceWinUsbDriver *installer; - UsbInstallCbInfo *cbinfo; - guint8 state; - - g_warn_if_fail(device != NULL); - g_return_if_fail(self->priv->installer); - - state = spice_usb_device_get_state(device); - if ((state != SPICE_USB_DEVICE_STATE_INSTALLED) && - (state != SPICE_USB_DEVICE_STATE_CONNECTED)) { - return; - } - - spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING); - - installer = self->priv->installer; - cbinfo = g_new0(UsbInstallCbInfo, 1); - cbinfo->manager = self; - cbinfo->device = spice_usb_device_ref(device); - cbinfo->installer = installer; - - spice_win_usb_driver_uninstall_async(installer, device, NULL, - spice_usb_device_manager_drv_uninstall_cb, - cbinfo); + _spice_usb_device_manager_uninstall_driver_async(self, device); #endif #endif -- 2.4.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel