[Spice-commits] 5 commits - src/usb-device-manager.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 11 13:35:18 UTC 2019
src/usb-device-manager.c | 52 +++++++++++++++++++----------------------------
1 file changed, 22 insertions(+), 30 deletions(-)
New commits:
commit 397f397c63268a5553895e6acd31ce07ab4d403a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun May 5 12:58:47 2019 +0100
usb-device-manager: Minor style fixes
Fix space.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index dbb7839..c270e1c 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -1716,7 +1716,7 @@ void _usbdk_hider_update(SpiceUsbDeviceManager *manager)
return;
}
- if(_usbdk_hider_prepare(manager)) {
+ if (_usbdk_hider_prepare(manager)) {
usbdk_api_set_hide_rules(priv->usbdk_api,
priv->usbdk_hider_handle,
priv->auto_connect_filter);
commit 1655acd0d3dae8ca1489f54503bb13293ef287c1
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun May 5 11:40:36 2019 +0100
usb-device-manager: Move devices and channels to USE_USBREDIR section
These fields are not used if USE_USBREDIR is not set.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 4b12689..dbb7839 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -108,9 +108,9 @@ struct _SpiceUsbDeviceManagerPrivate {
#else
gboolean redirecting; /* Handled by GUdevClient in the gudev case */
#endif
-#endif
GPtrArray *devices;
GPtrArray *channels;
+#endif
};
enum {
@@ -246,8 +246,8 @@ static void spice_usb_device_manager_init(SpiceUsbDeviceManager *self)
spice_debug("UsbDk driver is not installed");
}
#endif
- priv->channels = g_ptr_array_new();
#ifdef USE_USBREDIR
+ priv->channels = g_ptr_array_new();
priv->devices = g_ptr_array_new_with_free_func((GDestroyNotify)
spice_usb_device_unref);
#endif
@@ -343,11 +343,11 @@ static void spice_usb_device_manager_finalize(GObject *gobject)
SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(gobject);
SpiceUsbDeviceManagerPrivate *priv = self->priv;
+#ifdef USE_USBREDIR
g_ptr_array_unref(priv->channels);
- if (priv->devices)
+ if (priv->devices) {
g_ptr_array_unref(priv->devices);
-
-#ifdef USE_USBREDIR
+ }
#ifdef G_OS_WIN32
g_clear_object(&priv->udev);
#endif
commit 0bad866a2efd7b2a71c8ec3ee47414067745a4d7
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun May 5 11:39:45 2019 +0100
usb-device-manager: Put all Unix code in spice_usb_device_manager_initable_init together
This reduces conditional code.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 0a97921..4b12689 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -267,14 +267,6 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
GList *list;
GList *it;
-#ifndef G_OS_WIN32
- /* Initialize libusb */
- priv->context = spice_usb_backend_new(err);
- if (!priv->context) {
- return FALSE;
- }
-#endif
-
/* Start listening for usb devices plug / unplug */
#ifdef G_OS_WIN32
priv->udev = g_udev_client_new();
@@ -288,6 +280,12 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
/* Do coldplug (detection of already connected devices) */
g_udev_client_report_devices(priv->udev);
#else
+ /* Initialize libusb */
+ priv->context = spice_usb_backend_new(err);
+ if (!priv->context) {
+ return FALSE;
+ }
+
if (!spice_usb_backend_register_hotplug(priv->context, self,
spice_usb_device_manager_hotplug_cb)) {
return FALSE;
commit ffc9a2495104c00831075db8fda5397dbd786a68
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun May 5 11:39:17 2019 +0100
usb-device-manager: Reduce some conditional code handling !USE_USBREDIR first
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 479558f..0a97921 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -213,19 +213,15 @@ G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref, g_object_unr
*/
gboolean spice_usb_device_manager_is_redirecting(SpiceUsbDeviceManager *self)
{
-#ifdef USE_USBREDIR
-
-#ifdef G_OS_WIN32
+#ifndef USE_USBREDIR
+ return FALSE;
+#elif defined(G_OS_WIN32)
gboolean redirecting;
g_object_get(self->priv->udev, "redirecting", &redirecting, NULL);
return redirecting;
#else
return self->priv->redirecting;
#endif
-
-#else
- return FALSE;
-#endif
}
static void spice_usb_device_manager_initable_iface_init(GInitableIface *iface);
@@ -261,7 +257,11 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
GCancellable *cancellable,
GError **err)
{
-#ifdef USE_USBREDIR
+#ifndef USE_USBREDIR
+ g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+ _("USB redirection support not compiled in"));
+ return FALSE;
+#else
SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(initable);
SpiceUsbDeviceManagerPrivate *priv = self->priv;
GList *list;
@@ -306,10 +306,6 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
g_list_free(list);
return TRUE;
-#else
- g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
- _("USB redirection support not compiled in"));
- return FALSE;
#endif
}
commit 7de90b18174b6b194e12fd3e136b62a68ea147ba
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun May 5 11:38:23 2019 +0100
usb-device-manager: Put all windows field in a single #if section
This reduces conditional code.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 860f5c1..479558f 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -103,13 +103,11 @@ struct _SpiceUsbDeviceManagerPrivate {
int redirect_on_connect_rules_count;
#ifdef G_OS_WIN32
GUdevClient *udev;
+ usbdk_api_wrapper *usbdk_api;
+ HANDLE usbdk_hider_handle;
#else
gboolean redirecting; /* Handled by GUdevClient in the gudev case */
#endif
-#ifdef G_OS_WIN32
- usbdk_api_wrapper *usbdk_api;
- HANDLE usbdk_hider_handle;
-#endif
#endif
GPtrArray *devices;
GPtrArray *channels;
More information about the Spice-commits
mailing list