[Spice-devel] [spice-gtk Win32 v4 09/17] Win32/mingw: usb-device-manager: uninstall win usb driver upon device disconnect

Uri Lublin uril at redhat.com
Thu Jul 5 13:44:01 PDT 2012


---
 gtk/usb-device-manager.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 224b7e8..d9ed8a7 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -727,6 +727,7 @@ typedef struct _UsbInstallCbInfo {
     GCancellable          *cancellable;
     GAsyncReadyCallback   callback;
     gpointer              user_data;
+    gboolean              is_install;
 } UsbInstallCbInfo;

 /**
@@ -764,6 +765,7 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject,
     cancellable = cbinfo->cancellable;
     callback    = cbinfo->callback;
     user_data   = cbinfo->user_data;
+    is_install  = cbinfo->is_install;

     g_free(cbinfo);

@@ -1064,6 +1066,7 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
     cbinfo->cancellable = cancellable;
     cbinfo->callback    = callback;
     cbinfo->user_data   = user_data;
+    cbinfo->is_install  = TRUE;
     spice_win_usb_driver_install(installer, device, NULL,
                                  spice_usb_device_manager_drv_install_cb,
                                  cbinfo);
@@ -1113,6 +1116,28 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
     channel = spice_usb_device_manager_get_channel_for_dev(self, device);
     if (channel)
         spice_usbredir_channel_disconnect_device(channel);
+
+#ifdef G_OS_WIN32
+    SpiceWinUsbDriver *installer;
+    UsbInstallCbInfo *cbinfo;
+
+    g_warn_if_fail(device != NULL);
+
+    installer = spice_win_usb_driver_new();
+    cbinfo = g_new0(UsbInstallCbInfo, 1);
+    cbinfo->manager     = self;
+    cbinfo->device      = spice_usb_device_ref(device);
+    cbinfo->installer   = installer;
+    cbinfo->cancellable = NULL;
+    cbinfo->callback    = NULL;
+    cbinfo->user_data   = NULL;
+    cbinfo->is_install  = FALSE;
+
+    spice_win_usb_driver_uninstall(installer, device, NULL,
+                                   spice_usb_device_manager_drv_install_cb,
+                                   cbinfo);
+#endif
+
 #endif
 }

-- 
1.7.7.6



More information about the Spice-devel mailing list