本文整理汇总了C++中ComObjPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ComObjPtr类的具体用法?C++ ComObjPtr怎么用?C++ ComObjPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComObjPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckComArgOutPointerValid
STDMETHODIMP USBDeviceFilters::CreateDeviceFilter(IN_BSTR aName,
IUSBDeviceFilter **aFilter)
{
#ifdef VBOX_WITH_USB
CheckComArgOutPointerValid(aFilter);
CheckComArgStrNotEmptyOrNull(aName);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/* the machine needs to be mutable */
AutoMutableStateDependency adep(m->pParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
ComObjPtr<USBDeviceFilter> pFilter;
pFilter.createObject();
HRESULT rc = pFilter->init(this, aName);
ComAssertComRCRetRC(rc);
rc = pFilter.queryInterfaceTo(aFilter);
AssertComRCReturnRC(rc);
return S_OK;
#else
NOREF(aName);
NOREF(aFilter);
ReturnComNotImplemented();
#endif
}
示例2: adep
HRESULT USBDeviceFilter::setRemote(const com::Utf8Str &aRemote)
{
/* the machine needs to be mutable */
AutoMutableOrSavedOrRunningStateDependency adep(mParent->i_getMachine());
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
Bstr bRemote = Bstr(aRemote).raw();
if (mData->mRemote.string() != bRemote)
{
Data::BOOLFilter flt = bRemote;
ComAssertRet(!flt.isNull(), E_FAIL);
if (!flt.isValid())
return setError(E_INVALIDARG,
tr("Remote state filter string '%s' is not valid (error at position %d)"),
aRemote.c_str(), flt.errorPosition() + 1);
m_fModified = true;
ComObjPtr<Machine> pMachine = mParent->i_getMachine();
mData.backup();
mData->mRemote = flt;
// leave the lock before informing callbacks
alock.release();
AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
pMachine->i_setModified(Machine::IsModified_USB);
mlock.release();
return mParent->i_onDeviceFilterChange(this);
}
return S_OK;
}
示例3: init
HRESULT VirtualBoxErrorInfo::init(const com::ErrorInfo &info,
IVirtualBoxErrorInfo *aNext)
{
m_resultCode = info.getResultCode();
m_resultDetail = info.getResultDetail();
m_IID = info.getInterfaceID();
m_strComponent = info.getComponent();
m_strText = info.getText();
/* Recursively create VirtualBoxErrorInfo instances for the next objects. */
const com::ErrorInfo *pInfo = info.getNext();
if (pInfo)
{
ComObjPtr<VirtualBoxErrorInfo> nextEI;
HRESULT rc = nextEI.createObject();
if (FAILED(rc)) return rc;
rc = nextEI->init(*pInfo, aNext);
if (FAILED(rc)) return rc;
mNext = nextEI;
}
else
mNext = aNext;
return S_OK;
}
示例4: deviceChanged
/**
* Handle a device which state changed in some significant way.
*
* This means things like running filters and subsequent capturing and
* VM attaching. This may result in IPC and temporary lock abandonment.
*
* @param aDevice The device.
* @param pllOpenedMachines list of running session machines (VirtualBox::getOpenedMachines()); if NULL, we don't run filters
* @param aIgnoreMachine Machine to ignore when running filters.
*/
void USBProxyService::deviceChanged(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList *pllOpenedMachines,
SessionMachine *aIgnoreMachine)
{
/*
* Validate preconditions.
*/
AssertReturnVoid(!isWriteLockOnCurrentThread());
AssertReturnVoid(!aDevice->isWriteLockOnCurrentThread());
AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid} aRunFilters=%RTbool aIgnoreMachine=%p\n",
(HostUSBDevice *)aDevice,
aDevice->i_getName().c_str(),
aDevice->i_getStateName(),
aDevice->i_getId().raw(),
(pllOpenedMachines != NULL), // used to be "bool aRunFilters"
aIgnoreMachine));
devLock.release();
/*
* Run filters if requested to do so.
*/
if (pllOpenedMachines)
{
HRESULT rc = runAllFiltersOnDevice(aDevice, *pllOpenedMachines, aIgnoreMachine);
AssertComRC(rc);
}
}
示例5: LogFlowThisFunc
/**
* Apply filters for the machine to all eligible USB devices.
*
* This is in an interface for SessionMachine::CaptureUSBDevice(), which
* is an internal worker used by Console::AutoCaptureUSBDevices() from the
* VM process at VM startup.
*
* Matching devices will be attached to the VM and may result IPC back
* to the VM process via SessionMachine::onUSBDeviceAttach() depending
* on whether the device needs to be captured or not. If capture is
* required, SessionMachine::onUSBDeviceAttach() will be called
* asynchronously by the USB proxy service thread.
*
* @param aMachine The machine to capture devices for.
*
* @returns COM status code, perhaps with error info.
*
* @remarks Temporarily locks this object, the machine object and some USB
* device, and the called methods will lock similar objects.
*/
HRESULT USBProxyService::autoCaptureDevicesForVM(SessionMachine *aMachine)
{
LogFlowThisFunc(("aMachine=%p{%s}\n",
aMachine,
aMachine->i_getName().c_str()));
/*
* Make a copy of the list because we cannot hold the lock protecting it.
* (This will not make copies of any HostUSBDevice objects, only reference them.)
*/
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
HostUSBDeviceList ListCopy = mDevices;
alock.release();
for (HostUSBDeviceList::iterator it = ListCopy.begin();
it != ListCopy.end();
++it)
{
ComObjPtr<HostUSBDevice> device = *it;
AutoReadLock devLock(device COMMA_LOCKVAL_SRC_POS);
if ( device->i_getUnistate() == kHostUSBDeviceState_HeldByProxy
|| device->i_getUnistate() == kHostUSBDeviceState_Unused
|| device->i_getUnistate() == kHostUSBDeviceState_Capturable)
{
devLock.release();
runMachineFilters(aMachine, device);
}
}
return S_OK;
}
示例6: adep
HRESULT USBDeviceFilter::setActive(const BOOL aActive)
{
/* the machine needs to be mutable */
AutoMutableOrSavedOrRunningStateDependency adep(mParent->i_getMachine());
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
if (bd->mData.fActive != RT_BOOL(aActive))
{
m_fModified = true;
ComObjPtr<Machine> pMachine = mParent->i_getMachine();
bd.backup();
bd->mData.fActive = RT_BOOL(aActive);
// leave the lock before informing callbacks
alock.release();
AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
pMachine->i_setModified(Machine::IsModified_USB);
mlock.release();
return mParent->i_onDeviceFilterChange(this, TRUE /* aActiveChanged */);
}
return S_OK;
}
示例7: deviceAdded
/**
* Performs the required actions when a device has been added.
*
* This means things like running filters and subsequent capturing and
* VM attaching. This may result in IPC and temporary lock abandonment.
*
* @param aDevice The device in question.
* @param aUSBDevice The USB device structure.
*/
void USBProxyService::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice,
SessionMachinesList &llOpenedMachines,
PUSBDEVICE aUSBDevice)
{
/*
* Validate preconditions.
*/
AssertReturnVoid(!isWriteLockOnCurrentThread());
AssertReturnVoid(!aDevice->isWriteLockOnCurrentThread());
AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n",
(HostUSBDevice *)aDevice,
aDevice->i_getName().c_str(),
aDevice->i_getStateName(),
aDevice->i_getId().raw()));
/*
* Run filters on the device.
*/
if (aDevice->i_isCapturableOrHeld())
{
devLock.release();
HRESULT rc = runAllFiltersOnDevice(aDevice, llOpenedMachines, NULL /* aIgnoreMachine */);
AssertComRC(rc);
}
NOREF(aUSBDevice);
}
示例8: autoCaller
STDMETHODIMP USBDeviceFilter::COMSETTER(MaskedInterfaces) (ULONG aMaskedIfs)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/* the machine needs to be mutable */
AutoMutableStateDependency adep(mParent->getMachine());
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
if (mData->mMaskedIfs != aMaskedIfs)
{
m_fModified = true;
ComObjPtr<Machine> pMachine = mParent->getMachine();
mData.backup();
mData->mMaskedIfs = aMaskedIfs;
// leave the lock before informing callbacks
alock.release();
AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
pMachine->setModified(Machine::IsModified_USB);
mlock.release();
return mParent->onDeviceFilterChange(this);
}
return S_OK;
}
示例9: CheckComArgStrNotEmptyOrNull
STDMETHODIMP USBDeviceFilter::COMSETTER(Name) (IN_BSTR aName)
{
CheckComArgStrNotEmptyOrNull(aName);
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/* the machine needs to be mutable */
AutoMutableStateDependency adep(mParent->getMachine());
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
if (mData->mName != aName)
{
m_fModified = true;
ComObjPtr<Machine> pMachine = mParent->getMachine();
mData.backup();
mData->mName = aName;
// leave the lock before informing callbacks
alock.release();
AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
pMachine->setModified(Machine::IsModified_USB);
mlock.release();
return mParent->onDeviceFilterChange(this);
}
return S_OK;
}
示例10: ReturnComNotImplemented
// implementation of public methods
/////////////////////////////////////////////////////////////////////////////
HRESULT Guest::createSession(const com::Utf8Str &aUser, const com::Utf8Str &aPassword, const com::Utf8Str &aDomain,
const com::Utf8Str &aSessionName, ComPtr<IGuestSession> &aGuestSession)
{
#ifndef VBOX_WITH_GUEST_CONTROL
ReturnComNotImplemented();
#else /* VBOX_WITH_GUEST_CONTROL */
LogFlowFuncEnter();
/* Do not allow anonymous sessions (with system rights) with public API. */
if (RT_UNLIKELY(!aUser.length()))
return setError(E_INVALIDARG, tr("No user name specified"));
GuestSessionStartupInfo startupInfo;
startupInfo.mName = aSessionName;
GuestCredentials guestCreds;
guestCreds.mUser = aUser;
guestCreds.mPassword = aPassword;
guestCreds.mDomain = aDomain;
ComObjPtr<GuestSession> pSession;
int rc = i_sessionCreate(startupInfo, guestCreds, pSession);
if (RT_SUCCESS(rc))
{
/* Return guest session to the caller. */
HRESULT hr2 = pSession.queryInterfaceTo(aGuestSession.asOutParam());
if (FAILED(hr2))
rc = VERR_COM_OBJECT_NOT_FOUND;
}
if (RT_SUCCESS(rc))
/* Start (fork) the session asynchronously
* on the guest. */
rc = pSession->i_startSessionAsync();
HRESULT hr = S_OK;
if (RT_FAILURE(rc))
{
switch (rc)
{
case VERR_MAX_PROCS_REACHED:
hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of concurrent guest sessions (%ld) reached"),
VBOX_GUESTCTRL_MAX_SESSIONS);
break;
/** @todo Add more errors here. */
default:
hr = setError(VBOX_E_IPRT_ERROR, tr("Could not create guest session: %Rrc"), rc);
break;
}
}
LogFlowThisFunc(("Returning rc=%Rhrc\n", hr));
return hr;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
示例11: runMachineFilters
/**
* Runs the USB filters of the machine on the device.
*
* If a match is found we will request capture for VM. This may cause
* us to temporary abandon locks while doing IPC.
*
* @param aMachine Machine whose filters are to be run.
* @param aDevice The USB device in question.
* @returns @c true if the device has been or is being attached to the VM, @c false otherwise.
*
* @note Locks several objects temporarily for reading or writing.
*/
bool USBProxyService::runMachineFilters(SessionMachine *aMachine, ComObjPtr<HostUSBDevice> &aDevice)
{
LogFlowThisFunc(("{%s} aMachine=%p \n", aDevice->i_getName().c_str(), aMachine));
/*
* Validate preconditions.
*/
AssertReturn(aMachine, false);
AssertReturn(!isWriteLockOnCurrentThread(), false);
AssertReturn(!aMachine->isWriteLockOnCurrentThread(), false);
AssertReturn(!aDevice->isWriteLockOnCurrentThread(), false);
/* Let HostUSBDevice::requestCaptureToVM() validate the state. */
/*
* Do the job.
*/
ULONG ulMaskedIfs;
if (aMachine->i_hasMatchingUSBFilter(aDevice, &ulMaskedIfs))
{
/* try to capture the device */
HRESULT hrc = aDevice->i_requestCaptureForVM(aMachine, false /* aSetError */, Utf8Str(), ulMaskedIfs);
return SUCCEEDED(hrc)
|| hrc == E_UNEXPECTED /* bad device state, give up */;
}
return false;
}
示例12: LogFlowThisFuncEnter
STDMETHODIMP NetworkAdapter::COMGETTER(BandwidthGroup)(IBandwidthGroup **aBwGroup)
{
LogFlowThisFuncEnter();
CheckComArgOutPointerValid(aBwGroup);
HRESULT hrc = S_OK;
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
if (mData->mBandwidthGroup.isNotEmpty())
{
ComObjPtr<BandwidthGroup> pBwGroup;
hrc = mParent->getBandwidthGroup(mData->mBandwidthGroup, pBwGroup, true /* fSetError */);
Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of the group was checked when it was attached. */
if (SUCCEEDED(hrc))
pBwGroup.queryInterfaceTo(aBwGroup);
}
LogFlowThisFuncLeave();
return hrc;
}
示例13: LogFlowThisFuncEnter
int GuestObject::sendCommand(uint32_t uFunction,
uint32_t uParms, PVBOXHGCMSVCPARM paParms)
{
LogFlowThisFuncEnter();
#ifndef VBOX_GUESTCTRL_TEST_CASE
ComObjPtr<Console> pConsole = mObject.mConsole;
Assert(!pConsole.isNull());
/* Forward the information to the VMM device. */
VMMDev *pVMMDev = pConsole->getVMMDev();
AssertPtr(pVMMDev);
LogFlowThisFunc(("uFunction=%RU32, uParms=%RU32\n", uFunction, uParms));
int vrc = pVMMDev->hgcmHostCall(HGCMSERVICE_NAME, uFunction, uParms, paParms);
if (RT_FAILURE(vrc))
{
/** @todo What to do here? */
}
#else
/* Not needed within testcases. */
int vrc = VINF_SUCCESS;
#endif
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例14: AssertReturnVoid
void Guest::facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus,
uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS)
{
AssertReturnVoid( a_enmFacility < VBoxGuestFacilityType_All
&& a_enmFacility > VBoxGuestFacilityType_Unknown);
FacilityMapIter it = mData.mFacilityMap.find((AdditionsFacilityType_T)a_enmFacility);
if (it != mData.mFacilityMap.end())
{
AdditionsFacility *pFac = it->second;
pFac->update((AdditionsFacilityStatus_T)a_enmStatus, a_fFlags, a_pTimeSpecTS);
}
else
{
if (mData.mFacilityMap.size() > 64)
{
/* The easy way out for now. We could automatically destroy
inactive facilities like VMMDev does if we like... */
AssertFailedReturnVoid();
}
ComObjPtr<AdditionsFacility> ptrFac;
ptrFac.createObject();
AssertReturnVoid(!ptrFac.isNull());
HRESULT hrc = ptrFac->init(this, (AdditionsFacilityType_T)a_enmFacility, (AdditionsFacilityStatus_T)a_enmStatus,
a_fFlags, a_pTimeSpecTS);
if (SUCCEEDED(hrc))
mData.mFacilityMap.insert(std::make_pair((AdditionsFacilityType_T)a_enmFacility, ptrFac));
}
}
示例15: LogFlowThisFuncEnter
/**
* Removes a guest control session from the internal list and destroys the session.
*
* @returns VBox status code.
* @param uSessionID ID of the guest control session to remove.
*/
int Guest::i_sessionRemove(uint32_t uSessionID)
{
LogFlowThisFuncEnter();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
int rc = VERR_NOT_FOUND;
LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", uSessionID));
GuestSessions::iterator itSessions = mData.mGuestSessions.find(uSessionID);
if (itSessions == mData.mGuestSessions.end())
return VERR_NOT_FOUND;
/* Make sure to consume the pointer before the one of the
* iterator gets released. */
ComObjPtr<GuestSession> pSession = itSessions->second;
LogFlowThisFunc(("Removing session %RU32 (now total %ld sessions)\n",
uSessionID, mData.mGuestSessions.size() ? mData.mGuestSessions.size() - 1 : 0));
rc = pSession->i_onRemove();
mData.mGuestSessions.erase(itSessions);
alock.release(); /* Release lock before firing off event. */
fireGuestSessionRegisteredEvent(mEventSource, pSession, false /* Unregistered */);
pSession.setNull();
LogFlowFuncLeaveRC(rc);
return rc;
}