* tsmf: OSS code cleanup
+ urbdrc: add devd support (not tested) * fix FindUUID detection ubder BSD * wlog: fix prev commit: build error on Windows * cmdline: add /usb syntax help
This commit is contained in:
parent
1009268158
commit
83a40a32a7
@ -647,17 +647,6 @@ set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp/extensions")
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
if(BSD)
|
||||
if(IS_DIRECTORY /usr/local/include)
|
||||
include_directories(/usr/local/include)
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
if(OPENBSD)
|
||||
if(IS_DIRECTORY /usr/X11R6/include)
|
||||
include_directories(/usr/X11R6/include)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Configure files
|
||||
add_definitions("-DHAVE_CONFIG_H")
|
||||
@ -718,10 +707,6 @@ add_subdirectory(include)
|
||||
|
||||
add_subdirectory(libfreerdp)
|
||||
|
||||
if(WITH_CHANNELS)
|
||||
add_subdirectory(channels)
|
||||
endif()
|
||||
|
||||
if (IOS)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "")
|
||||
if (IOS_PLATFORM MATCHES "SIMULATOR")
|
||||
@ -737,6 +722,22 @@ include_directories("${CMAKE_BINARY_DIR}/rdtk/include")
|
||||
|
||||
add_subdirectory(rdtk)
|
||||
|
||||
if(BSD)
|
||||
if(IS_DIRECTORY /usr/local/include)
|
||||
include_directories(/usr/local/include)
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
if(OPENBSD)
|
||||
if(IS_DIRECTORY /usr/X11R6/include)
|
||||
include_directories(/usr/X11R6/include)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_CHANNELS)
|
||||
add_subdirectory(channels)
|
||||
endif()
|
||||
|
||||
if(WITH_CLIENT)
|
||||
add_subdirectory(client)
|
||||
endif()
|
||||
@ -745,6 +746,7 @@ if(WITH_SERVER)
|
||||
add_subdirectory(server)
|
||||
endif()
|
||||
|
||||
|
||||
# Exporting
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "2.8.10")
|
||||
|
@ -62,13 +62,20 @@ typedef struct _TSMFOSSAudioDevice {
|
||||
WLog_ERR(TAG, "%s: %i - %s", _text, _error, strerror(_error));
|
||||
|
||||
|
||||
static BOOL tsmf_oss_open_device(TSMFOssAudioDevice *oss) {
|
||||
static BOOL tsmf_oss_open(ITSMFAudioDevice *audio, const char *device) {
|
||||
int tmp;
|
||||
int error;
|
||||
TSMFOssAudioDevice *oss = (TSMFOssAudioDevice*)audio;
|
||||
|
||||
if (oss == NULL || oss->pcm_handle != -1)
|
||||
return FALSE;
|
||||
|
||||
if (device == NULL) { /* Default device. */
|
||||
strncpy(oss->dev_name, "/dev/dsp", sizeof(oss->dev_name));
|
||||
} else {
|
||||
strncpy(oss->dev_name, device, sizeof(oss->dev_name));
|
||||
}
|
||||
|
||||
if ((oss->pcm_handle = open(oss->dev_name, O_WRONLY)) < 0) {
|
||||
OSS_LOG_ERR("sound dev open failed", errno);
|
||||
oss->pcm_handle = -1;
|
||||
@ -104,20 +111,6 @@ static BOOL tsmf_oss_open_device(TSMFOssAudioDevice *oss) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL tsmf_oss_open(ITSMFAudioDevice *audio, const char *device) {
|
||||
TSMFOssAudioDevice *oss = (TSMFOssAudioDevice*)audio;
|
||||
|
||||
if (oss == NULL || oss->pcm_handle != -1)
|
||||
return FALSE;
|
||||
|
||||
if (device == NULL) {
|
||||
strncpy(oss->dev_name, "/dev/dsp", sizeof(oss->dev_name));
|
||||
} else {
|
||||
strncpy(oss->dev_name, device, sizeof(oss->dev_name));
|
||||
}
|
||||
return tsmf_oss_open_device(oss);
|
||||
}
|
||||
|
||||
static BOOL tsmf_oss_set_format(ITSMFAudioDevice *audio, UINT32 sample_rate, UINT32 channels, UINT32 bits_per_sample) {
|
||||
int tmp;
|
||||
TSMFOssAudioDevice *oss = (TSMFOssAudioDevice*)audio;
|
||||
|
@ -18,15 +18,28 @@
|
||||
define_channel("urbdrc")
|
||||
|
||||
if(NOT WIN32)
|
||||
find_package(DevD)
|
||||
find_package(UDev)
|
||||
find_package(UUID)
|
||||
find_package(DbusGlib)
|
||||
find_package(libusb-1.0)
|
||||
endif()
|
||||
|
||||
if(UDEV_FOUND AND UUID_FOUND AND DBUS_GLIB_FOUND AND LIBUSB_1_FOUND)
|
||||
set(URBDRC_DEPENDENCIES_FOUND TRUE)
|
||||
message(STATUS "Found all URBDRC dependencies")
|
||||
if(DEVD_FOUND OR UDEV_FOUND)
|
||||
if(UUID_FOUND AND DBUS_GLIB_FOUND AND LIBUSB_1_FOUND)
|
||||
set(URBDRC_DEPENDENCIES_FOUND TRUE)
|
||||
message(STATUS "Found all URBDRC dependencies")
|
||||
else()
|
||||
if(NOT UUID_FOUND)
|
||||
message(STATUS "URBDRC dependencie not found: UUID")
|
||||
endif()
|
||||
if(NOT DBUS_GLIB_FOUND)
|
||||
message(STATUS "URBDRC dependencie not found: DBUS_GLIB")
|
||||
endif()
|
||||
if(NOT LIBUSB_1_FOUND)
|
||||
message(STATUS "URBDRC dependencie not found: LIBUSB_1")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_CLIENT_CHANNELS)
|
||||
|
@ -39,8 +39,10 @@ add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE
|
||||
|
||||
set(${MODULE_PREFIX}_LIBS
|
||||
${DBUS_GLIB_LIBRARIES}
|
||||
${UDEV_LIBRARIES}
|
||||
${UUID_LIBRARIES})
|
||||
if (UDEV_FOUND AND UDEV_LIBRARIES)
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${UDEV_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp)
|
||||
|
||||
|
@ -1281,7 +1281,7 @@ static int urb_os_feature_descriptor_request(URBDRC_CHANNEL_CALLBACK * callback,
|
||||
|
||||
data_read_UINT32(data + 0, RequestId);
|
||||
data_read_BYTE(data + 4, Recipient); /** Recipient */
|
||||
Recipient = Recipient && 0x1f;
|
||||
Recipient = (Recipient & 0x1f); /* XXX: origin: Recipient && 0x1f !? */
|
||||
data_read_BYTE(data + 5, InterfaceNumber); /** InterfaceNumber */
|
||||
data_read_BYTE(data + 6, Ms_PageIndex); /** Ms_PageIndex */
|
||||
data_read_UINT16(data + 7, Ms_featureDescIndex); /** Ms_featureDescIndex */
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__linux__)
|
||||
#include <libudev.h>
|
||||
#endif
|
||||
|
||||
#include "libusb_udevice.h"
|
||||
|
||||
@ -455,8 +457,7 @@ static void print_status(enum libusb_transfer_status status)
|
||||
|
||||
static LIBUSB_DEVICE* udev_get_libusb_dev(int bus_number, int dev_number)
|
||||
{
|
||||
int i;
|
||||
ssize_t total_device;
|
||||
ssize_t i, total_device;
|
||||
LIBUSB_DEVICE** libusb_list;
|
||||
|
||||
total_device = libusb_get_device_list(NULL, &libusb_list);
|
||||
@ -492,7 +493,64 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(LIBUSB_DEVICE* libusb_dev)
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/* Get HUB handle */
|
||||
/* Get HUB handle */
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number) {
|
||||
int error;
|
||||
ssize_t i, total_device, ports_cnt;
|
||||
uint8_t port_numbers[16];
|
||||
LIBUSB_DEVICE **libusb_list;
|
||||
|
||||
total_device = libusb_get_device_list(NULL, &libusb_list);
|
||||
/* Look for device. */
|
||||
error = -1;
|
||||
for (i = 0; i < total_device; i ++) {
|
||||
if ((bus_number != libusb_get_bus_number(libusb_list[i])) ||
|
||||
(dev_number != libusb_get_device_address(libusb_list[i])))
|
||||
continue;
|
||||
error = libusb_open(libusb_list[i], &pdev->hub_handle);
|
||||
if (error < 0) {
|
||||
WLog_ERR(TAG,"libusb_open error: %i - %s", error, libusb_strerror(error));
|
||||
break;
|
||||
}
|
||||
/* get port number */
|
||||
error = libusb_get_port_numbers(libusb_list[i], port_numbers, sizeof(port_numbers));
|
||||
libusb_close(pdev->hub_handle);
|
||||
if (error < 1) { /* Prevent open hub, treat as error. */
|
||||
WLog_ERR(TAG,"libusb_get_port_numbers error: %i - %s", error, libusb_strerror(error));
|
||||
break;
|
||||
}
|
||||
pdev->port_number = port_numbers[(error - 1)];
|
||||
error = 0;
|
||||
WLog_DBG(TAG, " Port: %d", pdev->port_number);
|
||||
/* gen device path */
|
||||
sprintf(pdev->path, "ugen%d.%d", bus_number, dev_number);
|
||||
WLog_DBG(TAG, " DevPath: %s", pdev->path);
|
||||
break;
|
||||
}
|
||||
/* Look for device hub. */
|
||||
if (error == 0) {
|
||||
error = -1;
|
||||
for (i = 0; i < total_device; i ++) {
|
||||
if ((bus_number != libusb_get_bus_number(libusb_list[i])) ||
|
||||
(1 != libusb_get_device_address(libusb_list[i]))) /* Root hub allways first on bus. */
|
||||
continue;
|
||||
WLog_DBG(TAG, " Open hub: %d", bus_number);
|
||||
error = libusb_open(libusb_list[i], &pdev->hub_handle);
|
||||
if (error < 0)
|
||||
WLog_ERR(TAG,"libusb_open error: %i - %s", error, libusb_strerror(error));
|
||||
break;
|
||||
}
|
||||
}
|
||||
libusb_free_device_list(libusb_list, 1);
|
||||
|
||||
if (error < 0)
|
||||
return -1;
|
||||
WLog_DBG(TAG, "libusb_open success!");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#if defined(__linux__)
|
||||
static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_number)
|
||||
{
|
||||
struct udev* udev;
|
||||
@ -627,6 +685,7 @@ static int udev_get_hub_handle(UDEVICE* pdev, UINT16 bus_number, UINT16 dev_numb
|
||||
/* Success! */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting)
|
||||
{
|
||||
@ -1211,6 +1270,7 @@ static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStat
|
||||
UDEVICE* pdev = (UDEVICE*) idev;
|
||||
int success = 0, ret;
|
||||
|
||||
WLog_DBG(TAG,"...");
|
||||
if (pdev->hub_handle != NULL)
|
||||
{
|
||||
ret = idev->control_transfer(idev, 0xffff, 0, 0,
|
||||
@ -1815,10 +1875,10 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray)
|
||||
UDEVICE** array;
|
||||
UINT16 bus_number;
|
||||
UINT16 dev_number;
|
||||
ssize_t total_device;
|
||||
int i, status, num = 0;
|
||||
ssize_t i, total_device;
|
||||
int status, num = 0;
|
||||
|
||||
WLog_ERR(TAG, "VID: 0x%04X PID: 0x%04X", idVendor, idProduct);
|
||||
WLog_INFO(TAG, "VID: 0x%04X, PID: 0x%04X", idVendor, idProduct);
|
||||
|
||||
array = (UDEVICE**) malloc(16 * sizeof(UDEVICE*));
|
||||
|
||||
@ -1839,7 +1899,7 @@ int udev_new_by_id(UINT16 idVendor, UINT16 idProduct, IUDEVICE*** devArray)
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "libusb_open: (by id) error: 0x%08X (%d)", status, status);
|
||||
WLog_ERR(TAG, "libusb_open: (by id) error: 0x%08X (%d)", status, status);
|
||||
zfree(descriptor);
|
||||
zfree(array[num]);
|
||||
continue;
|
||||
|
@ -23,7 +23,11 @@
|
||||
#ifndef __LIBUSB_UDEVICE_H
|
||||
#define __LIBUSB_UDEVICE_H
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
#include "urbdrc_types.h"
|
||||
#include "request_queue.h"
|
||||
|
@ -610,5 +610,7 @@ int freerdp_urbdrc_client_subsystem_entry(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS p
|
||||
|
||||
pEntryPoints->pRegisterUDEVMAN(pEntryPoints->plugin, (IUDEVMAN*) udevman);
|
||||
|
||||
WLog_DBG(TAG, "UDEVMAN device registered.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,7 +24,16 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#endif
|
||||
#if defined(__linux__)
|
||||
#include <libudev.h>
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
@ -435,6 +444,247 @@ static int urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, char*
|
||||
return error;
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
static char *devd_get_val(char *buf, size_t buf_size, const char *val_name, size_t val_name_size, size_t *val_size) {
|
||||
char *ret, *buf_end, *ptr;
|
||||
|
||||
buf_end = (buf + buf_size);
|
||||
for (ret = buf; ret != NULL && ret < buf_end;) {
|
||||
ret = memmem(ret, (buf_end - ret), val_name, val_name_size);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
/* Found. */
|
||||
/* Check: space before or buf+1. */
|
||||
if ((buf + 1) < ret && ret[-1] != ' ') {
|
||||
ret += val_name_size;
|
||||
continue;
|
||||
}
|
||||
/* Check: = after name and size for value. */
|
||||
ret += val_name_size;
|
||||
if ((ret + 1) >= buf_end)
|
||||
return NULL;
|
||||
if (ret[0] != '=')
|
||||
continue;
|
||||
ret ++;
|
||||
break;
|
||||
}
|
||||
if (ret == NULL || val_size == NULL)
|
||||
return ret;
|
||||
/* Calc value data size. */
|
||||
ptr = memchr(ret, ' ', (buf_end - ret));
|
||||
if (ptr == NULL) /* End of string/last value. */
|
||||
ptr = buf_end;
|
||||
(*val_size) = (ptr - ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *urbdrc_search_usb_device(void *arg) {
|
||||
USB_SEARCHMAN *searchman = (USB_SEARCHMAN*)arg;
|
||||
URBDRC_PLUGIN *urbdrc = (URBDRC_PLUGIN*)searchman->urbdrc;
|
||||
IUDEVMAN *udevman = urbdrc->udevman;
|
||||
IWTSVirtualChannelManager *channel_mgr = urbdrc->listener_callback->channel_mgr;
|
||||
IWTSVirtualChannel *dvc_channel;
|
||||
USB_SEARCHDEV *sdev;
|
||||
IUDEVICE *pdev;
|
||||
HANDLE listobj[2];
|
||||
HANDLE mon_fd;
|
||||
int devd_skt;
|
||||
char buf[4096], *val, *ptr, *end_val;
|
||||
ssize_t data_size;
|
||||
size_t val_size, tm;
|
||||
int idVendor, idProduct;
|
||||
int busnum, devnum;
|
||||
int action, success, error, found, on_close;
|
||||
struct sockaddr_un sun;
|
||||
|
||||
WLog_DBG(TAG, "urbdrc_search_usb_device - devd: start");
|
||||
|
||||
devd_skt = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
|
||||
if (devd_skt == -1) {
|
||||
WLog_ERR(TAG, "Can't create devd socket: error = %i", errno);
|
||||
goto err_out;
|
||||
}
|
||||
memset(&sun, 0, sizeof(sun));
|
||||
sun.sun_family = PF_LOCAL;
|
||||
sun.sun_len = sizeof(sun);
|
||||
strlcpy(sun.sun_path, "/var/run/devd.seqpacket.pipe", sizeof(sun.sun_path));
|
||||
if (-1 == connect(devd_skt, (struct sockaddr*)&sun, sizeof(sun))) {
|
||||
WLog_ERR(TAG, "Can't connect devd socket: error = %i - %s", errno, strerror(errno));
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/* Get the file descriptor (fd) for the monitor.
|
||||
This fd will get passed to select() */
|
||||
mon_fd = CreateFileDescriptorEvent(NULL, TRUE, FALSE, devd_skt);
|
||||
listobj[0] = searchman->term_event;
|
||||
listobj[1] = mon_fd;
|
||||
|
||||
while (WaitForMultipleObjects(2, listobj, FALSE, INFINITE) != WAIT_OBJECT_0) {
|
||||
WLog_DBG(TAG, "======= SEARCH ======= ");
|
||||
|
||||
/* !system=USB subsystem=DEVICE type=ATTACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host port=4 parent=ugen3.1 */
|
||||
/* !system=USB subsystem=DEVICE type=DETACH ugen=ugen3.3 cdev=ugen3.3 vendor=0x046d product=0x082d devclass=0xef devsubclass=0x02 sernum="6E7D726F" release=0x0011 mode=host port=4 parent=ugen3.1 */
|
||||
data_size = read(devd_skt, buf, (sizeof(buf) - 1));
|
||||
if (data_size == -1) {
|
||||
WLog_ERR(TAG, "devd socket read: error = %i", errno);
|
||||
break;
|
||||
}
|
||||
buf[data_size] = 0;
|
||||
WLog_DBG(TAG, "devd event: %s", buf);
|
||||
|
||||
if (buf[0] != '!') /* Skeep non notify events. */
|
||||
continue;
|
||||
/* Check: system=USB */
|
||||
val = devd_get_val(buf, data_size, "system", 6, &val_size);
|
||||
if (val == NULL || val_size != 3 || memcmp(val, "USB", 3) != 0)
|
||||
continue;
|
||||
/* Check: subsystem=DEVICE */
|
||||
val = devd_get_val(buf, data_size, "subsystem", 9, &val_size);
|
||||
if (val == NULL || val_size != 6 || memcmp(val, "DEVICE", 6) != 0)
|
||||
continue;
|
||||
/* Get event type. */
|
||||
val = devd_get_val(buf, data_size, "type", 4, &val_size);
|
||||
if (val == NULL || val_size != 6)
|
||||
continue;
|
||||
action = -1;
|
||||
if (memcmp(val, "ATTACH", 6) == 0)
|
||||
action = 0;
|
||||
if (memcmp(val, "DETACH", 6) == 0)
|
||||
action = 1;
|
||||
if (action == -1)
|
||||
continue; /* Skeep other actions. */
|
||||
|
||||
/* Get bus and dev num. */
|
||||
/* ugen=ugen3.3 */
|
||||
val = devd_get_val(buf, data_size, "ugen", 4, &val_size);
|
||||
if (val == NULL || val_size < 7 || memcmp(val, "ugen", 4) != 0)
|
||||
continue;
|
||||
val += 4;
|
||||
val_size -= 4;
|
||||
ptr = memchr(val, '.', val_size);
|
||||
if (ptr == NULL)
|
||||
continue;
|
||||
/* Prepare strings. */
|
||||
ptr[0] = 0;
|
||||
ptr ++;
|
||||
val[val_size] = 0;
|
||||
/* Extract numbers. */
|
||||
busnum = atoi(val);
|
||||
devnum = atoi(ptr);
|
||||
/* Restore spaces. */
|
||||
ptr[-1] = ' ';
|
||||
val[val_size] = ' ';
|
||||
|
||||
/* Handle event. */
|
||||
dvc_channel = NULL;
|
||||
|
||||
switch (action) {
|
||||
case 0: /* ATTACH */
|
||||
sdev = NULL;
|
||||
success = 0;
|
||||
found = 0;
|
||||
|
||||
/* vendor=0x046d */
|
||||
val = devd_get_val(buf, data_size, "vendor", 6, &val_size);
|
||||
if (val == NULL || val_size < 1)
|
||||
continue;
|
||||
val[val_size] = 0;
|
||||
idVendor = strtol(val, NULL, 16);
|
||||
val[val_size] = ' ';
|
||||
|
||||
/* product=0x082d */
|
||||
val = devd_get_val(buf, data_size, "product", 7, &val_size);
|
||||
if (val == NULL || val_size < 1)
|
||||
continue;
|
||||
val[val_size] = 0;
|
||||
idProduct = strtol(val, NULL, 16);
|
||||
val[val_size] = ' ';
|
||||
|
||||
WLog_DBG(TAG, "ATTACH: bus: %i, dev: %i, ven: %i, prod: %i", busnum, devnum, idVendor, idProduct);
|
||||
|
||||
dvc_channel = channel_mgr->FindChannelById(channel_mgr, urbdrc->first_channel_id);
|
||||
searchman->rewind(searchman);
|
||||
while (dvc_channel && searchman->has_next(searchman)) {
|
||||
sdev = searchman->get_next(searchman);
|
||||
if (sdev->idVendor == idVendor &&
|
||||
sdev->idProduct == idProduct) {
|
||||
WLog_VRB(TAG, "Searchman Found Device: %04x:%04x",
|
||||
sdev->idVendor, sdev->idProduct);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && udevman->isAutoAdd(udevman)) {
|
||||
WLog_VRB(TAG, "Auto Find Device: %04x:%04x ",
|
||||
idVendor, idProduct);
|
||||
found = 2;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
success = udevman->register_udevice(udevman, busnum, devnum,
|
||||
searchman->UsbDevice, 0, 0, UDEVMAN_FLAG_ADD_BY_ADDR);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
searchman->UsbDevice ++;
|
||||
|
||||
usleep(400000);
|
||||
error = urdbrc_send_virtual_channel_add(dvc_channel, 0);
|
||||
if (found == 1)
|
||||
searchman->remove(searchman, sdev->idVendor, sdev->idProduct);
|
||||
}
|
||||
break;
|
||||
case 1: /* DETACH */
|
||||
pdev = NULL;
|
||||
on_close = 0;
|
||||
WLog_DBG(TAG, "DETACH: bus: %i, dev: %i", busnum, devnum);
|
||||
|
||||
usleep(500000);
|
||||
udevman->loading_lock(udevman);
|
||||
udevman->rewind(udevman);
|
||||
while(udevman->has_next(udevman)) {
|
||||
pdev = udevman->get_next(udevman);
|
||||
if (pdev->get_bus_number(pdev) == busnum &&
|
||||
pdev->get_dev_number(pdev) == devnum) {
|
||||
dvc_channel = channel_mgr->FindChannelById(channel_mgr, pdev->get_channel_id(pdev));
|
||||
|
||||
if (dvc_channel == NULL) {
|
||||
WLog_ERR(TAG, "SEARCH: dvc_channel %d is NULL!!", pdev->get_channel_id(pdev));
|
||||
func_close_udevice(searchman, pdev);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pdev->isSigToEnd(pdev)) {
|
||||
dvc_channel->Write(dvc_channel, 0, NULL, NULL);
|
||||
pdev->SigToEnd(pdev);
|
||||
}
|
||||
|
||||
on_close = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
udevman->loading_unlock(udevman);
|
||||
usleep(300000);
|
||||
|
||||
if (pdev && on_close && dvc_channel && pdev->isSigToEnd(pdev) && !(pdev->isChannelClosed(pdev))) {
|
||||
dvc_channel->Close(dvc_channel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(mon_fd);
|
||||
err_out:
|
||||
close(devd_skt);
|
||||
sem_post(&searchman->sem_term);
|
||||
WLog_DBG(TAG, "urbdrc_search_usb_device - devd: end");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#if defined (__linux__)
|
||||
static void* urbdrc_search_usb_device(void* arg)
|
||||
{
|
||||
USB_SEARCHMAN* searchman = (USB_SEARCHMAN*) arg;
|
||||
@ -658,6 +908,7 @@ fail_create_monfd_event:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void* urbdrc_new_device_create(void* arg)
|
||||
{
|
||||
@ -674,8 +925,10 @@ void* urbdrc_new_device_create(void* arg)
|
||||
UINT32 FunctionId;
|
||||
int i = 0, found = 0;
|
||||
|
||||
WLog_DBG(TAG, "...");
|
||||
|
||||
channel_mgr = urbdrc->listener_callback->channel_mgr;
|
||||
ChannelId = channel_mgr->GetChannelId(callback->channel);
|
||||
ChannelId = channel_mgr->GetChannelId(callback->channel);
|
||||
|
||||
data_read_UINT32(pBuffer + 0, MessageId);
|
||||
data_read_UINT32(pBuffer + 4, FunctionId);
|
||||
@ -743,6 +996,8 @@ static int urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback
|
||||
UINT32 FunctionId;
|
||||
URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*) callback->plugin;
|
||||
|
||||
WLog_DBG(TAG, "...");
|
||||
|
||||
data_read_UINT32(pBuffer + 0, MessageId);
|
||||
data_read_UINT32(pBuffer + 4, FunctionId);
|
||||
|
||||
@ -793,7 +1048,7 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
UINT32 Mask;
|
||||
int error = 0;
|
||||
char* pBuffer = (char*)Stream_Pointer(data);
|
||||
UINT32 cbSize = Stream_GetRemainingLength(data);
|
||||
UINT32 cbSize = Stream_GetRemainingLength(data);
|
||||
|
||||
if (callback == NULL)
|
||||
return 0;
|
||||
|
@ -30,7 +30,11 @@
|
||||
#include <freerdp/channels/log.h>
|
||||
#include <freerdp/utils/msusb.h>
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#include <uuid.h>
|
||||
#else
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
|
@ -104,7 +104,7 @@ COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{ "parallel", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect parallel device" },
|
||||
{ "smartcard", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect smartcard device" },
|
||||
{ "printer", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect printer device" },
|
||||
{ "usb", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect USB device" },
|
||||
{ "usb", COMMAND_LINE_VALUE_REQUIRED, "[dbg][dev][id|addr][auto]", NULL, NULL, -1, NULL, "Redirect USB device" },
|
||||
{ "multitouch", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect multitouch input" },
|
||||
{ "gestures", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Consume multitouch input locally" },
|
||||
{ "echo", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "echo", "Echo channel" },
|
||||
|
31
cmake/FindDevD.cmake
Normal file
31
cmake/FindDevD.cmake
Normal file
@ -0,0 +1,31 @@
|
||||
# Configure devd environment
|
||||
#
|
||||
# DEVD_FOUND - system has a devd
|
||||
# DEVD_BIN_DIR - devd bin dir
|
||||
# DEVD_SKT_DIR - devd socket dir
|
||||
#
|
||||
# Copyright (c) 2015 Rozhuk Ivan <rozhuk.im@gmail.com>
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
#
|
||||
|
||||
|
||||
FIND_PATH(
|
||||
DEVD_BIN_DIR
|
||||
NAMES devd
|
||||
PATHS /sbin /usr/sbin /usr/local/sbin
|
||||
)
|
||||
|
||||
FIND_PATH(
|
||||
DEVD_SKT_DIR
|
||||
NAMES devd.seqpacket.pipe devd.pipe
|
||||
PATHS /var/run/
|
||||
)
|
||||
|
||||
|
||||
if (DEVD_BIN_DIR)
|
||||
set(DEVD_FOUND "YES")
|
||||
message(STATUS "devd found")
|
||||
if (NOT DEVD_SKT_DIR)
|
||||
message(STATUS "devd not running!")
|
||||
endif (NOT DEVD_SKT_DIR)
|
||||
endif (DEVD_BIN_DIR)
|
@ -20,6 +20,7 @@ set(UUID_FOUND TRUE)
|
||||
else (UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
|
||||
find_path(UUID_INCLUDE_DIR
|
||||
NAMES
|
||||
uuid.h
|
||||
uuid/uuid.h
|
||||
PATHS
|
||||
${UUID_DIR}/include
|
||||
@ -85,26 +86,27 @@ $ENV{OSG_ROOT}/lib
|
||||
/opt/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
if (NOT UUID_LIBRARY AND BSD)
|
||||
set(UUID_LIBRARY "")
|
||||
endif(NOT UUID_LIBRARY AND BSD)
|
||||
|
||||
set(UUID_INCLUDE_DIRS
|
||||
${UUID_INCLUDE_DIR}
|
||||
)
|
||||
set(UUID_LIBRARIES
|
||||
${UUID_LIBRARY}
|
||||
)
|
||||
set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR})
|
||||
set(UUID_LIBRARIES ${UUID_LIBRARY})
|
||||
|
||||
if (UUID_INCLUDE_DIRS AND UUID_LIBRARIES)
|
||||
set(UUID_FOUND TRUE)
|
||||
endif (UUID_INCLUDE_DIRS AND UUID_LIBRARIES)
|
||||
if (UUID_INCLUDE_DIRS)
|
||||
if (BSD OR UUID_LIBRARIES)
|
||||
set(UUID_FOUND TRUE)
|
||||
endif (BSD OR UUID_LIBRARIES)
|
||||
endif (UUID_INCLUDE_DIRS)
|
||||
|
||||
if (UUID_FOUND)
|
||||
if (NOT UUID_FIND_QUIETLY)
|
||||
message(STATUS "Found UUID: ${UUID_LIBRARIES}")
|
||||
endif (NOT UUID_FIND_QUIETLY)
|
||||
if (NOT UUID_FIND_QUIETLY)
|
||||
message(STATUS "Found UUID: ${UUID_LIBRARIES}")
|
||||
endif (NOT UUID_FIND_QUIETLY)
|
||||
else (UUID_FOUND)
|
||||
if (UUID_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find UUID")
|
||||
endif (UUID_FIND_REQUIRED)
|
||||
if (UUID_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find UUID")
|
||||
endif (UUID_FIND_REQUIRED)
|
||||
endif (UUID_FOUND)
|
||||
|
||||
# show the UUID_INCLUDE_DIRS and UUID_LIBRARIES variables only in the advanced view
|
||||
|
@ -227,7 +227,7 @@ int WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args)
|
||||
int offset = 0;
|
||||
|
||||
if (message->Level == WLOG_DEBUG || message->Level == WLOG_ERROR)
|
||||
offset = snprintf(formattedLogMessage, (WLOG_MAX_STRING_SIZE - 1), "%s, line %i: ", message->FunctionName, message->LineNumber);
|
||||
offset = sprintf_s(formattedLogMessage, (WLOG_MAX_STRING_SIZE - 1), "%s, line %i: ", message->FunctionName, message->LineNumber);
|
||||
wvsnprintfx((formattedLogMessage + offset), ((WLOG_MAX_STRING_SIZE - 1) - offset), message->FormatString, args);
|
||||
message->TextString = formattedLogMessage;
|
||||
status = WLog_Write(log, message);
|
||||
|
Loading…
Reference in New Issue
Block a user