Re: [PATCH v2 2/6] WinUsbDev: add redirecting state to GUdevClientPrivate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 07, 2015 at 01:57:45PM +0300, Kirill Moizik wrote:
> > >
> > > +void spice_g_udev_set_redirecting (gboolean val)
> > > +{
> > > +    GUdevClientPrivate *priv = singleton->priv;
> > > +    priv->redirecting = val;
> > > +}
> >
> > I still think we should have something like
> > if (priv->redirecting && !val) {
> >     handle_dev_change(singleton);
> > }
> >
> > and not export spice_g_udev_handle_device_change() as updating the
> > device list is required anyway when redirecting changes from TRUE to
> > FALSE. Doing it automatically makes using the API less error-prone...
> >
> >
> The problem is not to prevent call  handle_dev_change from  the
> usb-device-widget.c
> I agree with you here, in this case it is better solution. The problem is
> here
> 
> static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam,
> LPARAM lparam)
> 
> {
> 
>     /* Only DBT_DEVNODES_CHANGED recieved */
> 
>     if (message == WM_DEVICECHANGE) {
> 
>         handle_dev_change(singleton);
> 
>     }
> 
>     return DefWindowProc(hwnd, message, wparam, lparam);
> 
> }
> 
> 
> It is a registered system callback. The only context available when it is
> called is GUdevClient singleton object.

I'm not sure I made myself clear, see the attached patch for what I'm
suggesting.

Christophe

diff --git a/src/map-file b/src/map-file
index d14a18d..2b938c7 100644
--- a/src/map-file
+++ b/src/map-file
@@ -118,7 +118,6 @@ spice_usb_device_get_description;
 spice_usb_device_get_libusb_device;
 spice_usb_device_get_type;
 spice_g_udev_set_redirecting;
-spice_g_udev_handle_device_change;
 spice_usb_device_manager_disconnect_device_async;
 spice_usb_device_manager_can_redirect_device;
 spice_usb_device_manager_connect_device_async;
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 85f3057..78a4723 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -460,9 +460,6 @@ static void set_redirecting(SpiceUsbDeviceWidget *self, gboolean val)
                                      GTK_MESSAGE_INFO,
                                      GTK_STOCK_DIALOG_INFO);
     } else {
-#ifndef USE_LIBUSB_HOTPLUG
-        spice_g_udev_handle_device_change();
-#endif
         spice_usb_device_widget_hide_info_bar(self);
     }
     gtk_container_foreach(GTK_CONTAINER(self),
diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 23bea42..c42273f 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -336,10 +336,16 @@ static gboolean gudev_devices_are_equal(GUdevDevice *a, GUdevDevice *b)
     return (same_pid && same_vid);
 }
 
-void spice_g_udev_set_redirecting (gboolean val)
+static void handle_dev_change(GUdevClient *self);
+
+void spice_g_udev_set_redirecting(gboolean val)
 {
     GUdevClientPrivate *priv = singleton->priv;
+    gboolean redirecting_end;
+    redirecting_end = (priv->redirecting && !val);
     priv->redirecting = val;
+    if (redirecting_end)
+        handle_dev_change(singleton);
 }
 
 /* Assumes each event stands for a single device change (at most) */
@@ -419,11 +425,6 @@ leave:
     priv->udev_list_size = dev_count;
 }
 
-void spice_g_udev_handle_device_change(void)
-{
-    handle_dev_change(singleton);
-}
-
 static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 {
     /* Only DBT_DEVNODES_CHANGED recieved */
diff --git a/src/win-usb-dev.h b/src/win-usb-dev.h
index 080c89f..d656e73 100644
--- a/src/win-usb-dev.h
+++ b/src/win-usb-dev.h
@@ -87,7 +87,6 @@ const gchar *g_udev_device_get_property(GUdevDevice *udev, const gchar *property
 const gchar *g_udev_device_get_sysfs_attr(GUdevDevice *udev, const gchar *attr);
 
 void   spice_g_udev_set_redirecting(gboolean val);
-void   spice_g_udev_handle_device_change(void);
 GQuark g_udev_client_error_quark(void);
 #define G_UDEV_CLIENT_ERROR g_udev_client_error_quark()
 

Attachment: pgp9v6DUXPu9a.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]