Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> On Thu, 2016-02-11 at 18:04 +0200, Dmitry Fleytman wrote: > This is a refactoring done in preparation for the next commits. > > Signed-off-by: Dmitry Fleytman <dmitry@xxxxxxxxxx> > --- > src/usb-device-manager.c | 108 ++++++++++++++++++++++++++++------------------ > - > 1 file changed, 65 insertions(+), 43 deletions(-) > > diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c > index ee8e490..5bb8e17 100644 > --- a/src/usb-device-manager.c > +++ b/src/usb-device-manager.c > @@ -1447,6 +1447,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, > @@ -1542,25 +1604,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, > @@ -1620,30 +1665,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 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel