USBProxyServiceDarwin.cpp revision 730b109e93240f48a2fc4ca97c05e5f347f71ec9
/* $Id$ */
/** @file
* VirtualBox USB Proxy Service (in VBoxSVC), Darwin Specialization.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* Oracle Corporation confidential
* All rights reserved
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "USBProxyService.h"
#include "Logging.h"
#include "iokit.h"
/**
* Initialize data members.
*/
: USBProxyService (aHost), mServiceRunLoopRef (NULL), mNotifyOpaque (NULL), mWaitABitNextTime (false), mUSBLibInitialized (false)
{
}
/**
* 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.
*/
/*
* Initialize the USB library.
*/
int rc = USBLibInit();
if (RT_FAILURE(rc))
{
mLastError = rc;
return S_OK;
}
mUSBLibInitialized = true;
#endif
/*
* Start the poller thread.
*/
start();
return S_OK;
}
/**
* Stop all service threads and free the device chain.
*/
{
LogFlowThisFunc(("\n"));
/*
* Stop the service.
*/
if (isActive())
stop();
/*
* Terminate the USB library - it'll
*/
if (mUSBLibInitialized)
{
USBLibTerm();
mUSBLibInitialized = false;
}
#endif
}
{
return USBLibAddFilter (aFilter);
}
{
}
#endif /* VBOX_WITH_NEW_USB_CODE_ON_DARWIN */
{
/*
* Check preconditions.
*/
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
/*
* Fake it.
*/
ASMAtomicWriteBool(&mFakeAsync, true);
return VINF_SUCCESS;
#else
/*
* Create a one-shot capture filter for the device (don't
* match on port) and trigger a re-enumeration of it.
*/
if (!pvId)
return VERR_GENERAL_FAILURE;
if (RT_SUCCESS(rc))
else
{
}
return rc;
#endif
}
{
/*
* Remove the one-shot filter if necessary.
*/
LogFlowThisFunc(("aDevice=%s aSuccess=%RTbool mOneShotId=%p\n", aDevice->getName().c_str(), aSuccess, aDevice->mOneShotId));
#endif
}
{
/*
* Check preconditions.
*/
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
/*
* Fake it.
*/
ASMAtomicWriteBool(&mFakeAsync, true);
return VINF_SUCCESS;
#else
/*
* Create a one-shot ignore filter for the device
* and trigger a re-enumeration of it.
*/
if (!pvId)
return VERR_GENERAL_FAILURE;
if (RT_SUCCESS(rc))
else
{
}
return rc;
#endif
}
{
/*
* Remove the one-shot filter if necessary.
*/
LogFlowThisFunc(("aDevice=%s aSuccess=%RTbool mOneShotId=%p\n", aDevice->getName().c_str(), aSuccess, aDevice->mOneShotId));
#endif
}
{
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
#else
#endif
}
bool USBProxyServiceDarwin::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine)
{
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
/* We're faking async state stuff. */
#else
/* Nothing special here so far, so fall back on parent */
#endif
}
{
#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
if ( mFakeAsync
&& ASMAtomicXchgBool(&mFakeAsync, false))
return VINF_SUCCESS;
#endif
? 1.0 /* seconds */
? 5.0 /* seconds */
: aMillies / 1000.0,
true);
return VINF_SUCCESS;
}
int USBProxyServiceDarwin::interruptWait (void)
{
if (mServiceRunLoopRef)
return 0;
}
{
/* call iokit.cpp */
return DarwinGetUSBDevices();
}
void USBProxyServiceDarwin::serviceThreadInit (void)
{
}
void USBProxyServiceDarwin::serviceThreadTerm (void)
{
}
/**
* Wrapper called from iokit.cpp.
*
* @param pCur The USB device to free.
*/
{
}