Changeset 48757 in vbox for trunk/src/VBox/Main
- Timestamp:
- Sep 28, 2013 10:47:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r48756 r48757 120 120 # include "ExtPackManagerImpl.h" 121 121 #endif 122 123 122 #if defined(RT_OS_DARWIN) 124 125 123 # include "IOKit/IOKitLib.h" 124 #endif 125 126 127 /******************************************************************************* 128 * Internal Functions * 129 *******************************************************************************/ 130 static Utf8Str *GetExtraDataBoth(IVirtualBox *pVirtualBox, IMachine *pMachine, const char *pszName, Utf8Str *pStrValue); 131 132 133 134 #if defined(RT_OS_DARWIN) 126 135 127 136 static int DarwinSmcKey(char *pabKey, uint32_t cbKey) … … 248 257 } 249 258 250 static int getSmcDeviceKey(IMachine *pMachine, BSTR *aKey, bool *pfGetKeyFromRealSMC) 259 /** 260 * @throws HRESULT on extra data retrival error. 261 */ 262 static int getSmcDeviceKey(IVirtualBox *pVirtualBox, IMachine *pMachine, Utf8Str *pStrKey, bool *pfGetKeyFromRealSMC) 251 263 { 252 264 *pfGetKeyFromRealSMC = false; … … 255 267 * The extra data takes precedence (if non-zero). 256 268 */ 257 HRESULT hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey").raw(), 258 aKey); 259 if (FAILED(hrc)) 260 return Global::vboxStatusCodeFromCOM(hrc); 261 if ( SUCCEEDED(hrc) 262 && *aKey 263 && **aKey) 269 GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/SmcDeviceKey", pStrKey); 270 if (pStrKey->isNotEmpty()) 264 271 return VINF_SUCCESS; 265 272 … … 465 472 throw ConfigError("CFGMR3RemoveValue", vrc, pcszName); 466 473 } 474 475 /** 476 * Gets an extra data value, consulting both machine and global extra data. 477 * 478 * @throws HRESULT on failure 479 * @returns pStrValue for the callers convenience. 480 * @param pVirtualBox Pointer to the IVirtualBox interface. 481 * @param pMachine Pointer to the IMachine interface. 482 * @param pszName The value to get. 483 * @param pStrValue Where to return it's value (empty string if not 484 * found). 485 */ 486 static Utf8Str *GetExtraDataBoth(IVirtualBox *pVirtualBox, IMachine *pMachine, const char *pszName, Utf8Str *pStrValue) 487 { 488 pStrValue->setNull(); 489 490 Bstr bstrName(pszName); 491 Bstr bstrValue; 492 HRESULT hrc = pMachine->GetExtraData(bstrName.raw(), bstrValue.asOutParam()); 493 if (FAILED(hrc)) 494 throw hrc; 495 if (bstrValue.isEmpty()) 496 { 497 hrc = pVirtualBox->GetExtraData(bstrName.raw(), bstrValue.asOutParam()); 498 if (FAILED(hrc)) 499 throw hrc; 500 } 501 502 if (bstrValue.isNotEmpty()) 503 *pStrValue = bstrValue; 504 return pStrValue; 505 } 506 507 467 508 /** Helper that finds out the next SATA port used 468 509 */ … … 711 752 int rc; 712 753 HRESULT hrc; 754 Utf8Str strTmp; 713 755 Bstr bstr; 714 756 … … 1259 1301 1260 1302 bool fGetKeyFromRealSMC; 1261 Bstr bstrKey;1262 rc = getSmcDeviceKey( pMachine, bstrKey.asOutParam(), &fGetKeyFromRealSMC);1303 Utf8Str strKey; 1304 rc = getSmcDeviceKey(virtualBox, pMachine, &strKey, &fGetKeyFromRealSMC); 1263 1305 AssertRCReturn(rc, rc); 1264 1306 1265 InsertConfigString(pCfg, "DeviceKey", bstrKey);1307 InsertConfigString(pCfg, "DeviceKey", strKey); 1266 1308 InsertConfigInteger(pCfg, "GetKeyFromRealSMC", fGetKeyFromRealSMC); 1267 1309 } … … 1476 1518 1477 1519 /* Get boot args */ 1478 Bstr bootArgs;1479 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiBootArgs").raw(), bootArgs.asOutParam()); H();1520 Utf8Str bootArgs; 1521 GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiBootArgs", &bootArgs); 1480 1522 1481 1523 /* Get device props */ 1482 Bstr deviceProps;1483 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiDeviceProps").raw(), deviceProps.asOutParam()); H();1524 Utf8Str deviceProps; 1525 GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiDeviceProps", &deviceProps); 1484 1526 1485 1527 /* Get GOP mode settings */ 1486 1528 uint32_t u32GopMode = UINT32_MAX; 1487 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiGopMode").raw(), bstr.asOutParam()); H();1488 if (! bstr.isEmpty())1489 u32GopMode = Utf8Str(bstr).toUInt32();1529 GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiGopMode", &strTmp); 1530 if (!strTmp.isEmpty()) 1531 u32GopMode = strTmp.toUInt32(); 1490 1532 1491 1533 /* UGA mode settings */ 1492 1534 uint32_t u32UgaHorisontal = 0; 1493 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution").raw(), bstr.asOutParam()); H();1494 if (! bstr.isEmpty())1495 u32UgaHorisontal = Utf8Str(bstr).toUInt32();1535 GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaHorizontalResolution", &strTmp); 1536 if (!strTmp.isEmpty()) 1537 u32UgaHorisontal = strTmp.toUInt32(); 1496 1538 1497 1539 uint32_t u32UgaVertical = 0; 1498 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution").raw(), bstr.asOutParam()); H();1499 if (! bstr.isEmpty())1500 u32UgaVertical = Utf8Str(bstr).toUInt32();1540 GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaVerticalResolution", &strTmp); 1541 if (!strTmp.isEmpty()) 1542 u32UgaVertical = strTmp.toUInt32(); 1501 1543 1502 1544 /* … … 2827 2869 // InsertConfig threw something: 2828 2870 return x.m_vrc; 2871 } 2872 catch (HRESULT hrcXcpt) 2873 { 2874 AssertMsgFailedReturn(("hrc=%Rhrc\n", hrcXcpt), VERR_GENERAL_FAILURE); 2829 2875 } 2830 2876
Note:
See TracChangeset
for help on using the changeset viewer.