[Spice-devel] [PATCH 1/5] build: add build option for non-winusb redirection backends
Kirill Moizik
kirill at daynix.com
Thu May 28 03:24:00 PDT 2015
From: Dmitry Fleytman <dmitry at daynix.com>
--enable-winusb configure option added
This option actually disables winusb driver installation
for the USB device being redirected.
Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
---
configure.ac | 12 ++++++++++++
gtk/Makefile.am | 11 +++++++++--
gtk/usb-device-manager.c | 20 +++++++++++---------
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4e88dec..073a2ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -422,6 +422,18 @@ else
fi
AM_CONDITIONAL([WITH_USBREDIR], [test "x$have_usbredir" = "xyes"])
+AC_ARG_ENABLE([winusb],
+ [AC_HELP_STRING([--enable-winusb], [use Winusb/Usbclerk for USB redirection [default=yes]])],
+ [], [enable_winusb="yes"])
+ if test "x$enable_winusb" = "xyes" && \
+ test "x$have_usbredir" = "xyes" && \
+ test "x$os_win32" = "xyes"; then
+ AC_DEFINE(USE_WINUSB, 1, [use Winusb/Usbclerk for USB redirection])
+ fi
+
+ AC_SUBST(USE_WINUSB)
+ AM_CONDITIONAL([WITH_WINUSB], [test "x$enable_winusb" = "xyes"])
+
AC_ARG_ENABLE([polkit],
AS_HELP_STRING([--enable-polkit=@<:@auto/yes/no@:>@],
[Enable PolicyKit support (for the usb acl helper)@<:@default=auto@:>@]),
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 7728fec..ed35f47 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -359,10 +359,13 @@ libspice_client_glib_2_0_la_SOURCES += coroutine_gthread.c
libspice_client_glib_2_0_la_LIBADD += $(GTHREAD_LIBS)
endif
+WIN_FILES =\
+ win-usb-dev.h \
+ win-usb-dev.c \
+ $(NULL)
+
WIN_USB_FILES= \
- win-usb-dev.h \
- win-usb-dev.c \
win-usb-clerk.h \
win-usb-driver-install.h \
win-usb-driver-install.c \
@@ -371,8 +374,12 @@ WIN_USB_FILES= \
if OS_WIN32
if WITH_USBREDIR
libspice_client_glib_2_0_la_SOURCES += \
+ $(WIN_FILES)
+if WITH_WINUSB
+libspice_client_glib_2_0_la_SOURCES += \
$(WIN_USB_FILES)
endif
+endif
libspice_client_glib_2_0_la_LIBADD += -lws2_32 -lgdi32
endif
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index e11eae0..e1f03e2 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -33,7 +33,9 @@
#include <gudev/gudev.h>
#elif defined(G_OS_WIN32)
#include "win-usb-dev.h"
+#if defined(USE_WINUSB)
#include "win-usb-driver-install.h"
+#endif
#define USE_GUDEV /* win-usb-dev.h provides a fake gudev interface */
#elif !defined USE_LIBUSB_HOTPLUG
#error "Expecting one of USE_GUDEV or USE_LIBUSB_HOTPLUG to be defined"
@@ -120,7 +122,7 @@ struct _SpiceUsbDeviceManagerPrivate {
#else
libusb_hotplug_callback_handle hp_handle;
#endif
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
SpiceWinUsbDriver *installer;
#endif
#endif
@@ -179,7 +181,7 @@ static SpiceUsbDeviceInfo *spice_usb_device_new(libusb_device *libdev);
static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *device);
static void spice_usb_device_unref(SpiceUsbDevice *device);
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
static guint8 spice_usb_device_get_state(SpiceUsbDevice *device);
static void spice_usb_device_set_state(SpiceUsbDevice *device, guint8 s);
#endif
@@ -208,7 +210,7 @@ G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref, g_object_unr
static void spice_usb_device_manager_initable_iface_init(GInitableIface *iface);
#ifdef USE_USBREDIR
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
static void spice_usb_device_manager_drv_install_cb(GObject *gobject,
GAsyncResult *res,
gpointer user_data);
@@ -371,7 +373,7 @@ static void spice_usb_device_manager_finalize(GObject *gobject)
libusb_exit(priv->context);
free(priv->auto_conn_filter_rules);
free(priv->redirect_on_connect_rules);
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
if (priv->installer)
g_object_unref(priv->installer);
#endif
@@ -923,7 +925,7 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager *self,
return;
}
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
const guint8 state = spice_usb_device_get_state(device);
if ((state == SPICE_USB_DEVICE_STATE_INSTALLING) ||
(state == SPICE_USB_DEVICE_STATE_UNINSTALLING)) {
@@ -1077,7 +1079,7 @@ static void spice_usb_device_manager_channel_connect_cb(
g_object_unref(result);
}
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
typedef struct _UsbInstallCbInfo {
SpiceUsbDeviceManager *manager;
@@ -1488,7 +1490,7 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
gpointer user_data)
{
-#if defined(USE_USBREDIR) && defined(G_OS_WIN32)
+#if defined(USE_USBREDIR) && defined(USE_WINUSB)
SpiceWinUsbDriver *installer;
UsbInstallCbInfo *cbinfo;
@@ -1555,7 +1557,7 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
if (channel)
spice_usbredir_channel_disconnect_device(channel);
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
SpiceWinUsbDriver *installer;
UsbInstallCbInfo *cbinfo;
guint8 state;
@@ -1800,7 +1802,7 @@ guint16 spice_usb_device_get_pid(const SpiceUsbDevice *device)
return info->pid;
}
-#ifdef G_OS_WIN32
+#ifdef USE_WINUSB
void spice_usb_device_set_state(SpiceUsbDevice *device, guint8 state)
{
SpiceUsbDeviceInfo *info = (SpiceUsbDeviceInfo *)device;
--
2.1.0
More information about the Spice-devel
mailing list