HRESULT Guest::facilityUpdate(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus) { ComAssertRet(enmFacility < INT32_MAX, E_INVALIDARG); HRESULT rc; RTTIMESPEC tsNow; RTTimeNow(&tsNow); FacilityMapIter it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility); if (it != mData.mFacilityMap.end()) { AdditionsFacility *pFac = it->second; rc = pFac->update((AdditionsFacilityStatus_T)enmStatus, tsNow); } else { ComObjPtr<AdditionsFacility> pFacility; pFacility.createObject(); ComAssert(!pFacility.isNull()); rc = pFacility->init(this, (AdditionsFacilityType_T)enmFacility, (AdditionsFacilityStatus_T)enmStatus); if (SUCCEEDED(rc)) mData.mFacilityMap.insert(std::make_pair((AdditionsFacilityType_T)enmFacility, pFacility)); } LogFlowFunc(("Returned with rc=%Rrc\n")); return rc; }
/** * Returns the status of a specified Guest Additions facility. * * @return aStatus Current status of specified facility. * @param aType Facility to get the status from. * @param aTimestamp Timestamp of last facility status update in ms (optional). */ STDMETHODIMP Guest::GetFacilityStatus(AdditionsFacilityType_T aType, LONG64 *aTimestamp, AdditionsFacilityStatus_T *aStatus) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); CheckComArgNotNull(aStatus); /* Not checking for aTimestamp is intentional; it's optional. */ FacilityMapIterConst it = mData.mFacilityMap.find(aType); if (it != mData.mFacilityMap.end()) { AdditionsFacility *pFacility = it->second; ComAssert(pFacility); *aStatus = pFacility->getStatus(); if (aTimestamp) *aTimestamp = pFacility->getLastUpdated(); } else { /* * Do not fail here -- could be that the facility never has been brought up (yet) but * the host wants to have its status anyway. So just tell we don't know at this point. */ *aStatus = AdditionsFacilityStatus_Unknown; if (aTimestamp) *aTimestamp = RTTimeMilliTS(); } return S_OK; }
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)); } }
bool Guest::facilityIsActive(VBoxGuestFacilityType enmFacility) { Assert(enmFacility < INT32_MAX); FacilityMapIterConst it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility); if (it != mData.mFacilityMap.end()) { AdditionsFacility *pFac = it->second; return (pFac->getStatus() == AdditionsFacilityStatus_Active); } return false; }