<div dir="ltr">+1<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 2, 2015 at 4:41 PM, Kirill Moizik <span dir="ltr"><<a href="mailto:kirill@daynix.com" target="_blank">kirill@daynix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">encapsulate preparations for win_usb_driver_uninstall in function to prevent further code duplication<br>
<br>
Signed-off-by: Kirill Moizik <<a href="mailto:kmoizik@redhat.com">kmoizik@redhat.com</a>><br>
---<br>
 src/usb-device-manager.c | 58 +++++++++++++++++++++++++++---------------------<br>
 1 file changed, 33 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c<br>
index 2fde03a..db4944f 100644<br>
--- a/src/usb-device-manager.c<br>
+++ b/src/usb-device-manager.c<br>
@@ -1203,6 +1203,37 @@ static void spice_usb_device_manager_drv_uninstall_cb(GObject *gobject,<br>
<br>
 #endif<br>
<br>
+#if defined(USE_USBREDIR) && defined(G_OS_WIN32)<br>
+void  spice_usb_device_manager_driver_uninstall_async(SpiceUsbDeviceManager *self,<br>
+                                                      SpiceUsbDevice *device)<br>
+{<br>
+<br>
+    SpiceWinUsbDriver *installer;<br>
+    UsbInstallCbInfo *cbinfo;<br>
+    guint8 state;<br>
+<br>
+    g_warn_if_fail(device != NULL);<br>
+    g_return_if_fail(self->priv->installer);<br>
+<br>
+    state = spice_usb_device_get_state(device);<br>
+    if ((state != SPICE_USB_DEVICE_STATE_INSTALLED) &&<br>
+        (state != SPICE_USB_DEVICE_STATE_CONNECTED)) {<br>
+        return;<br>
+    }<br>
+<br>
+    spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING);<br>
+<br>
+    installer = self->priv->installer;<br>
+    cbinfo = g_new0(UsbInstallCbInfo, 1);<br>
+    cbinfo->manager     = self;<br>
+    cbinfo->device      = spice_usb_device_ref(device);<br>
+    cbinfo->installer   = installer;<br>
+    spice_win_usb_driver_uninstall_async (installer, device, NULL,<br>
+                                          spice_usb_device_manager_drv_uninstall_cb,<br>
+                                          cbinfo);<br>
+}<br>
+#endif<br>
+<br>
 /* ------------------------------------------------------------------ */<br>
 /* private api                                                        */<br>
<br>
@@ -1590,31 +1621,8 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,<br>
         spice_usbredir_channel_disconnect_device(channel);<br>
<br>
 #ifdef G_OS_WIN32<br>
-   if (self->priv->use_usbclerk) {<br>
-        SpiceWinUsbDriver *installer;<br>
-        UsbInstallCbInfo *cbinfo;<br>
-        guint8 state;<br>
-<br>
-        g_warn_if_fail(device != NULL);<br>
-        g_return_if_fail(self->priv->installer);<br>
-<br>
-        state = spice_usb_device_get_state(device);<br>
-        if ((state != SPICE_USB_DEVICE_STATE_INSTALLED) &&<br>
-           (state != SPICE_USB_DEVICE_STATE_CONNECTED)) {<br>
-           return;<br>
-        }<br>
-<br>
-        spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING);<br>
-<br>
-        installer = self->priv->installer;<br>
-        cbinfo = g_new0(UsbInstallCbInfo, 1);<br>
-        cbinfo->manager     = self;<br>
-        cbinfo->device      = spice_usb_device_ref(device);<br>
-        cbinfo->installer   = installer;<br>
-<br>
-        spice_win_usb_driver_uninstall_async (installer, device, NULL,<br>
-                                       spice_usb_device_manager_drv_uninstall_cb,<br>
-                                       cbinfo);<br>
+    if (self->priv->use_usbclerk) {<br>
+        spice_usb_device_manager_driver_uninstall_async(self,device);<br>
     }<br>
 #endif<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.1.0<br>
<br>
</font></span></blockquote></div><br></div></div>