本文整理汇总了C++中Utf8Str::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ Utf8Str::c_str方法的具体用法?C++ Utf8Str::c_str怎么用?C++ Utf8Str::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8Str
的用法示例。
在下文中一共展示了Utf8Str::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/**
* Initializes the bandwidth group object.
*
* @returns COM result indicator.
* @param aParent Pointer to our parent object.
* @param aName Name of the storage controller.
* @param aInstance Instance number of the storage controller.
*/
HRESULT BandwidthGroup::init(BandwidthControl *aParent,
const Utf8Str &aName,
BandwidthGroupType_T aType,
LONG64 aMaxBytesPerSec)
{
LogFlowThisFunc(("aParent=%p aName=\"%s\"\n",
aParent, aName.c_str()));
ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG);
if ( (aType <= BandwidthGroupType_Null)
|| (aType > BandwidthGroupType_Network))
return setError(E_INVALIDARG,
tr("Invalid bandwidth group type type"));
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* m->pPeer is left null */
m->bd.allocate();
m->bd->strName = aName;
m->bd->enmType = aType;
m->bd->cReferences = 0;
m->bd->aMaxBytesPerSec = aMaxBytesPerSec;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例2: GluePrintErrorInfo
void GluePrintErrorInfo(const com::ErrorInfo &info)
{
bool haveResultCode = false;
#if defined (RT_OS_WIN)
haveResultCode = info.isFullAvailable();
bool haveComponent = true;
bool haveInterfaceID = true;
#else /* defined (RT_OS_WIN) */
haveResultCode = true;
bool haveComponent = info.isFullAvailable();
bool haveInterfaceID = info.isFullAvailable();
#endif
Utf8Str str;
RTCList<Utf8Str> comp;
Bstr bstrDetailsText = info.getText();
if (!bstrDetailsText.isEmpty())
str = Utf8StrFmt("%ls\n",
bstrDetailsText.raw());
if (haveResultCode)
comp.append(Utf8StrFmt("code %Rhrc (0x%RX32)",
info.getResultCode(),
info.getResultCode()));
if (haveComponent)
comp.append(Utf8StrFmt("component %ls",
info.getComponent().raw()));
if (haveInterfaceID)
comp.append(Utf8StrFmt("interface %ls",
info.getInterfaceName().raw()));
if (!info.getCalleeName().isEmpty())
comp.append(Utf8StrFmt("callee %ls",
info.getCalleeName().raw()));
if (comp.size() > 0)
{
str += "Details: ";
for (size_t i = 0; i < comp.size() - 1; ++i)
str += comp.at(i) + ", ";
str += comp.last();
str += "\n";
}
// print and log
RTMsgError("%s", str.c_str());
Log(("ERROR: %s", str.c_str()));
}
示例3: while
size_t Utf8Str::parseKeyValue(Utf8Str &key, Utf8Str &value, size_t pos, const Utf8Str &pairSeparator, const Utf8Str &keyValueSeparator) const
{
size_t start = pos;
while(start == (pos = find(pairSeparator.c_str(), pos)))
start = ++pos;
size_t kvSepPos = find(keyValueSeparator.c_str(), start);
if (kvSepPos < pos)
{
key = substr(start, kvSepPos - start);
value = substr(kvSepPos + 1, pos - kvSepPos - 1);
}
else
{
key = value = "";
}
return pos;
}
示例4: COMGETTER
STDMETHODIMP VRDEServer::COMGETTER(VRDEExtPack) (BSTR *aExtPack)
{
CheckComArgOutPointerValid(aExtPack);
AutoCaller autoCaller(this);
HRESULT hrc = autoCaller.rc();
if (SUCCEEDED(hrc))
{
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
Utf8Str strExtPack = mData->mVrdeExtPack;
alock.release();
if (strExtPack.isNotEmpty())
{
if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
hrc = S_OK;
else
{
#ifdef VBOX_WITH_EXTPACK
ExtPackManager *pExtPackMgr = mParent->getVirtualBox()->getExtPackManager();
hrc = pExtPackMgr->checkVrdeExtPack(&strExtPack);
#else
hrc = setError(E_FAIL, tr("Extension pack '%s' does not exist"), strExtPack.c_str());
#endif
}
if (SUCCEEDED(hrc))
strExtPack.cloneTo(aExtPack);
}
else
{
/* Get the global setting. */
ComPtr<ISystemProperties> systemProperties;
hrc = mParent->getVirtualBox()->COMGETTER(SystemProperties)(systemProperties.asOutParam());
if (SUCCEEDED(hrc))
hrc = systemProperties->COMGETTER(DefaultVRDEExtPack)(aExtPack);
}
}
return hrc;
}
示例5: init
/**
* Initializes the sub-progress object that represents a specific operation of
* the whole task.
*
* Objects initialized with this method are then combined together into the
* single task using a Progress instance, so it doesn't require the
* parent, initiator, description and doesn't create an ID. Note that calling
* respective getter methods on an object initialized with this method is
* useless. Such objects are used only to provide a separate wait semaphore and
* store individual operation descriptions.
*
* @param aCancelable Flag whether the task maybe canceled.
* @param aOperationCount Number of sub-operations within this task (at least 1).
* @param aOperationDescription Description of the individual operation.
*/
HRESULT Progress::init(BOOL aCancelable,
ULONG aOperationCount,
Utf8Str aOperationDescription)
{
LogFlowThisFunc(("aOperationDescription=\"%s\"\n", aOperationDescription.c_str()));
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
HRESULT rc = S_OK;
/* Guarantees subclasses call this method at the proper time */
NOREF(autoInitSpan);
if (FAILED(rc)) return rc;
mCancelable = aCancelable;
// for this variant we assume for now that all operations are weighed "1"
// and equal total weight = operation count
m_cOperations = aOperationCount;
m_ulTotalOperationsWeight = aOperationCount;
m_ulOperationsCompletedWeight = 0;
m_ulCurrentOperation = 0;
m_operationDescription = aOperationDescription;
m_ulCurrentOperationWeight = 1;
m_ulOperationPercent = 0;
int vrc = RTSemEventMultiCreate(&mCompletedSem);
ComAssertRCRet(vrc, E_FAIL);
RTSemEventMultiReset(mCompletedSem);
/* Confirm a successful initialization when it's the case */
if (SUCCEEDED(rc))
autoInitSpan.setSucceeded();
return rc;
}
示例6: getVRDEExtPack
HRESULT VRDEServer::getVRDEExtPack(com::Utf8Str &aExtPack)
{
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
Utf8Str strExtPack = mData->mVrdeExtPack;
alock.release();
HRESULT hrc = S_OK;
if (strExtPack.isNotEmpty())
{
if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
hrc = S_OK;
else
{
#ifdef VBOX_WITH_EXTPACK
ExtPackManager *pExtPackMgr = mParent->i_getVirtualBox()->i_getExtPackManager();
hrc = pExtPackMgr->i_checkVrdeExtPack(&strExtPack);
#else
hrc = setError(E_FAIL, tr("Extension pack '%s' does not exist"), strExtPack.c_str());
#endif
}
if (SUCCEEDED(hrc))
aExtPack = strExtPack;
}
else
{
/* Get the global setting. */
ComPtr<ISystemProperties> systemProperties;
hrc = mParent->i_getVirtualBox()->COMGETTER(SystemProperties)(systemProperties.asOutParam());
if (SUCCEEDED(hrc))
{
BSTR bstr;
hrc = systemProperties->COMGETTER(DefaultVRDEExtPack)(&bstr);
if (SUCCEEDED(hrc))
aExtPack = Utf8Str(bstr);
}
}
return hrc;
}
示例7: init
/**
* Initializes the host object.
*
* @returns COM result indicator
* @param aInterfaceName name of the network interface
* @param aShortName short name of the network interface
* @param aGuid GUID of the host network interface
* @param ifType interface type
*/
HRESULT HostNetworkInterface::init(Utf8Str aInterfaceName, Utf8Str aShortName, Guid aGuid, HostNetworkInterfaceType_T ifType)
{
LogFlowThisFunc(("aInterfaceName={%s}, aGuid={%s}\n",
aInterfaceName.c_str(), aGuid.toString().c_str()));
ComAssertRet(!aInterfaceName.isEmpty(), E_INVALIDARG);
ComAssertRet(aGuid.isValid(), E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
unconst(mInterfaceName) = aInterfaceName;
unconst(mNetworkName) = i_composeNetworkName(aShortName);
unconst(mShortName) = aShortName;
unconst(mGuid) = aGuid;
mIfType = ifType;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例8: getVRDEProperties
HRESULT VRDEServer::getVRDEProperties(std::vector<com::Utf8Str> &aProperties)
{
size_t cProperties = 0;
aProperties.resize(0);
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
if (!mData->mEnabled)
{
return S_OK;
}
alock.release();
/*
* Check that a VRDE extension pack name is set and resolve it into a
* library path.
*/
Bstr bstrExtPack;
HRESULT hrc = COMGETTER(VRDEExtPack)(bstrExtPack.asOutParam());
Log(("VRDEPROP: get extpack hrc 0x%08X, isEmpty %d\n", hrc, bstrExtPack.isEmpty()));
if (FAILED(hrc))
return hrc;
if (bstrExtPack.isEmpty())
return E_FAIL;
Utf8Str strExtPack(bstrExtPack);
Utf8Str strVrdeLibrary;
int vrc = VINF_SUCCESS;
if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
strVrdeLibrary = "VBoxVRDP";
else
{
#ifdef VBOX_WITH_EXTPACK
VirtualBox *pVirtualBox = mParent->i_getVirtualBox();
ExtPackManager *pExtPackMgr = pVirtualBox->i_getExtPackManager();
vrc = pExtPackMgr->i_getVrdeLibraryPathForExtPack(&strExtPack, &strVrdeLibrary);
#else
vrc = VERR_FILE_NOT_FOUND;
#endif
}
Log(("VRDEPROP: library get rc %Rrc\n", vrc));
if (RT_SUCCESS(vrc))
{
/*
* Load the VRDE library and start the server, if it is enabled.
*/
PFNVRDESUPPORTEDPROPERTIES pfn = NULL;
RTLDRMOD hmod = NIL_RTLDRMOD;
vrc = loadVRDELibrary(strVrdeLibrary.c_str(), &hmod, &pfn);
Log(("VRDEPROP: load library [%s] rc %Rrc\n", strVrdeLibrary.c_str(), vrc));
if (RT_SUCCESS(vrc))
{
const char * const *papszNames = pfn();
if (papszNames)
{
size_t i;
for (i = 0; papszNames[i] != NULL; ++i)
{
cProperties++;
}
}
Log(("VRDEPROP: %d properties\n", cProperties));
if (cProperties > 0)
{
aProperties.resize(cProperties);
for (size_t i = 0; papszNames[i] != NULL && i < cProperties; ++i)
{
aProperties[i] = papszNames[i];
}
}
/* Do not forget to unload the library. */
RTLdrClose(hmod);
hmod = NIL_RTLDRMOD;
}
}
if (RT_FAILURE(vrc))
{
return E_FAIL;
}
return S_OK;
}
示例9: grabIPCSemaphore
/** @note To be called only from #AssignMachine() */
HRESULT Session::grabIPCSemaphore()
{
HRESULT rc = E_FAIL;
/* open the IPC semaphore based on the sessionId and try to grab it */
Bstr ipcId;
rc = mControl->GetIPCId(ipcId.asOutParam());
AssertComRCReturnRC(rc);
LogFlowThisFunc(("ipcId='%ls'\n", ipcId.raw()));
#if defined(RT_OS_WINDOWS)
/*
* Since Session is an MTA object, this method can be executed on
* any thread, and this thread will not necessarily match the thread on
* which close() will be called later. Therefore, we need a separate
* thread to hold the IPC mutex and then release it in close().
*/
mIPCThreadSem = ::CreateEvent(NULL, FALSE, FALSE, NULL);
AssertMsgReturn(mIPCThreadSem,
("Cannot create an event sem, err=%d", ::GetLastError()),
E_FAIL);
void *data[3];
data[0] = (void*)(BSTR)ipcId.raw();
data[1] = (void*)mIPCThreadSem;
data[2] = 0; /* will get an output from the thread */
/* create a thread to hold the IPC mutex until signalled to release it */
RTTHREAD tid;
int vrc = RTThreadCreate(&tid, IPCMutexHolderThread, (void*)data, 0, RTTHREADTYPE_MAIN_WORKER, 0, "IPCHolder");
AssertRCReturn(vrc, E_FAIL);
/* wait until thread init is completed */
DWORD wrc = ::WaitForSingleObject(mIPCThreadSem, INFINITE);
AssertMsg(wrc == WAIT_OBJECT_0, ("Wait failed, err=%d\n", ::GetLastError()));
Assert(data[2]);
if (wrc == WAIT_OBJECT_0 && data[2])
{
/* memorize the event sem we should signal in close() */
mIPCSem = (HANDLE)data[2];
rc = S_OK;
}
else
{
::CloseHandle(mIPCThreadSem);
mIPCThreadSem = NULL;
rc = E_FAIL;
}
#elif defined(RT_OS_OS2)
/* We use XPCOM where any message (including close()) can arrive on any
* worker thread (which will not necessarily match this thread that opens
* the mutex). Therefore, we need a separate thread to hold the IPC mutex
* and then release it in close(). */
int vrc = RTSemEventCreate(&mIPCThreadSem);
AssertRCReturn(vrc, E_FAIL);
void *data[3];
data[0] = (void*)ipcId.raw();
data[1] = (void*)mIPCThreadSem;
data[2] = (void*)false; /* will get the thread result here */
/* create a thread to hold the IPC mutex until signalled to release it */
vrc = RTThreadCreate(&mIPCThread, IPCMutexHolderThread, (void *) data,
0, RTTHREADTYPE_MAIN_WORKER, 0, "IPCHolder");
AssertRCReturn(vrc, E_FAIL);
/* wait until thread init is completed */
vrc = RTThreadUserWait (mIPCThread, RT_INDEFINITE_WAIT);
AssertReturn(RT_SUCCESS(vrc) || vrc == VERR_INTERRUPTED, E_FAIL);
/* the thread must succeed */
AssertReturn((bool)data[2], E_FAIL);
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
# ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
Utf8Str ipcKey = ipcId;
key_t key = RTStrToUInt32(ipcKey.c_str());
AssertMsgReturn (key != 0,
("Key value of 0 is not valid for IPC semaphore"),
E_FAIL);
# else /* !VBOX_WITH_NEW_SYS_V_KEYGEN */
Utf8Str semName = ipcId;
char *pszSemName = NULL;
RTStrUtf8ToCurrentCP (&pszSemName, semName);
key_t key = ::ftok (pszSemName, 'V');
RTStrFree (pszSemName);
# endif /* !VBOX_WITH_NEW_SYS_V_KEYGEN */
mIPCSem = ::semget (key, 0, 0);
AssertMsgReturn (mIPCSem >= 0,
("Cannot open IPC semaphore, errno=%d", errno),
//.........这里部分代码省略.........
示例10: receiveData
HRESULT GuestDnDSource::receiveData(std::vector<BYTE> &aData)
{
#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
ReturnComNotImplemented();
#else /* VBOX_WITH_DRAG_AND_DROP */
/* Input validation. */
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
HRESULT hr = S_OK;
GuestDnDResponse *pResp = GuestDnDInst()->response();
if (pResp)
{
size_t cbData = pResp->size();
if (cbData)
{
const void *pvData = pResp->data();
AssertPtr(pvData);
Utf8Str strFormat = pResp->format();
LogFlowFunc(("strFormat=%s, cbData=%zu, pvData=0x%p\n",
strFormat.c_str(), cbData, pvData));
try
{
if (DnDMIMEHasFileURLs(strFormat.c_str(), strFormat.length()))
{
LogFlowFunc(("strDropDir=%s\n", pResp->dropDir().c_str()));
DnDURIList lstURI;
int rc2 = lstURI.RootFromURIData(pvData, cbData, 0 /* fFlags */);
if (RT_SUCCESS(rc2))
{
Utf8Str strURIs = lstURI.RootToString(pResp->dropDir());
size_t cbURIs = strURIs.length();
LogFlowFunc(("Found %zu root URIs (%zu bytes)\n",
lstURI.RootCount(), cbURIs));
aData.resize(cbURIs + 1 /* Include termination */);
memcpy(&aData.front(), strURIs.c_str(), cbURIs);
}
else
hr = VBOX_E_IPRT_ERROR;
}
else
{
/* Copy the data into a safe array of bytes. */
aData.resize(cbData);
memcpy(&aData.front(), pvData, cbData);
}
}
catch (std::bad_alloc &)
{
hr = E_OUTOFMEMORY;
}
}
/* Delete the data. */
pResp->reset();
}
else
hr = VBOX_E_INVALID_OBJECT_STATE;
LogFlowFunc(("Returning hr=%Rhrc\n", hr));
return hr;
#endif /* VBOX_WITH_DRAG_AND_DROP */
}
示例11: init
/**
* Initializes the storage controller object.
*
* @returns COM result indicator.
* @param aParent Pointer to our parent object.
* @param aName Name of the storage controller.
* @param aInstance Instance number of the storage controller.
*/
HRESULT StorageController::init(Machine *aParent,
const Utf8Str &aName,
StorageBus_T aStorageBus,
ULONG aInstance, bool fBootable)
{
LogFlowThisFunc(("aParent=%p aName=\"%s\" aInstance=%u\n",
aParent, aName.c_str(), aInstance));
ComAssertRet(aParent && !aName.isEmpty(), E_INVALIDARG);
if ( (aStorageBus <= StorageBus_Null)
|| (aStorageBus > StorageBus_USB))
return setError(E_INVALIDARG,
tr("Invalid storage connection type"));
ULONG maxInstances;
ChipsetType_T chipsetType;
HRESULT rc = aParent->COMGETTER(ChipsetType)(&chipsetType);
if (FAILED(rc))
return rc;
rc = aParent->i_getVirtualBox()->i_getSystemProperties()->
GetMaxInstancesOfStorageBus(chipsetType, aStorageBus, &maxInstances);
if (FAILED(rc))
return rc;
if (aInstance >= maxInstances)
return setError(E_INVALIDARG,
tr("Too many storage controllers of this type"));
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data(aParent);
/* m->pPeer is left null */
m->bd.allocate();
m->bd->strName = aName;
m->bd->mInstance = aInstance;
m->bd->fBootable = fBootable;
m->bd->mStorageBus = aStorageBus;
if ( aStorageBus != StorageBus_IDE
&& aStorageBus != StorageBus_Floppy)
m->bd->fUseHostIOCache = false;
else
m->bd->fUseHostIOCache = true;
switch (aStorageBus)
{
case StorageBus_IDE:
m->bd->mPortCount = 2;
m->bd->mStorageControllerType = StorageControllerType_PIIX4;
break;
case StorageBus_SATA:
m->bd->mPortCount = 30;
m->bd->mStorageControllerType = StorageControllerType_IntelAhci;
break;
case StorageBus_SCSI:
m->bd->mPortCount = 16;
m->bd->mStorageControllerType = StorageControllerType_LsiLogic;
break;
case StorageBus_Floppy:
m->bd->mPortCount = 1;
m->bd->mStorageControllerType = StorageControllerType_I82078;
break;
case StorageBus_SAS:
m->bd->mPortCount = 8;
m->bd->mStorageControllerType = StorageControllerType_LsiLogicSas;
case StorageBus_USB:
m->bd->mPortCount = 8;
m->bd->mStorageControllerType = StorageControllerType_USB;
break;
}
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
示例12: protectedInit
/**
* Shared initialization code. Called from the other constructors.
*
* @note
* Must be called from under the object's lock!
*/
HRESULT SharedFolder::protectedInit(VirtualBoxBase *aParent,
const Utf8Str &aName,
const Utf8Str &aHostPath,
bool aWritable,
bool aAutoMount,
bool fFailOnError)
{
LogFlowThisFunc(("aName={%s}, aHostPath={%s}, aWritable={%d}, aAutoMount={%d}\n",
aName.c_str(), aHostPath.c_str(), aWritable, aAutoMount));
ComAssertRet(aParent && aName.isNotEmpty() && aHostPath.isNotEmpty(), E_INVALIDARG);
Utf8Str hostPath = aHostPath;
size_t hostPathLen = hostPath.length();
/* Remove the trailing slash unless it's a root directory
* (otherwise the comparison with the RTPathAbs() result will fail at least
* on Linux). Note that this isn't really necessary for the shared folder
* itself, since adding a mapping eventually results into a
* RTDirOpenFiltered() call (see HostServices/SharedFolders) that seems to
* accept both the slashified paths and not. */
#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
if (hostPathLen > 2 &&
RTPATH_IS_SEP (hostPath.c_str()[hostPathLen - 1]) &&
RTPATH_IS_VOLSEP (hostPath.c_str()[hostPathLen - 2]))
;
#else
if (hostPathLen == 1 && RTPATH_IS_SEP(hostPath[0]))
;
#endif
else
hostPath.stripTrailingSlash();
if (fFailOnError)
{
/* Check whether the path is full (absolute) */
char hostPathFull[RTPATH_MAX];
int vrc = RTPathAbsEx(NULL,
hostPath.c_str(),
hostPathFull,
sizeof (hostPathFull));
if (RT_FAILURE(vrc))
return setError(E_INVALIDARG,
tr("Invalid shared folder path: '%s' (%Rrc)"),
hostPath.c_str(), vrc);
if (RTPathCompare(hostPath.c_str(), hostPathFull) != 0)
return setError(E_INVALIDARG,
tr("Shared folder path '%s' is not absolute"),
hostPath.c_str());
}
unconst(mParent) = aParent;
unconst(m->strName) = aName;
unconst(m->strHostPath) = hostPath;
m->fWritable = aWritable;
m->fAutoMount = aAutoMount;
return S_OK;
}
示例13: init
/**
* Initializes the medium attachment object.
*
* @param aParent Machine object.
* @param aMedium Medium object.
* @param aControllerName Controller the hard disk is attached to.
* @param aPort Port number.
* @param aDevice Device number on the port.
* @param aType Device type.
* @param aImplicit
* @param aPassthrough Whether accesses are directly passed to the host drive.
* @param aTempEject Whether guest-triggered eject results in unmounting the medium.
* @param aNonRotational Whether this medium is non-rotational (aka SSD).
* @param aDiscard Whether this medium supports discarding unused blocks.
* @param aHotPluggable Whether this medium is hot-pluggable.
* @param strBandwidthGroup Bandwidth group.
*/
HRESULT MediumAttachment::init(Machine *aParent,
Medium *aMedium,
const Utf8Str &aControllerName,
LONG aPort,
LONG aDevice,
DeviceType_T aType,
bool aImplicit,
bool aPassthrough,
bool aTempEject,
bool aNonRotational,
bool aDiscard,
bool aHotPluggable,
const Utf8Str &strBandwidthGroup)
{
LogFlowThisFuncEnter();
LogFlowThisFunc(("aParent=%p aMedium=%p aControllerName=%s aPort=%d aDevice=%d aType=%d aImplicit=%d aPassthrough=%d aTempEject=%d aNonRotational=%d aDiscard=%d aHotPluggable=%d strBandwithGroup=%s\n", aParent, aMedium, aControllerName.c_str(), aPort, aDevice, aType, aImplicit, aPassthrough, aTempEject, aNonRotational, aDiscard, aHotPluggable, strBandwidthGroup.c_str()));
if (aType == DeviceType_HardDisk)
AssertReturn(aMedium, E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
AssertReturn(autoInitSpan.isOk(), E_FAIL);
m = new Data();
unconst(m->pMachine) = aParent;
m->bd.allocate();
m->bd->pMedium = aMedium;
m->bd->mData.strBwGroup = strBandwidthGroup;
unconst(m->bd->strControllerName) = aControllerName;
m->bd->mData.lPort = aPort;
m->bd->mData.lDevice = aDevice;
m->bd->mData.deviceType = aType;
m->bd->mData.fPassThrough = aPassthrough;
m->bd->mData.fTempEject = aTempEject;
m->bd->mData.fNonRotational = aNonRotational;
m->bd->mData.fDiscard = aDiscard;
m->bd->fImplicit = aImplicit;
m->bd->mData.fHotPluggable = aHotPluggable;
/* Confirm a successful initialization when it's the case */
autoInitSpan.setSucceeded();
/* Construct a short log name for this attachment. */
i_updateLogName();
LogFlowThisFunc(("LEAVE - %s\n", i_getLogName()));
return S_OK;
}
示例14: setProgress
int GuestDnDResponse::setProgress(unsigned uPercentage,
uint32_t uStatus,
int rcOp /* = VINF_SUCCESS */, const Utf8Str &strMsg /* = "" */)
{
LogFlowFunc(("uStatus=%RU32, uPercentage=%RU32, rcOp=%Rrc, strMsg=%s\n",
uStatus, uPercentage, rcOp, strMsg.c_str()));
int rc = VINF_SUCCESS;
if (!m_progress.isNull())
{
BOOL fCompleted;
HRESULT hr = m_progress->COMGETTER(Completed)(&fCompleted);
AssertComRC(hr);
BOOL fCanceled;
hr = m_progress->COMGETTER(Canceled)(&fCanceled);
AssertComRC(hr);
LogFlowFunc(("Current: fCompleted=%RTbool, fCanceled=%RTbool\n", fCompleted, fCanceled));
if (!fCompleted)
{
switch (uStatus)
{
case DragAndDropSvc::DND_PROGRESS_ERROR:
{
hr = m_progress->i_notifyComplete(VBOX_E_IPRT_ERROR,
COM_IIDOF(IGuest),
m_parent->getComponentName(), strMsg.c_str());
reset();
break;
}
case DragAndDropSvc::DND_PROGRESS_CANCELLED:
{
hr = m_progress->i_notifyComplete(S_OK);
AssertComRC(hr);
reset();
break;
}
case DragAndDropSvc::DND_PROGRESS_RUNNING:
case DragAndDropSvc::DND_PROGRESS_COMPLETE:
{
if (!fCanceled)
{
hr = m_progress->SetCurrentOperationProgress(uPercentage);
AssertComRC(hr);
if ( uStatus == DragAndDropSvc::DND_PROGRESS_COMPLETE
|| uPercentage >= 100)
{
hr = m_progress->i_notifyComplete(S_OK);
AssertComRC(hr);
}
}
break;
}
default:
break;
}
}
hr = m_progress->COMGETTER(Completed)(&fCompleted);
AssertComRC(hr);
hr = m_progress->COMGETTER(Canceled)(&fCanceled);
AssertComRC(hr);
LogFlowFunc(("New: fCompleted=%RTbool, fCanceled=%RTbool\n", fCompleted, fCanceled));
}
LogFlowFuncLeaveRC(rc);
return rc;
}
示例15: taskUpdateGuestAdditions
HRESULT Guest::taskUpdateGuestAdditions(GuestTask *aTask)
{
LogFlowFuncEnter();
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/*
* Do *not* take a write lock here since we don't (and won't)
* touch any class-specific data (of IGuest) here - only the member functions
* which get called here can do that.
*/
HRESULT rc = S_OK;
BOOL fCompleted;
BOOL fCanceled;
try
{
ComObjPtr<Guest> pGuest = aTask->pGuest;
aTask->pProgress->SetCurrentOperationProgress(10);
/*
* Determine guest OS type and the required installer image.
* At the moment only Windows guests are supported.
*/
Utf8Str installerImage;
Bstr osTypeId;
if ( SUCCEEDED(pGuest->COMGETTER(OSTypeId(osTypeId.asOutParam())))
&& !osTypeId.isEmpty())
{
Utf8Str osTypeIdUtf8(osTypeId); /* Needed for .contains(). */
if ( osTypeIdUtf8.contains("Microsoft", Utf8Str::CaseInsensitive)
|| osTypeIdUtf8.contains("Windows", Utf8Str::CaseInsensitive))
{
if (osTypeIdUtf8.contains("64", Utf8Str::CaseInsensitive))
installerImage = "VBOXWINDOWSADDITIONS_AMD64.EXE";
else
installerImage = "VBOXWINDOWSADDITIONS_X86.EXE";
/* Since the installers are located in the root directory,
* no further path processing needs to be done (yet). */
}
else /* Everything else is not supported (yet). */
throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
Guest::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
osTypeIdUtf8.c_str());
}
else
throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
Guest::tr("Could not detected guest OS type/version, please update manually"));
Assert(!installerImage.isEmpty());
/*
* Try to open the .ISO file and locate the specified installer.
*/
RTISOFSFILE iso;
int vrc = RTIsoFsOpen(&iso, aTask->strSource.c_str());
if (RT_FAILURE(vrc))
{
rc = GuestTask::setProgressErrorInfo(VBOX_E_FILE_ERROR, aTask->pProgress,
Guest::tr("Invalid installation medium detected: \"%s\""),
aTask->strSource.c_str());
}
else
{
uint32_t cbOffset;
size_t cbLength;
vrc = RTIsoFsGetFileInfo(&iso, installerImage.c_str(), &cbOffset, &cbLength);
if ( RT_SUCCESS(vrc)
&& cbOffset
&& cbLength)
{
vrc = RTFileSeek(iso.file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
if (RT_FAILURE(vrc))
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Could not seek to setup file on installation medium \"%s\" (%Rrc)"),
aTask->strSource.c_str(), vrc);
}
else
{
switch (vrc)
{
case VERR_FILE_NOT_FOUND:
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("Setup file was not found on installation medium \"%s\""),
aTask->strSource.c_str());
break;
default:
rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
Guest::tr("An unknown error (%Rrc) occured while retrieving information of setup file on installation medium \"%s\""),
vrc, aTask->strSource.c_str());
break;
}
}
/* Specify the ouput path on the guest side. */
Utf8Str strInstallerPath = "%TEMP%\\VBoxWindowsAdditions.exe";
//.........这里部分代码省略.........