On Sun, Aug 16, 2015 at 03:35:45PM +0300, Dmitry Fleytman wrote: > From: Kirill Moizik <kmoizik@xxxxxxxxxx> > > Signed-off-by: Kirill Moizik <kmoizik@xxxxxxxxxx> > Signed-off-by: Dmitry Fleytman <dfleytma@xxxxxxxxxx> > --- > src/usb-device-manager.c | 71 ++++++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 62 insertions(+), 9 deletions(-) > > diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c > index af2c87a..f133907 100644 > --- a/src/usb-device-manager.c > +++ b/src/usb-device-manager.c > @@ -122,6 +122,7 @@ struct _SpiceUsbDeviceManagerPrivate { > GUdevClient *udev; > libusb_device **coldplug_list; /* Avoid needless reprobing during init */ > #else > + gboolean redirecting; > libusb_hotplug_callback_handle hp_handle; > #endif > #ifdef G_OS_WIN32 > @@ -205,10 +206,25 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, > GAsyncReadyCallback callback, > gpointer user_data); > > +static > +void _connect_device_async_cb(GObject *gobject, > + GAsyncResult *channel_res, > + gpointer user_data); > + > G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, > (GBoxedCopyFunc)spice_usb_device_ref, > (GBoxedFreeFunc)spice_usb_device_unref) > > +static void > +_set_redirecting(SpiceUsbDeviceManager *self, gboolean is_redirecting) > +{ > +#ifdef USE_GUDEV > + g_object_set(self->priv->udev, "redirecting", is_redirecting, NULL); > +#else > + self->priv->redirecting = is_redirecting; > +#endif > +} > + > #else > G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref, g_object_unref) > #endif > @@ -1103,6 +1119,13 @@ static void spice_usb_device_manager_channel_connect_cb( > g_object_unref(result); > } > > +typedef struct _connect_cb_data > +{ > + SpiceUsbDeviceManager *self; > + GAsyncReadyCallback callback; > + gpointer user_data; > +} connect_cb_data; > + This looks like a GSimpleAsyncResult could be passed around instead of this new structure? > #ifdef G_OS_WIN32 > > typedef struct _UsbInstallCbInfo { > @@ -1138,7 +1161,7 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject, > SpiceUsbDevice *device; > UsbInstallCbInfo *cbinfo; > GCancellable *cancellable; > - GAsyncReadyCallback callback; > + connect_cb_data *data; > > g_return_if_fail(user_data != NULL); > > @@ -1147,8 +1170,7 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject, > device = cbinfo->device; > installer = cbinfo->installer; > cancellable = cbinfo->cancellable; > - callback = cbinfo->callback; > - user_data = cbinfo->user_data; > + data = cbinfo->user_data; > > g_free(cbinfo); > > @@ -1170,8 +1192,8 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject, > _spice_usb_device_manager_connect_device_async(self, > device, > cancellable, > - callback, > - user_data); > + _connect_device_async_cb, > + data); > > spice_usb_device_unref(device); > } > @@ -1552,8 +1574,17 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, > GAsyncReadyCallback callback, > gpointer user_data) > { > + g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self)); > +#ifdef USE_USBREDIR > + _set_redirecting(self, TRUE); > + > + connect_cb_data *data = g_new(connect_cb_data, 1); > + data->self = self; > + data->callback = callback; > + data->user_data = user_data; > + > if (self->priv->use_usbclerk) { > -#if defined(USE_USBREDIR) && defined(G_OS_WIN32) > +#ifdef G_OS_WIN32 > SpiceWinUsbDriver *installer; > UsbInstallCbInfo *cbinfo; > > @@ -1568,7 +1599,7 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, > cbinfo->installer = installer; > cbinfo->cancellable = cancellable; > cbinfo->callback = callback; > - cbinfo->user_data = user_data; > + cbinfo->user_data = data; > > spice_win_usb_driver_install_async(installer, device, cancellable, > spice_usb_device_manager_drv_install_cb, > @@ -1580,9 +1611,10 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, > _spice_usb_device_manager_connect_device_async(self, > device, > cancellable, > - callback, > - user_data); > + _connect_device_async_cb, > + data); > } > +#endif > } > > gboolean spice_usb_device_manager_connect_device_finish( > @@ -1600,6 +1632,27 @@ gboolean spice_usb_device_manager_connect_device_finish( > return TRUE; > } > > +#ifdef USE_USBREDIR > +static > +void _connect_device_async_cb(GObject *gobject, > + GAsyncResult *channel_res, > + gpointer user_data) > +{ > + connect_cb_data *data = user_data; > + GSimpleAsyncResult *result = g_simple_async_result_new( > + G_OBJECT(data->self), > + data->callback, > + data->user_data, > + spice_usb_device_manager_connect_device_async); > + > + _set_redirecting(data->self, FALSE); > + > + g_simple_async_result_complete(result); > + g_object_unref(result); > + g_free(data); > +} > +#endif > + > /** > * spice_usb_device_manager_disconnect_device: > * @manager: the #SpiceUsbDeviceManager manager > -- > 2.4.3 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
pgpun1UPD3O4W.pgp
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel