USBProxyServiceWindows.cpp revision df294ff29aab74013667896ef2d4f5bd1f782143
/* $Id$ */
/** @file
* VirtualBox USB Proxy Service, Windows Specialization.
*/
/*
* Copyright (C) 2006-2010 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.
*/
/*******************************************************************************
* 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).
*/
/*
* Initialize 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;
}
{
}
{
/*
* Create a one-shot ignore filter for the device
* and trigger a re-enumeration of it.
*/
if (!pvId)
{
AssertMsgFailed(("Add one-shot Filter failed\n"));
return VERR_GENERAL_FAILURE;
}
int rc = USBLibRunFilters();
if (!RT_SUCCESS(rc))
{
AssertMsgFailed(("Run Filters failed\n"));
return rc;
}
return VINF_SUCCESS;
}
{
/*
* Create a one-shot ignore filter for the device
* and trigger a re-enumeration of it.
*/
if (!pvId)
{
AssertMsgFailed(("Add one-shot Filter failed\n"));
return VERR_GENERAL_FAILURE;
}
int rc = USBLibRunFilters();
if (!RT_SUCCESS(rc))
{
AssertMsgFailed(("Run Filters failed\n"));
return rc;
}
return VINF_SUCCESS;
}
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
}
{
return USBLibWaitChange(aMillies);
}
int USBProxyServiceWindows::interruptWait(void)
{
return USBLibInterruptWaitChange();
}
/**
* Gets a list of all devices the VM can grab
*/
{
Log(("USBProxyServiceWindows::getDevices\n"));
return pDevices;
}