USBProxyServiceWindows.cpp revision 730b109e93240f48a2fc4ca97c05e5f347f71ec9
/* $Id$ */
/** @file
* VirtualBox USB Proxy Service, Windows Specialization.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* Oracle Corporation confidential
* All rights reserved
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "USBProxyService.h"
#include "Logging.h"
/**
* Initialize data members.
*/
{
}
/**
* Initializes the object (called right after construction).
*
* @returns S_OK on success and non-fatal failures, some COM error otherwise.
*/
{
/*
* Call the superclass method first.
*/
/*
* Create the semaphore (considered fatal).
*/
/*
* Initalize the USB lib and stuff.
*/
int rc = USBLibInit();
if (RT_SUCCESS(rc))
{
/*
* Start the poller thread.
*/
if (RT_SUCCESS(rc))
{
LogFlowThisFunc(("returns successfully\n"));
return S_OK;
}
USBLibTerm();
}
mLastError = rc;
return S_OK;
}
/**
* Stop all service threads and free the device chain.
*/
{
LogFlowThisFunc(("\n"));
/*
* Stop the service.
*/
if (isActive())
stop();
if (mhEventInterrupt != INVALID_HANDLE_VALUE)
/*
* Terminate the library...
*/
int rc = USBLibTerm();
}
{
LogFlow(("USBProxyServiceWindows::insertFilter()\n"));
return pvId;
}
{
}
{
/** @todo pass up a one-shot filter like on darwin? */
}
{
/** @todo pass up a one-shot filter like on darwin? */
Log(("USBProxyServiceWindows::releaseDevice\n"));
}
bool USBProxyServiceWindows::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine)
{
/* Nothing special here so far, so fall back on parent */
/// @todo remove?
#if 0
AssertReturn(aDevice, false);
/*
* We're only called in the 'existing device' state, so if there is a pending async
* operation we can check if it completed here and suppress state changes if it hasn't.
*/
/* TESTME */
if (aDevice->isStatePending())
{
if (fRc)
{
fRc = false;
}
return fRc;
}
/* fall back on parent. */
#endif
}
{
/* Not going to do something fancy where we block in the filter
* driver and are woken up when the state has changed.
* Would be better, but this is good enough.
*/
do
{
if (rc == WAIT_OBJECT_0)
return VINF_SUCCESS;
/** @todo handle WAIT_FAILED here */
if (USBLibHasPendingDeviceChanges() == true)
{
Log(("wait thread detected usb change\n"));
return VINF_SUCCESS;
}
if (aMillies > 100)
aMillies -= 100;
}
while (aMillies > 100);
return VERR_TIMEOUT;
}
int USBProxyServiceWindows::interruptWait(void)
{
return VINF_SUCCESS;
}
/**
* Gets a list of all devices the VM can grab
*/
{
Log(("USBProxyServiceWindows::getDevices\n"));
return pDevices;
}