USBProxyService.h revision dff7b61dd3fdc4026a02236298516db1d8ac6516
/* $Id$ */
/** @file
* VirtualBox USB Proxy Service (base) class.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_USBPROXYSERVICE
#define ____H_USBPROXYSERVICE
#include <VBox/usbfilter.h>
#include "VirtualBoxBase.h"
#include "VirtualBoxImpl.h"
#include "HostUSBDeviceImpl.h"
/**
* Base class for the USB Proxy service.
*/
{
/**
* Override of the default locking class to be used for validating lock
* order with the standard member lock handle.
*/
{
// the USB proxy service uses the Host object lock, so return the
// same locking class as the host
return LOCKCLASS_HOSTOBJECT;
}
bool isActive(void);
int getLastError(void);
RWLockHandle *lockHandle() const;
/** @name Host Interfaces
* @{ */
/** @} */
/** @name SessionMachine Interfaces
* @{ */
/** @} */
/** @name Interface for the USBController and the Host object.
* @{ */
/** @} */
/** @name Interfaces for the HostUSBDevice
* @{ */
/** @} */
int start(void);
int stop(void);
virtual void serviceThreadInit(void);
virtual void serviceThreadTerm(void);
virtual int interruptWait(void);
virtual void deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines, PUSBDEVICE aUSBDevice);
virtual void deviceChanged(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList *pllOpenedMachines, SessionMachine *aIgnoreMachine);
bool updateDeviceStateFake(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
void processChanges(void);
/** Pointer to the Host object. */
/** Thread handle of the service thread. */
/** Flag which stop() sets to cause serviceThread to return. */
bool volatile mTerminate;
/** VBox status code of the last failure.
* (Only used by start(), stop() and the child constructors.) */
int mLastError;
/** Optional error message to complement mLastError. */
/** List of smart HostUSBDevice pointers. */
/** List of the known USB devices. */
};
# ifdef RT_OS_DARWIN
# define OSType Carbon_OSType
/**
* The Darwin hosted USB Proxy Service.
*/
{
#endif
virtual int interruptWait (void);
virtual void serviceThreadInit (void);
virtual void serviceThreadTerm (void);
virtual bool updateDeviceState (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
/** Reference to the runloop of the service thread.
* This is NULL if the service thread isn't running. */
/** The opaque value returned by DarwinSubscribeUSBNotifications. */
void *mNotifyOpaque;
/** A hack to work around the problem with the usb device enumeration
* not including newly attached devices. */
bool mWaitABitNextTime;
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
/** Whether we've got a fake async event and should return without entering the runloop. */
bool volatile mFakeAsync;
#endif
/** Whether we've successfully initialized the USBLib and should call USBLibTerm in the destructor. */
bool mUSBLibInitialized;
};
# endif /* RT_OS_DARWIN */
# ifdef RT_OS_LINUX
# include <stdio.h>
# ifdef VBOX_USB_WITH_SYSFS
# include <HostHardwareLinux.h>
# endif
/**
* The Linux hosted USB Proxy Service.
*/
{
int initUsbfs(void);
int initSysfs(void);
void doUsbfsCleanupAsNeeded(void);
virtual int interruptWait(void);
virtual void deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines, PUSBDEVICE aUSBDevice);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
/** Pipe used to interrupt wait(), the read end. */
/** Pipe used to interrupt wait(), the write end. */
/** The root of usbfs. */
bool mUsingUsbfsDevices;
/** Number of 500ms polls left to do. See usbDeterminState for details. */
unsigned mUdevPolls;
# ifdef VBOX_USB_WITH_SYSFS
/** Object used for polling for hotplug events from hal. */
# endif
};
# endif /* RT_OS_LINUX */
# ifdef RT_OS_OS2
# include <usbcalls.h>
/**
* The Linux hosted USB Proxy Service.
*/
{
/// @todo virtual HRESULT init(void);
virtual int interruptWait(void);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
/** The notification event semaphore */
/** The notification id. */
/** The usbcalls.dll handle. */
/** UsbRegisterChangeNotification */
/** UsbDeregisterNotification */
/** UsbQueryNumberDevices */
/** UsbQueryDeviceReport */
};
# endif /* RT_OS_LINUX */
# ifdef RT_OS_SOLARIS
# include <libdevinfo.h>
/**
* The Solaris hosted USB Proxy Service.
*/
{
virtual int interruptWait(void);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
/** Whether we've successfully initialized the USBLib and should call USBLibTerm in the destructor. */
bool mUSBLibInitialized;
};
#endif /* RT_OS_SOLARIS */
# ifdef RT_OS_WINDOWS
/**
* The Windows hosted USB Proxy Service.
*/
{
virtual int interruptWait(void);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
};
# endif /* RT_OS_WINDOWS */
# ifdef RT_OS_FREEBSD
/**
* The FreeBSD hosted USB Proxy Service.
*/
{
int initUsbfs(void);
int initSysfs(void);
virtual int interruptWait(void);
virtual void deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines, PUSBDEVICE aUSBDevice);
virtual bool updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine);
};
# endif /* RT_OS_FREEBSD */
#endif /* !____H_USBPROXYSERVICE */
/* vi: set tabstop=4 shiftwidth=4 expandtab: */