/** * Called by setter methods of all USB device filters. * * @note Locks nothing. */ HRESULT USBController::onDeviceFilterChange (USBDeviceFilter *aFilter, BOOL aActiveChanged /* = FALSE */) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); /* we need the machine state */ AutoAnyStateDependency adep(m->pParent); AssertComRCReturnRC(adep.rc()); /* nothing to do if the machine isn't running */ if (!Global::IsOnline (adep.machineState())) return S_OK; /* we don't modify our data fields -- no need to lock */ if ( aFilter->mInList && m->pParent->isRegistered()) { USBProxyService *service = m->pHost->usbProxyService(); ComAssertRet(service, E_FAIL); if (aActiveChanged) { if (aFilter->getData().mRemote.isMatch (false)) { /* insert/remove the filter from the proxy */ if (aFilter->getData().mActive) { ComAssertRet(aFilter->getId() == NULL, E_FAIL); aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter); } else { ComAssertRet(aFilter->getId() != NULL, E_FAIL); service->removeFilter(aFilter->getId()); aFilter->getId() = NULL; } } } else { if (aFilter->getData().mActive) { /* update the filter in the proxy */ ComAssertRet(aFilter->getId() != NULL, E_FAIL); service->removeFilter(aFilter->getId()); if (aFilter->getData().mRemote.isMatch (false)) { aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter); } } } } return S_OK; }
/** * Signals that the current operation is successfully completed and advances to * the next operation. The operation percentage is reset to 0. * * @param aOperationDescription Description of the next operation. * * @note The current operation must not be the last one. */ STDMETHODIMP Progress::SetNextOperation(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight) { AssertReturn(bstrNextOperationDescription, E_INVALIDARG); AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); if (mCanceled) return E_FAIL; AssertReturn(!mCompleted, E_FAIL); AssertReturn(m_ulCurrentOperation + 1 < m_cOperations, E_FAIL); ++m_ulCurrentOperation; m_ulOperationsCompletedWeight += m_ulCurrentOperationWeight; m_bstrOperationDescription = bstrNextOperationDescription; m_ulCurrentOperationWeight = ulNextOperationsWeight; m_ulOperationPercent = 0; Log(("Progress::setNextOperation(%ls): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeight is now %d\n", m_bstrOperationDescription.raw(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight)); /* wake up all waiting threads */ if (mWaitersCount > 0) RTSemEventMultiSignal(mCompletedSem); return S_OK; }
/** * Initializes the Serial Port object given another serial port object * (a kind of copy constructor). This object shares data with * the object passed as an argument. * * @note This object must be destroyed before the original object * it shares data with is destroyed. * * @note Locks @a aThat object for reading. */ HRESULT SerialPort::init(Machine *aParent, SerialPort *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(); unconst(m->pMachine) = aParent; unconst(m->pPeer) = aThat; AutoCaller thatCaller (aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); m->bd.share (aThat->m->bd); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
HRESULT USBDeviceFilters::createDeviceFilter(const com::Utf8Str &aName, ComPtr<IUSBDeviceFilter> &aFilter) { #ifdef VBOX_WITH_USB /* 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, Bstr(aName).raw()); ComAssertComRCRetRC(rc); rc = pFilter.queryInterfaceTo(aFilter.asOutParam()); AssertComRCReturnRC(rc); return S_OK; #else NOREF(aName); NOREF(aFilter); ReturnComNotImplemented(); #endif }
/** * Loads settings from the given machine node. * May be called once right after this object creation. * * @param aMachineNode <Machine> node. * * @note Does not lock "this" as Machine::loadHardware, which calls this, does not lock either. */ HRESULT USBDeviceFilters::i_loadSettings(const settings::USB &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); /* Note: we assume that the default values for attributes of optional * nodes are assigned in the Data::Data() constructor and don't do it * here. It implies that this method may only be called after constructing * a new USBDeviceFilters object while all its data fields are in the default * values. Exceptions are fields whose creation time defaults don't match * values that should be applied when these fields are not explicitly set * in the settings file (for backwards compatibility reasons). This takes * place when a setting of a newly created object must default to A while * the same setting of an object loaded from the old settings file must * default to B. */ #ifdef VBOX_WITH_USB for (settings::USBDeviceFiltersList::const_iterator it = data.llDeviceFilters.begin(); it != data.llDeviceFilters.end(); ++it) { const settings::USBDeviceFilter &f = *it; ComObjPtr<USBDeviceFilter> pFilter; pFilter.createObject(); HRESULT rc = pFilter->init(this, // parent f); if (FAILED(rc)) return rc; m->llDeviceFilters->push_back(pFilter); pFilter->mInList = true; } #endif /* VBOX_WITH_USB */ return S_OK; }
/** * Initializes the mouse object. * * @returns COM result indicator * @param parent handle of our parent object */ HRESULT Mouse::init (Console *parent) { LogFlowThisFunc(("\n")); ComAssertRet(parent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = parent; #ifndef VBOXBFE_WITHOUT_COM unconst(mEventSource).createObject(); HRESULT rc = mEventSource->init(static_cast<IMouse*>(this)); AssertComRCReturnRC(rc); mMouseEvent.init(mEventSource, VBoxEventType_OnGuestMouse, 0, 0, 0, 0, 0); #endif /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the guest object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. * * @note Locks @a aThat object for reading. */ HRESULT NetworkAdapter::initCopy(Machine *aParent, NetworkAdapter *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* mPeer is left null */ unconst(mNATEngine).createObject(); mNATEngine->initCopy(aParent, this, aThat->mNATEngine); AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); mData.attachCopy(aThat->mData); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
HRESULT NATEngine::saveSettings(settings::NAT &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = S_OK; data.strNetwork = mData->mNetwork; data.strBindIP = mData->mBindIP; data.u32Mtu = mData->mMtu; data.u32SockRcv = mData->mSockRcv; data.u32SockSnd = mData->mSockSnd; data.u32TcpRcv = mData->mTcpRcv; data.u32TcpSnd = mData->mTcpSnd; /* TFTP */ data.strTFTPPrefix = mData->mTFTPPrefix; data.strTFTPBootFile = mData->mTFTPBootFile; data.strTFTPNextServer = mData->mTFTPNextServer; /* DNS */ data.fDNSPassDomain = !!mData->mDNSPassDomain; data.fDNSProxy = !!mData->mDNSProxy; data.fDNSUseHostResolver = !!mData->mDNSUseHostResolver; /* Alias */ data.fAliasLog = !!(mData->mAliasMode & NATAliasMode_AliasLog); data.fAliasProxyOnly = !!(mData->mAliasMode & NATAliasMode_AliasProxyOnly); data.fAliasUseSamePorts = !!(mData->mAliasMode & NATAliasMode_AliasUseSamePorts); for (NATRuleMap::iterator it = mNATRules.begin(); it != mNATRules.end(); ++it) data.llRules.push_back(it->second); m_fModified = false; return rc; }
HRESULT NATEngine::loadSettings(const settings::NAT &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); HRESULT rc = S_OK; mData->mNetwork = data.strNetwork; mData->mBindIP = data.strBindIP; mData->mMtu = data.u32Mtu; mData->mSockSnd = data.u32SockSnd; mData->mTcpRcv = data.u32TcpRcv; mData->mTcpSnd = data.u32TcpSnd; /* TFTP */ mData->mTFTPPrefix = data.strTFTPPrefix; mData->mTFTPBootFile = data.strTFTPBootFile; mData->mTFTPNextServer = data.strTFTPNextServer; /* DNS */ mData->mDNSPassDomain = data.fDNSPassDomain; mData->mDNSProxy = data.fDNSProxy; mData->mDNSUseHostResolver = data.fDNSUseHostResolver; /* Alias */ mData->mAliasMode = (data.fAliasUseSamePorts ? NATAliasMode_AliasUseSamePorts : 0); mData->mAliasMode |= (data.fAliasLog ? NATAliasMode_AliasLog : 0); mData->mAliasMode |= (data.fAliasProxyOnly ? NATAliasMode_AliasProxyOnly : 0); /* port forwarding */ mNATRules.clear(); for (settings::NATRuleList::const_iterator it = data.llRules.begin(); it != data.llRules.end(); ++it) { mNATRules.insert(std::make_pair(it->strName, *it)); } m_fModified = false; return rc; }
STDMETHODIMP USBController::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> filter; filter.createObject(); HRESULT rc = filter->init (this, aName); ComAssertComRCRetRC (rc); rc = filter.queryInterfaceTo(aFilter); AssertComRCReturnRC(rc); return S_OK; #else NOREF(aName); NOREF(aFilter); ReturnComNotImplemented(); #endif }
/** * Initializes the medium attachment object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. */ HRESULT MediumAttachment::initCopy(Machine *aParent, MediumAttachment *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); m = new Data(aParent); /* m->pPeer is left null */ AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS); m->bd.attachCopy(aThat->m->bd); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); /* Construct a short log name for this attachment. */ i_updateLogName(); LogFlowThisFunc(("LEAVE - %s\n", i_getLogName())); return S_OK; }
/** * Initializes the guest object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. * * @note Locks @a aThat object for reading. */ HRESULT USBDeviceFilter::initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat) { LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; /* mPeer is left null */ m_fModified = false; /* sanity */ AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); bd.attachCopy(aThat->bd); /* reset the arbitrary ID field * (this field is something unique that two distinct objects, even if they * are deep copies of each other, should not share) */ bd->mId = NULL; mInList = aThat->mInList; /* Confirm successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Initializes the VirtualBoxClient object. * * @returns COM result indicator */ HRESULT VirtualBoxClient::init() { LogFlowThisFunc(("\n")); HRESULT rc; /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); mData.m_ThreadWatcher = NIL_RTTHREAD; mData.m_SemEvWatcher = NIL_RTSEMEVENT; if (ASMAtomicIncU32(&g_cInstances) != 1) AssertFailedReturn(E_FAIL); rc = mData.m_pVirtualBox.createLocalObject(CLSID_VirtualBox); AssertComRCReturnRC(rc); rc = unconst(mData.m_pEventSource).createObject(); AssertComRCReturnRC(rc); rc = mData.m_pEventSource->init(static_cast<IVirtualBoxClient *>(this)); AssertComRCReturnRC(rc); /* Setting up the VBoxSVC watcher thread. If anything goes wrong here it * is not considered important enough to cause any sort of visible * failure. The monitoring will not be done, but that's all. */ int vrc = RTSemEventCreate(&mData.m_SemEvWatcher); AssertRC(vrc); if (RT_SUCCESS(vrc)) { vrc = RTThreadCreate(&mData.m_ThreadWatcher, SVCWatcherThread, this, 0, RTTHREADTYPE_INFREQUENT_POLLER, RTTHREADFLAGS_WAITABLE, "VBoxSVCWatcher"); AssertRC(vrc); } else { RTSemEventDestroy(mData.m_SemEvWatcher); mData.m_SemEvWatcher = NIL_RTSEMEVENT; } /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return rc; }
STDMETHODIMP NATEngine::COMGETTER(AliasMode)(ULONG *aAliasMode) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); *aAliasMode = mData->mAliasMode; return S_OK; }
STDMETHODIMP NATEngine::COMGETTER(DNSUseHostResolver)(BOOL *aDNSUseHostResolver) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); *aDNSUseHostResolver = mData->mDNSUseHostResolver; return S_OK; }
STDMETHODIMP NATEngine::COMGETTER(DNSProxy)(BOOL *aDNSProxy) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); *aDNSProxy = mData->mDNSProxy; return S_OK; }
STDMETHODIMP NATEngine::COMGETTER(HostIP)(BSTR *aBindIP) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (!mData->mBindIP.isEmpty()) mData->mBindIP.cloneTo(aBindIP); return S_OK; }
/** * Sets the internal result code and attempts to retrieve additional error * info from the current thread. Gets called from Progress::notifyComplete(), * but can be called again to override a previous result set with * notifyComplete(). * * @param aResultCode */ HRESULT Progress::setResultCode(HRESULT aResultCode) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); mResultCode = aResultCode; HRESULT rc = S_OK; if (FAILED(aResultCode)) { /* try to import error info from the current thread */ #if !defined(VBOX_WITH_XPCOM) ComPtr<IErrorInfo> err; rc = ::GetErrorInfo(0, err.asOutParam()); if (rc == S_OK && err) { rc = err.queryInterfaceTo(mErrorInfo.asOutParam()); if (SUCCEEDED(rc) && !mErrorInfo) rc = E_FAIL; } #else /* !defined(VBOX_WITH_XPCOM) */ nsCOMPtr<nsIExceptionService> es; es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc); if (NS_SUCCEEDED(rc)) { nsCOMPtr <nsIExceptionManager> em; rc = es->GetCurrentExceptionManager(getter_AddRefs(em)); if (NS_SUCCEEDED(rc)) { ComPtr<nsIException> ex; rc = em->GetCurrentException(ex.asOutParam()); if (NS_SUCCEEDED(rc) && ex) { rc = ex.queryInterfaceTo(mErrorInfo.asOutParam()); if (NS_SUCCEEDED(rc) && !mErrorInfo) rc = E_FAIL; } } } #endif /* !defined(VBOX_WITH_XPCOM) */ AssertMsg(rc == S_OK, ("Couldn't get error info (rc=%08X) while trying to set a failed result (%08X)!\n", rc, aResultCode)); } return rc; }
/** * Loads settings from the given port node. * May be called once right after this object creation. * * @param aPortNode <Port> node. * * @note Locks this object for writing. */ HRESULT ParallelPort::i_loadSettings(const settings::ParallelPort &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); // simply copy *m->bd.data() = data; return S_OK; }
/** * Saves settings to the given machine node. * * @param aMachineNode <Machine> node. * * @note Locks this object for reading. */ HRESULT AudioAdapter::saveSettings(settings::AudioAdapter &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); data.fEnabled = !!mData->mEnabled; data.controllerType = mData->mAudioController; data.driverType = mData->mAudioDriver; return S_OK; }
/** * Saves the port settings to the given port node. * * Note that the given Port node is completely empty on input. * * @param aPortNode <Port> node. * * @note Locks this object for reading. */ HRESULT SerialPort::i_saveSettings(settings::SerialPort &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); // simply copy data = *m->bd.data(); return S_OK; }
STDMETHODIMP NATEngine::COMGETTER(TFTPNextServer)(BSTR *aTFTPNextServer) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (!mData->mTFTPNextServer.isEmpty()) { mData->mTFTPNextServer.cloneTo(aTFTPNextServer); Log(("Getter (this:%p) NextServer: %s\n", this, mData->mTFTPNextServer.c_str())); } return S_OK; }
STDMETHODIMP NATEngine::COMGETTER(Network)(BSTR *aNetwork) { CheckComArgNotNull(aNetwork); AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (!mData->mNetwork.isEmpty()) { mData->mNetwork.cloneTo(aNetwork); Log(("Getter (this:%p) Network: %s\n", this, mData->mNetwork.c_str())); } return S_OK; }
STDMETHODIMP NATEngine::COMSETTER(TFTPNextServer)(IN_BSTR aTFTPNextServer) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); if (Bstr(mData->mTFTPNextServer) != aTFTPNextServer) { mData.backup(); mData->mTFTPNextServer = aTFTPNextServer; mParent->setModified(Machine::IsModified_NetworkAdapters); m_fModified = true; } return S_OK; }
STDMETHODIMP NATEngine::COMSETTER(AliasMode)(ULONG aAliasMode) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (mData->mAliasMode != aAliasMode) { mData.backup(); mData->mAliasMode = aAliasMode; mParent->setModified(Machine::IsModified_NetworkAdapters); m_fModified = true; } return S_OK; }
STDMETHODIMP NATEngine::COMSETTER(DNSProxy)(BOOL aDNSProxy) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); if (mData->mDNSProxy != aDNSProxy) { mData.backup(); mData->mDNSProxy = aDNSProxy; mParent->setModified(Machine::IsModified_NetworkAdapters); m_fModified = true; } return S_OK; }
/** * Initializes the object given another object * (a kind of copy constructor). This object shares data with * the object passed as an argument. * * @param aReshare * When false, the original object will remain a data owner. * Otherwise, data ownership will be transferred from the original * object to this one. * * @note This object must be destroyed before the original object * it shares data with is destroyed. * * @note Locks @a aThat object for writing if @a aReshare is @c true, or for * reading if @a aReshare is false. */ HRESULT USBDeviceFilter::init(USBDeviceFilters *aParent, USBDeviceFilter *aThat, bool aReshare /* = false */) { LogFlowThisFunc(("aParent=%p, aThat=%p, aReshare=%RTbool\n", aParent, aThat, aReshare)); ComAssertRet(aParent && aThat, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; m_fModified = false; /* sanity */ AutoCaller thatCaller(aThat); AssertComRCReturnRC(thatCaller.rc()); if (aReshare) { AutoWriteLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); unconst(aThat->mPeer) = this; bd.attach(aThat->bd); } else { unconst(mPeer) = aThat; AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); bd.share(aThat->bd); } /* the arbitrary ID field is not reset because * the copy is a shadow of the original */ mInList = aThat->mInList; /* Confirm successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }
/** * Marks the operation as complete and attaches full error info. * * See VirtualBoxBase::setError(HRESULT, const GUID &, const wchar_t * *, const char *, ...) for more info. * * @param aResultCode Operation result (error) code, must not be S_OK. * @param aIID IID of the interface that defines the error. * @param aComponent Name of the component that generates the error. * @param aText Error message (must not be null), an RTStrPrintf-like * format string in UTF-8 encoding. * @param va List of arguments for the format string. */ HRESULT Progress::i_notifyCompleteV(HRESULT aResultCode, const GUID &aIID, const char *pcszComponent, const char *aText, va_list va) { Utf8Str text(aText, va); AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); AssertReturn(mCompleted == FALSE, E_FAIL); if (mCanceled && SUCCEEDED(aResultCode)) aResultCode = E_FAIL; mCompleted = TRUE; mResultCode = aResultCode; AssertReturn(FAILED(aResultCode), E_FAIL); ComObjPtr<VirtualBoxErrorInfo> errorInfo; HRESULT rc = errorInfo.createObject(); AssertComRC(rc); if (SUCCEEDED(rc)) { errorInfo->init(aResultCode, aIID, pcszComponent, text); errorInfo.queryInterfaceTo(mErrorInfo.asOutParam()); } #if !defined VBOX_COM_INPROC /* remove from the global collection of pending progress operations */ if (mParent) mParent->i_removeProgress(mId.ref()); #endif /* wake up all waiting threads */ if (mWaitersCount > 0) RTSemEventMultiSignal(mCompletedSem); return rc; }
/** * Saves settings to the given adapter node. * * Note that the given Adapter node is completely empty on input. * * @param aAdapterNode <Adapter> node. * * @note Locks this object for reading. */ HRESULT NetworkAdapter::saveSettings(settings::NetworkAdapter &data) { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); data.fEnabled = !!mData->mEnabled; data.strMACAddress = mData->mMACAddress; data.fCableConnected = !!mData->mCableConnected; data.enmPromiscModePolicy = mData->mPromiscModePolicy; data.ulLineSpeed = mData->mLineSpeed; data.fTraceEnabled = !!mData->mTraceEnabled; data.strTraceFile = mData->mTraceFile; data.ulBootPriority = mData->mBootPriority; data.strBandwidthGroup = mData->mBandwidthGroup; data.type = mData->mAdapterType; data.mode = mData->mAttachmentType; mNATEngine->commit(); mNATEngine->saveSettings(data.nat); data.strBridgedName = mData->mBridgedInterface; data.strHostOnlyName = mData->mHostOnlyInterface; data.strInternalNetworkName = mData->mInternalNetwork; data.strGenericDriver = mData->mGenericDriver; data.genericProperties = mData->mGenericProperties; // after saving settings, we are no longer different from the XML on disk m_fModified = false; return S_OK; }
/** * Initializes the keyboard object. * * @returns COM result indicator * @param parent handle of our parent object */ HRESULT Keyboard::init(Console *aParent) { LogFlowThisFunc(("aParent=%p\n", aParent)); ComAssertRet(aParent, E_INVALIDARG); /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); AssertReturn(autoInitSpan.isOk(), E_FAIL); unconst(mParent) = aParent; unconst(mEventSource).createObject(); HRESULT rc = mEventSource->init(); AssertComRCReturnRC(rc); /* Confirm a successful initialization */ autoInitSpan.setSucceeded(); return S_OK; }