USBProxyService.h revision 03b802818ffd2f36e2b9210243cef54f4d4aa5ac
/** @file
* VirtualBox USB Proxy Service (base) class.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef ____H_USBPROXYSERVICE
#define ____H_USBPROXYSERVICE
#include "HostImpl.h"
#include "HostUSBDeviceImpl.h"
/**
* Base class for the USB Proxy service.
*/
{
/**
* A filter was inserted / loaded.
*
* @param aFilter Pointer to the inserted filter.
* @return ID of the inserted filter
*/
/**
* A filter was removed.
*
* @param aID ID of the filter to remove
*/
/**
* A VM is trying to capture a device, do necessary preperations.
*
* @returns VBox status code.
* @param pDevice The device in question.
*/
/**
* The device is to be held so that the host OS will not start using it.
*
* @returns VBox status code.
* @param pDevice The device in question.
*/
/**
* A VM is releasing a device back to the host.
*
* @returns VBox status code.
* @param pDevice The device in question.
*/
/**
* A VM is releaseing a device back to be held or assigned to another VM.
* A port reset should be performed.
*
* @returns VBox status code.
* @param pDevice The device in question.
*/
/**
* Query if the service is active and working.
*
* @returns true if the service is up running.
* @returns false if the service isn't running.
*/
bool isActive (void);
/**
* Get last error.
* Can be used to check why the proxy !isActive() upon construction.
*
* @returns VBox status code.
*/
int getLastError (void);
/**
* Calculate the hash of the serial string.
*
* 64bit FNV1a, chosen because it is designed to hash in to a power of two
* space, and is much quicker and simpler than, say, a half MD4.
*
* @returns the hash.
* @param aSerial The serial string.
*/
/**
* Starts the service.
*
* @returns VBox status.
*/
int start (void);
/**
* Stops the service.
*
* @returns VBox status.
*/
int stop (void);
/**
* Wait for a change in the USB devices attached to the host.
*
* @returns VBox status (ignored).
* @param aMillies Number of milliseconds to wait.
*/
/**
* Interrupt any wait() call in progress.
*
* @returns VBox status.
*/
virtual int interruptWait (void);
/**
* Get a list of USB device currently attached to the host.
*
* @returns Pointer to a list of USB devices.
* The list nodes are freed individually by calling freeDevice().
*/
/**
* First call made on the service thread, use it to do
* thread initialization.
*/
virtual void serviceThreadInit (void);
/**
* First call made on the service thread, use it to do
* thread termination.
*/
virtual void serviceThreadTerm (void);
/**
* Free one USB device returned by getDevice().
*
* @param pDevice Pointer to the device.
*/
/**
* Process any relevant changes in the attached USB devices.
*/
void processChanges (void);
/**
* The service thread created by start().
*
* @param Thread The thread handle.
* @param pvUser Pointer to the USBProxyService instance.
*/
/** Pointer to the Host object. */
/** Thread handle of the service thread. */
/** Flag which stop() sets to cause serviceThread to return. */
bool volatile mTerminate;
/** List of smart HostUSBDevice pointers. */
/** List of the known USB devices. */
/** VBox status code of the last failure.
* (Only used by start(), stop() and the child constructors.) */
int mLastError;
};
#ifdef VBOX_WITH_USB
# ifdef __DARWIN__
# define OSType Carbon_OSType
/**
* The Darwin hosted USB Proxy Service.
*/
{
virtual int interruptWait (void);
virtual void serviceThreadInit (void);
virtual void serviceThreadTerm (void);
/** Reference to the runloop of the service thread.
* This is NULL if the service thread isn't running. */
};
# endif /* __DARWIN__ */
# ifdef __LINUX__
# include <stdio.h>
/**
* The Linux hosted USB Proxy Service.
*/
{
virtual int interruptWait (void);
/** Stream for mFile. */
/** Pipe used to interrupt wait(), the read end. */
/** Pipe used to interrupt wait(), the write end. */
/** The root of usbfs. */
};
# endif /* __LINUX__ */
# ifdef __WIN__
/**
* The Win32 hosted USB Proxy Service.
*/
{
virtual int interruptWait (void);
};
# endif /* __WIN__ */
#endif /* VBOX_WITH_USB */
#endif /* !____H_USBPROXYSERVICE */