Changeset 30714 in vbox
- Timestamp:
- Jul 7, 2010 4:20:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 63479
- Location:
- trunk
- Files:
-
- 65 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/SupportErrorInfo.h
r28800 r30714 155 155 } 156 156 157 /** 158 * Returns true if multi-mode is enabled for the current thread (i.e. at 159 * least one MultiResult instance exists on the stack somewhere). 160 * @return 161 */ 162 static bool isMultiEnabled(); 163 157 164 private: 158 165 … … 164 171 static RTTLS sCounter; 165 172 166 friend class SupportErrorInfoBase;167 173 friend class MultiResultRef; 168 174 }; … … 202 208 }; 203 209 204 /**205 * The SupportErrorInfoBase template class provides basic error info support.206 *207 * Basic error info support includes a group of setError() methods to set208 * extended error information on the current thread. This support does not209 * include all necessary implementation details (for example, implementation of210 * the ISupportErrorInfo interface on MS COM) to make the error info support211 * fully functional in a target component. These details are provided by the212 * SupportErrorInfoDerived class.213 *214 * This way, this class is intended to be directly inherited only by215 * intermediate component base classes that will be then inherited by final216 * component classes through the SupportErrorInfoDerived template class. In217 * all other cases, the SupportErrorInfoImpl class should be used as a base for218 * final component classes instead.219 */220 class SupportErrorInfoBase221 {222 static HRESULT setErrorInternal(HRESULT aResultCode,223 const GUID *aIID,224 const char *aComponent,225 const Utf8Str &strText,226 bool aWarning,227 IVirtualBoxErrorInfo *aInfo = NULL);228 229 protected:230 231 /**232 * Returns an interface ID that is to be used in short setError() variants233 * to specify the interface that has defined the error. Must be implemented234 * in subclasses.235 */236 virtual const GUID &mainInterfaceID() const = 0;237 238 /**239 * Returns an component name (in UTF8) that is to be used in short240 * setError() variants to specify the interface that has defined the error.241 * Must be implemented in subclasses.242 */243 virtual const char *componentName() const = 0;244 245 /**246 * Same as #setError (HRESULT, const GUID &, const char *, const char *) but247 * interprets the @a aText argument as a RTPrintf-like format string and the248 * @a aArgs argument as an argument list for this format string.249 */250 static HRESULT setErrorV(HRESULT aResultCode, const GUID &aIID,251 const char *aComponent, const char *aText,252 va_list aArgs)253 {254 return setErrorInternal(aResultCode, &aIID, aComponent,255 Utf8StrFmtVA(aText, aArgs),256 false /* aWarning */);257 }258 259 /**260 * Same as #setWarning (HRESULT, const GUID &, const char *, const char *)261 * but interprets the @a aText argument as a RTPrintf-like format string and262 * the @a aArgs argument as an argument list for this format string.263 */264 static HRESULT setWarningV(HRESULT aResultCode, const GUID &aIID,265 const char *aComponent, const char *aText,266 va_list aArgs)267 {268 return setErrorInternal(aResultCode, &aIID,269 aComponent,270 Utf8StrFmtVA(aText, aArgs),271 true /* aWarning */);272 }273 274 /**275 * Same as #setError (HRESULT, const GUID &, const char *, const char *) but276 * interprets the @a aText argument as a RTPrintf-like format string and277 * takes a variable list of arguments for this format string.278 */279 static HRESULT setError(HRESULT aResultCode,280 const GUID &aIID,281 const char *aComponent,282 const char *aText,283 ...);284 285 /**286 * Same as #setWarning (HRESULT, const GUID &, const char *, const char *)287 * but interprets the @a aText argument as a RTPrintf-like format string and288 * takes a variable list of arguments for this format string.289 */290 static HRESULT setWarning(HRESULT aResultCode, const GUID &aIID,291 const char *aComponent, const char *aText,292 ...);293 294 /**295 * Sets the given error info object on the current thread.296 *297 * Note that In multi-error mode (see MultiResult), the existing error info298 * object (if any) will be preserved by attaching it to the tail of the299 * error chain of the given aInfo object.300 *301 * @param aInfo Error info object to set (must not be NULL).302 */303 static HRESULT setErrorInfo(IVirtualBoxErrorInfo *aInfo)304 {305 AssertReturn (aInfo != NULL, E_FAIL);306 return setErrorInternal(0, NULL, NULL, Utf8Str::Null, false, aInfo);307 }308 309 /**310 * Same as #setError (HRESULT, const GUID &, const char *, const char *,311 * ...) but uses the return value of the mainInterfaceID() method as an @a312 * aIID argument and the return value of the componentName() method as a @a313 * aComponent argument.314 *315 * This method is the most common (and convenient) way to set error316 * information from within a component method. The typical usage pattern is:317 * <code>318 * return setError (E_FAIL, "Terrible Error");319 * </code>320 * or321 * <code>322 * HRESULT rc = setError (E_FAIL, "Terrible Error");323 * ...324 * return rc;325 * </code>326 */327 HRESULT setError(HRESULT aResultCode, const char *aText, ...);328 329 HRESULT setError(HRESULT aResultCode, const Utf8Str &strText);330 331 /**332 * Same as #setWarning (HRESULT, const GUID &, const char *, const char *,333 * ...) but uses the return value of the mainInterfaceID() method as an @a334 * aIID argument and the return value of the componentName() method as a @a335 * aComponent argument.336 *337 * This method is the most common (and convenient) way to set warning338 * information from within a component method. The typical usage pattern is:339 * <code>340 * return setWarning (E_FAIL, "Dangerous warning");341 * </code>342 * or343 * <code>344 * HRESULT rc = setWarning (E_FAIL, "Dangerous warning");345 * ...346 * return rc;347 * </code>348 */349 HRESULT setWarning (HRESULT aResultCode, const char *aText, ...);350 351 /**352 * Same as #setError (HRESULT, const char *, ...) but takes a va_list353 * argument instead of a variable argument list.354 */355 HRESULT setErrorV (HRESULT aResultCode, const char *aText, va_list aArgs)356 {357 return setError (aResultCode, mainInterfaceID(), componentName(),358 aText, aArgs);359 }360 361 /**362 * Same as #setWarning (HRESULT, const char *, ...) but takes a va_list363 * argument instead of a variable argument list.364 */365 HRESULT setWarningV (HRESULT aResultCode, const char *aText, va_list aArgs)366 {367 return setWarning (aResultCode, mainInterfaceID(), componentName(),368 aText, aArgs);369 }370 371 /**372 * Same as #setError (HRESULT, const char *, ...) but allows to specify the373 * interface ID manually.374 */375 HRESULT setError (HRESULT aResultCode, const GUID &aIID,376 const char *aText, ...);377 378 /**379 * Same as #setWarning (HRESULT, const char *, ...) but allows to specify380 * the interface ID manually.381 */382 HRESULT setWarning (HRESULT aResultCode, const GUID &aIID,383 const char *aText, ...);384 };385 386 ////////////////////////////////////////////////////////////////////////////////387 388 /**389 * The SupportErrorInfoDerived template class implements the remaining parts390 * of error info support in addition to SupportErrorInfoBase.391 *392 * These parts include the ISupportErrorInfo implementation on the MS COM393 * platform and implementations of mandatory SupportErrorInfoBase virtual394 * methods.395 *396 * On MS COM, the @a C template argument must declare a COM interface map using397 * BEGIN_COM_MAP / END_COM_MAP macros and this map must contain a398 * COM_INTERFACE_ENTRY(ISupportErrorInfo) definition. All interface entries that399 * follow it will be considered to support IErrorInfo, i.e. the400 * InterfaceSupportsErrorInfo() implementation will return S_OK for the401 * corresponding IIDs.402 *403 * On all platforms, the @a C template argument must be a subclass of404 * SupportErrorInfoBase and also define the following method: <tt>public static405 * const char *ComponentName()</tt> that will be used as a value returned by the406 * SupportErrorInfoBase::componentName() implementation.407 *408 * If SupportErrorInfoBase is used as a base for an intermediate component base409 * class FooBase then the final component FooFinal that inherits FooBase should410 * use this template class as follows:411 * <code>412 * class FooFinal : public SupportErrorInfoDerived <FooBase, FooFinal, IFoo>413 * {414 * ...415 * };416 * </code>417 *418 * Note that if you don not use intermediate component base classes, you should419 * use the SupportErrorInfoImpl class as a base for your component instead.420 *421 * @param B Intermediate component base derived from SupportErrorInfoBase.422 * @param C Component class that implements one or more COM interfaces.423 * @param I Default interface for the component (for short #setError()424 * versions).425 */426 template <class B, class C, class I>427 class ATL_NO_VTABLE SupportErrorInfoDerived : public B428 #if !defined (VBOX_WITH_XPCOM)429 , public ISupportErrorInfo430 #endif431 {432 public:433 434 #if !defined (VBOX_WITH_XPCOM)435 STDMETHOD(InterfaceSupportsErrorInfo) (REFIID aIID)436 {437 const _ATL_INTMAP_ENTRY* pEntries = C::_GetEntries();438 Assert (pEntries);439 if (!pEntries)440 return S_FALSE;441 442 BOOL bSupports = FALSE;443 BOOL bISupportErrorInfoFound = FALSE;444 445 while (pEntries->pFunc != NULL && !bSupports)446 {447 if (!bISupportErrorInfoFound)448 {449 /* skip the COM map entries until ISupportErrorInfo is found */450 bISupportErrorInfoFound =451 InlineIsEqualGUID (*(pEntries->piid), IID_ISupportErrorInfo);452 }453 else454 {455 /* look for the requested interface in the rest of the com map */456 bSupports = InlineIsEqualGUID (*(pEntries->piid), aIID);457 }458 pEntries++;459 }460 461 Assert (bISupportErrorInfoFound);462 463 return bSupports ? S_OK : S_FALSE;464 }465 #endif /* !defined (VBOX_WITH_XPCOM) */466 467 protected:468 469 virtual const GUID &mainInterfaceID() const { return COM_IIDOF (I); }470 471 virtual const char *componentName() const { return C::ComponentName(); }472 };473 474 ////////////////////////////////////////////////////////////////////////////////475 476 /**477 * The SupportErrorInfoImpl template class provides complete error info support478 * for COM component classes.479 *480 * Complete error info support includes what both SupportErrorInfoBase and481 * SupportErrorInfoDerived provide, e.g. a variety of setError() methods to482 * set extended error information from within a component's method483 * implementation and all necessary additional interface implementations (see484 * descriptions of these classes for details).485 *486 * To add error info support to a Foo component that implements a IFoo487 * interface, use the following pattern:488 * <code>489 * class Foo : public SupportErrorInfoImpl <Foo, IFoo>490 * {491 * public:492 *493 * ...494 *495 * static const char *ComponentName() const { return "Foo"; }496 * };497 * </code>498 *499 * Note that your component class (the @a C template argument) must provide the500 * ComponentName() implementation as shown above.501 *502 * @param C Component class that implements one or more COM interfaces.503 * @param I Default interface for the component (for short #setError()504 * versions).505 */506 template <class C, class I>507 class ATL_NO_VTABLE SupportErrorInfoImpl508 : public SupportErrorInfoDerived <SupportErrorInfoBase, C, I>509 {510 };511 210 512 211 } /* namespace com */ -
trunk/include/VBox/com/VirtualBoxErrorInfo.h
r28800 r30714 144 144 145 145 // IVirtualBoxErrorInfo properties 146 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_ResultCode_TO_OBJ 147 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_InterfaceID_TO_OBJ 148 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Component_TO_OBJ 149 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Text_TO_OBJ 146 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_ResultCode_TO_OBJ(mReal) 147 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_InterfaceID_TO_OBJ(mReal) 148 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Component_TO_OBJ(mReal) 149 COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Text_TO_OBJ(mReal) 150 150 STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext); 151 151 -
trunk/include/VBox/com/defs.h
r30681 r30714 225 225 * @param i interface class 226 226 */ 227 #define COM_IIDOF(I) _ATL_IIDOF 227 #define COM_IIDOF(I) _ATL_IIDOF(I) 228 228 229 229 #else /* defined (RT_OS_WINDOWS) */ … … 349 349 #define STDMETHODIMP NS_IMETHODIMP 350 350 351 #define COM_IIDOF(I) NS_GET_IID 351 #define COM_IIDOF(I) NS_GET_IID(I) 352 352 353 353 /* A few very simple ATL emulator classes to provide -
trunk/src/VBox/Frontends/VBoxBFE/VirtualBoxBase.h
r28800 r30714 277 277 cls::cls () {}; cls::~cls () {}; 278 278 279 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls )279 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls, iface) 280 280 281 281 //////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/ApplianceImpl.cpp
r30681 r30714 538 538 * @return 539 539 */ 540 bool Appliance::isApplianceIdle() const540 bool Appliance::isApplianceIdle() 541 541 { 542 542 if (m->state == Data::ApplianceImporting) 543 setError(VBOX_E_INVALID_OBJECT_STATE, "The appliance is busy importing files");543 setError(VBOX_E_INVALID_OBJECT_STATE, tr("The appliance is busy importing files")); 544 544 else if (m->state == Data::ApplianceExporting) 545 setError(VBOX_E_INVALID_OBJECT_STATE, "The appliance is busy exporting files");545 setError(VBOX_E_INVALID_OBJECT_STATE, tr("The appliance is busy exporting files")); 546 546 else 547 547 return true; … … 864 864 } 865 865 866 void Appliance::parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const866 void Appliance::parseBucket(Utf8Str &aPath, Utf8Str &aBucket) 867 867 { 868 868 /* Buckets are S3 specific. So parse the bucket out of the file path */ -
trunk/src/VBox/Main/ConsoleImpl.cpp
r30629 r30714 1269 1269 if (RT_FAILURE(vrc)) 1270 1270 rc = setError(VBOX_E_FILE_ERROR, 1271 tr("The saved state file '%ls' is invalid (%Rrc). Delete the saved state and try again"),1272 savedStateFile.raw(), vrc);1271 tr("The saved state file '%ls' is invalid (%Rrc). Delete the saved state and try again"), 1272 savedStateFile.raw(), vrc); 1273 1273 1274 1274 mSavedStateDataLoaded = true; … … 1516 1516 if (VERR_BUFFER_OVERFLOW == vrc) 1517 1517 return setError(E_UNEXPECTED, 1518 tr("Temporary failure due to guest activity, please retry"));1518 tr("Temporary failure due to guest activity, please retry")); 1519 1519 1520 1520 /* … … 1871 1871 /** @todo r=bird: This should be allowed on paused VMs as well. Later. */ 1872 1872 ) 1873 return setError(VBOX_E_INVALID_VM_STATE, 1874 tr("Invalid machine state: %s"), 1875 Global::stringifyMachineState(mMachineState)); 1873 return setInvalidMachineStateError(); 1876 1874 1877 1875 /* protect mpVM */ … … 1886 1884 HRESULT rc = RT_SUCCESS(vrc) ? S_OK : 1887 1885 setError(VBOX_E_VM_ERROR, 1888 tr("Could not reset the machine (%Rrc)"),1889 vrc);1886 tr("Could not reset the machine (%Rrc)"), 1887 vrc); 1890 1888 1891 1889 LogFlowThisFunc(("mMachineState=%d, rc=%08X\n", mMachineState, rc)); … … 1922 1920 && mMachineState != MachineState_LiveSnapshotting 1923 1921 ) 1924 return setError(VBOX_E_INVALID_VM_STATE, 1925 tr("Invalid machine state: %s"), 1926 Global::stringifyMachineState(mMachineState)); 1922 return setInvalidMachineStateError(); 1927 1923 1928 1924 /* protect mpVM */ … … 2077 2073 /** @todo r=bird: This should be allowed on paused VMs as well. Later. */ 2078 2074 ) 2079 return setError(VBOX_E_INVALID_VM_STATE, 2080 tr("Invalid machine state: %s"), 2081 Global::stringifyMachineState(mMachineState)); 2075 return setInvalidMachineStateError(); 2082 2076 2083 2077 /* protect mpVM */ … … 2118 2112 rc = RT_SUCCESS(vrc) ? S_OK : 2119 2113 setError(VBOX_E_VM_ERROR, 2120 tr("Could not add CPU to the machine (%Rrc)"),2121 vrc);2114 tr("Could not add CPU to the machine (%Rrc)"), 2115 vrc); 2122 2116 2123 2117 if (RT_SUCCESS(vrc)) … … 2160 2154 2161 2155 default: 2162 return setError(VBOX_E_INVALID_VM_STATE, 2163 tr("Invalid machine state: %s"), 2164 Global::stringifyMachineState(mMachineState)); 2156 return setInvalidMachineStateError(); 2165 2157 } 2166 2158 … … 2196 2188 if (mMachineState != MachineState_Paused) 2197 2189 return setError(VBOX_E_INVALID_VM_STATE, 2198 tr("Cannot resume the machine as it is not paused (machine state: %s)"),2199 Global::stringifyMachineState(mMachineState));2190 tr("Cannot resume the machine as it is not paused (machine state: %s)"), 2191 Global::stringifyMachineState(mMachineState)); 2200 2192 2201 2193 /* protect mpVM */ … … 2216 2208 HRESULT rc = RT_SUCCESS(vrc) ? S_OK : 2217 2209 setError(VBOX_E_VM_ERROR, 2218 tr("Could not resume the machine execution (%Rrc)"),2219 vrc);2210 tr("Could not resume the machine execution (%Rrc)"), 2211 vrc); 2220 2212 2221 2213 LogFlowThisFunc(("rc=%08X\n", rc)); … … 2237 2229 && mMachineState != MachineState_LiveSnapshotting 2238 2230 ) 2239 return setError(VBOX_E_INVALID_VM_STATE, 2240 tr("Invalid machine state: %s"), 2241 Global::stringifyMachineState(mMachineState)); 2231 return setInvalidMachineStateError(); 2242 2232 2243 2233 /* protect mpVM */ … … 2256 2246 HRESULT rc = RT_SUCCESS(vrc) ? S_OK : 2257 2247 setError(VBOX_E_PDM_ERROR, 2258 tr("Controlled power off failed (%Rrc)"),2259 vrc);2248 tr("Controlled power off failed (%Rrc)"), 2249 vrc); 2260 2250 2261 2251 LogFlowThisFunc(("rc=%08X\n", rc)); … … 2280 2270 && mMachineState != MachineState_LiveSnapshotting 2281 2271 ) 2282 return setError(VBOX_E_INVALID_VM_STATE, 2283 tr("Invalid machine state: %s"), 2284 Global::stringifyMachineState(mMachineState)); 2272 return setInvalidMachineStateError(); 2285 2273 2286 2274 /* protect mpVM */ … … 2360 2348 2361 2349 if (mMachineState != MachineState_Running) /** @todo Live Migration: ??? */ 2362 return setError(VBOX_E_INVALID_VM_STATE, 2363 tr("Invalid machine state: %s)"), 2364 Global::stringifyMachineState(mMachineState)); 2350 return setInvalidMachineStateError(); 2365 2351 2366 2352 /* protect mpVM */ … … 3203 3189 ///////////////////////////////////////////////////////////////////////////// 3204 3190 3191 /*static*/ 3192 HRESULT Console::setErrorStatic(HRESULT aResultCode, const char *pcsz, ...) 3193 { 3194 va_list args; 3195 va_start(args, pcsz); 3196 HRESULT rc = setErrorInternal(aResultCode, 3197 getStaticClassIID(), 3198 getStaticComponentName(), 3199 Utf8StrFmtVA(pcsz, args), 3200 false /* aWarning */, 3201 true /* aLogIt */); 3202 va_end(args); 3203 return rc; 3204 } 3205 3206 HRESULT Console::setAuthLibraryError(const char *filename, int rc) 3207 { 3208 return setError(E_FAIL, tr("Could not load the external authentication library '%s' (%Rrc)"), filename, rc); 3209 } 3210 3211 HRESULT Console::setInvalidMachineStateError() 3212 { 3213 return setError(VBOX_E_INVALID_VM_STATE, 3214 tr("Invalid machine state: %s"), 3215 Global::stringifyMachineState(mMachineState)); 3216 } 3217 3218 3205 3219 /** 3206 3220 * @copydoc VirtualBox::handleUnexpectedExceptions … … 3216 3230 catch (const std::exception &err) 3217 3231 { 3218 return setError(E_FAIL, tr("Unexpected exception: %s [%s]\n%s[%d] (%s)"), 3219 err.what(), typeid(err).name(), 3220 pszFile, iLine, pszFunction); 3232 return setErrorStatic(E_FAIL, 3233 tr("Unexpected exception: %s [%s]\n%s[%d] (%s)"), 3234 err.what(), typeid(err).name(), 3235 pszFile, iLine, pszFunction); 3221 3236 } 3222 3237 catch (...) 3223 3238 { 3224 return setError(E_FAIL, tr("Unknown exception\n%s[%d] (%s)"), 3225 pszFile, iLine, pszFunction); 3239 return setErrorStatic(E_FAIL, 3240 tr("Unknown exception\n%s[%d] (%s)"), 3241 pszFile, iLine, pszFunction); 3226 3242 } 3227 3243 … … 3470 3486 3471 3487 case VMSTATE_RUNNING_LS: 3472 return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot change drive during live migration")); 3488 return setErrorInternal(VBOX_E_INVALID_VM_STATE, 3489 COM_IIDOF(IConsole), 3490 getStaticComponentName(), 3491 Utf8Str(tr("Cannot change drive during live migration")), 3492 false /*aWarning*/, 3493 true /*aLogIt*/); 3473 3494 3474 3495 default: … … 4551 4572 4552 4573 default: 4553 return setError(VBOX_E_INVALID_VM_STATE, 4554 tr("Invalid machine state: %s"), 4555 Global::stringifyMachineState(mMachineState)); 4574 return setInvalidMachineStateError(); 4556 4575 } 4557 4576 … … 7475 7494 LogRel(("Failed to launch VRDP server (%Rrc), error message: '%s'\n", 7476 7495 vrc, errMsg.raw())); 7477 throw setError (E_FAIL, errMsg.c_str());7496 throw setErrorStatic(E_FAIL, errMsg.c_str()); 7478 7497 } 7479 7498 … … 7677 7696 /* Set the error message as the COM error. 7678 7697 * Progress::notifyComplete() will pick it up later. */ 7679 throw setError (E_FAIL, task->mErrorMsg.c_str());7698 throw setErrorStatic(E_FAIL, task->mErrorMsg.c_str()); 7680 7699 } 7681 7700 } … … 7912 7931 alock.enter(); 7913 7932 if (RT_FAILURE(vrc)) 7914 throw setError (E_FAIL,7915 tr("Failed to save the machine state to '%s' (%Rrc)"),7916 strSavedStateFile.c_str(), vrc);7933 throw setErrorStatic(E_FAIL, 7934 tr("Failed to save the machine state to '%s' (%Rrc)"), 7935 strSavedStateFile.c_str(), vrc); 7917 7936 7918 7937 pTask->mProgress->setCancelCallback(NULL, NULL); 7919 7938 if (!pTask->mProgress->notifyPointOfNoReturn()) 7920 throw setError (E_FAIL, tr("Cancelled"));7939 throw setErrorStatic(E_FAIL, tr("Cancelled")); 7921 7940 that->mptrCancelableProgress.setNull(); 7922 7941 … … 7992 8011 &rc); 7993 8012 if (RT_FAILURE(vrc)) 7994 throw setError (E_FAIL, Console::tr("%Rrc"), vrc);8013 throw setErrorStatic(E_FAIL, Console::tr("%Rrc"), vrc); 7995 8014 if (FAILED(rc)) 7996 8015 throw rc; … … 8050 8069 if (RT_FAILURE(vrc)) 8051 8070 { 8052 rc = setError (VBOX_E_VM_ERROR, tr("Could not resume the machine execution (%Rrc)"), vrc);8071 rc = setErrorStatic(VBOX_E_VM_ERROR, tr("Could not resume the machine execution (%Rrc)"), vrc); 8053 8072 pTask->mProgress->notifyComplete(rc); 8054 8073 if (that->mMachineState == MachineState_Saving) … … 8210 8229 task->mProgress->notifyComplete(rc, 8211 8230 COM_IIDOF(IConsole), 8212 (CBSTR)Console::getComponentName(),8231 Console::getStaticComponentName(), 8213 8232 errMsg.c_str()); 8214 8233 else -
trunk/src/VBox/Main/ConsoleVRDPServer.cpp
r30681 r30714 1513 1513 if (RT_FAILURE(rc)) 1514 1514 { 1515 mConsole-> reportAuthLibraryError(filename.raw(), rc);1515 mConsole->setAuthLibraryError(filename.raw(), rc); 1516 1516 1517 1517 mpfnAuthEntry = NULL; -
trunk/src/VBox/Main/EventImpl.cpp
r30706 r30714 66 66 { 67 67 Data() 68 : 69 mType(VBoxEventType_Invalid), 70 mWaitEvent(NIL_RTSEMEVENT), 71 mWaitable(FALSE), 72 mProcessed(FALSE) 68 : mType(VBoxEventType_Invalid), 69 mWaitEvent(NIL_RTSEMEVENT), 70 mWaitable(FALSE), 71 mProcessed(FALSE) 73 72 {} 73 74 74 VBoxEventType_T mType; 75 75 RTSEMEVENT mWaitEvent; … … 95 95 } 96 96 97 98 97 HRESULT VBoxEvent::init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable) 99 98 { … … 113 112 if (aWaitable) 114 113 { 115 int vrc = ::RTSemEventCreate 114 int vrc = ::RTSemEventCreate(&m->mWaitEvent); 116 115 117 116 if (RT_FAILURE(vrc)) … … 915 914 class ATL_NO_VTABLE PassiveEventListener : 916 915 public VirtualBoxBase, 917 public VirtualBoxSupportErrorInfoImpl<PassiveEventListener, IEventListener>,918 916 public VirtualBoxSupportTranslation<PassiveEventListener>, 919 917 VBOX_SCRIPTABLE_IMPL(IEventListener) … … 921 919 public: 922 920 923 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PassiveEventListener )921 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PassiveEventListener, IEventListener) 924 922 925 923 DECLARE_NOT_AGGREGATABLE(PassiveEventListener) … … 951 949 E_FAIL); 952 950 } 953 // for VirtualBoxSupportErrorInfoImpl954 static const wchar_t *getComponentName() { return L"PassiveEventListener"; }955 951 }; 956 952 -
trunk/src/VBox/Main/GuestImpl.cpp
r30662 r30714 650 650 || fCancelled) /* If cancelled we have to report E_FAIL! */ 651 651 { 652 HRESULT hr2 = it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, COM_IIDOF(IGuest), 653 (CBSTR)Guest::getComponentName(), errMsg.c_str()); 652 HRESULT hr2 = it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, 653 COM_IIDOF(IGuest), 654 Guest::getStaticComponentName(), 655 "%s", errMsg.c_str()); 654 656 AssertComRC(hr2); 655 657 LogFlowFunc(("Process (context ID=%u, status=%u) reported error: %s\n", … … 705 707 if (SUCCEEDED(it->second.pProgress->COMGETTER(Canceled)(&fCancelled)) && fCancelled) 706 708 { 707 it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, COM_IIDOF(IGuest), 708 (CBSTR)Guest::getComponentName(), Guest::tr("The output operation was cancelled")); 709 it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, 710 COM_IIDOF(IGuest), 711 Guest::getStaticComponentName(), 712 Guest::tr("The output operation was cancelled")); 709 713 } 710 714 else … … 783 787 * progress object to become signalled. 784 788 */ 785 it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, COM_IIDOF(IGuest), 786 (CBSTR)Guest::getComponentName(), Guest::tr("The operation was cancelled because client is shutting down")); 789 it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR, 790 COM_IIDOF(IGuest), 791 Guest::getStaticComponentName(), 792 Guest::tr("The operation was cancelled because client is shutting down")); 787 793 } 788 794 /* -
trunk/src/VBox/Main/HostImpl.cpp
r30377 r30714 227 227 m->pUSBProxyService = new USBProxyServiceLinux(this); 228 228 # elif defined (RT_OS_OS2) 229 m->pUSBProxyService = new USBProxyServiceOs2 229 m->pUSBProxyService = new USBProxyServiceOs2(this); 230 230 # elif defined (RT_OS_SOLARIS) 231 231 m->pUSBProxyService = new USBProxyServiceSolaris(this); … … 1395 1395 } 1396 1396 1397 return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr (1398 "Could not find a USB device with address '%ls'"),1399 aAddress);1397 return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND, 1398 tr("Could not find a USB device with address '%ls'"), 1399 aAddress); 1400 1400 1401 1401 #else /* !VBOX_WITH_USB */ … … 2302 2302 2303 2303 if (m->pUSBProxyService->getLastError() == VERR_FILE_NOT_FOUND) 2304 return setWarning (E_FAIL, 2305 tr ("Could not load the Host USB Proxy Service (%Rrc). " 2306 "The service might not be installed on the host computer"), 2307 m->pUSBProxyService->getLastError()); 2304 return setWarning(E_FAIL, 2305 tr("Could not load the Host USB Proxy Service (%Rrc). The service might not be installed on the host computer"), 2306 m->pUSBProxyService->getLastError()); 2308 2307 if (m->pUSBProxyService->getLastError() == VINF_SUCCESS) 2309 2308 #ifdef RT_OS_LINUX -
trunk/src/VBox/Main/MachineImpl.cpp
r30632 r30714 626 626 HRESULT Machine::registeredInit() 627 627 { 628 AssertReturn(getClassID() == clsidMachine, E_FAIL); 628 AssertReturn(!isSessionMachine(), E_FAIL); 629 AssertReturn(!isSnapshotMachine(), E_FAIL); 629 630 AssertReturn(!mData->mUuid.isEmpty(), E_FAIL); 630 631 AssertReturn(!mData->mAccessible, E_FAIL); … … 726 727 return; 727 728 728 Assert(getClassID() == clsidMachine); 729 Assert(!isSnapshotMachine()); 730 Assert(!isSessionMachine()); 729 731 Assert(!!mData); 730 732 … … 881 883 errorInfo->init(mData->mAccessError.getResultCode(), 882 884 mData->mAccessError.getInterfaceID(), 883 mData->mAccessError.getComponent(),884 mData->mAccessError.getText());885 Utf8Str(mData->mAccessError.getComponent()).c_str(), 886 Utf8Str(mData->mAccessError.getText())); 885 887 rc = errorInfo.queryInterfaceTo(aAccessError); 886 888 } … … 2422 2424 if ( aEnabled 2423 2425 && mData->mRegistered 2424 && ( getClassID() != clsidSessionMachine2426 && ( !isSessionMachine() 2425 2427 || ( mData->mMachineState != MachineState_PoweredOff 2426 2428 && mData->mMachineState != MachineState_Teleported … … 2561 2563 if ( aEnabled 2562 2564 && mData->mRegistered 2563 && ( getClassID() != clsidSessionMachine2565 && ( !isSessionMachine() 2564 2566 || ( mData->mMachineState != MachineState_PoweredOff 2565 2567 && mData->mMachineState != MachineState_Teleported … … 3641 3643 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3642 3644 3643 if ( getClassID() == clsidSnapshotMachine)3645 if (isSnapshotMachine()) 3644 3646 { 3645 3647 HRESULT rc = checkStateDependency(MutableStateDep); … … 6162 6164 { 6163 6165 if ( mData->mRegistered 6164 && ( getClassID() != clsidSessionMachine/** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */6166 && ( !isSessionMachine() /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */ 6165 6167 || ( mData->mMachineState != MachineState_Paused 6166 6168 && mData->mMachineState != MachineState_Running … … 6179 6181 { 6180 6182 if ( mData->mRegistered 6181 && ( getClassID() != clsidSessionMachine/** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */6183 && ( !isSessionMachine() /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */ 6182 6184 || ( mData->mMachineState != MachineState_Paused 6183 6185 && mData->mMachineState != MachineState_Running … … 6352 6354 * disk attachments will already be uninitialized and deleted, so this 6353 6355 * code will not affect them. */ 6354 VBoxClsID clsid = getClassID();6355 6356 if ( !!mMediaData 6356 && ( clsid == clsidMachine || clsid == clsidSnapshotMachine)6357 && (!isSessionMachine()) 6357 6358 ) 6358 6359 { … … 6369 6370 } 6370 6371 6371 if ( getClassID() == clsidMachine)6372 if (!isSessionMachine() && !isSnapshotMachine()) 6372 6373 { 6373 6374 // clean up the snapshots list (Snapshot::uninit() will handle the snapshot's children recursively) … … 6404 6405 Machine* Machine::getMachine() 6405 6406 { 6406 if ( getClassID() == clsidSessionMachine)6407 if (isSessionMachine()) 6407 6408 return (Machine*)mPeer; 6408 6409 return this; … … 6653 6654 Snapshot *aParentSnapshot) 6654 6655 { 6655 AssertReturn(getClassID() == clsidMachine, E_FAIL); 6656 AssertReturn(!isSnapshotMachine(), E_FAIL); 6657 AssertReturn(!isSessionMachine(), E_FAIL); 6656 6658 6657 6659 HRESULT rc = S_OK; … … 6724 6726 HRESULT Machine::loadHardware(const settings::Hardware &data) 6725 6727 { 6726 AssertReturn( getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL);6728 AssertReturn(!isSessionMachine(), E_FAIL); 6727 6729 6728 6730 HRESULT rc = S_OK; … … 6931 6933 const Guid *aSnapshotId /* = NULL */) 6932 6934 { 6933 AssertReturn( getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL);6935 AssertReturn(!isSessionMachine(), E_FAIL); 6934 6936 6935 6937 HRESULT rc = S_OK; … … 7000 7002 const Guid *aSnapshotId /*= NULL*/) 7001 7003 { 7002 AssertReturn( (getClassID() == clsidMachine && aSnapshotId == NULL)7003 || (getClassID() == clsidSnapshotMachine && aSnapshotId != NULL),7004 E_FAIL);7005 7006 7004 HRESULT rc = S_OK; 7007 7005 … … 7096 7094 if (FAILED(rc)) 7097 7095 { 7098 VBoxClsID clsid = getClassID(); 7099 if (clsid == clsidSnapshotMachine) 7096 if (isSnapshotMachine()) 7100 7097 { 7101 7098 // wrap another error message around the "cannot find hard disk" set by findHardDisk … … 7115 7112 if (medium->getType() == MediumType_Immutable) 7116 7113 { 7117 if ( getClassID() == clsidSnapshotMachine)7114 if (isSnapshotMachine()) 7118 7115 return setError(E_FAIL, 7119 7116 tr("Immutable hard disk '%s' with UUID {%RTuuid} cannot be directly attached to snapshot with UUID {%RTuuid} " … … 7133 7130 } 7134 7131 7135 if ( getClassID() != clsidSnapshotMachine7132 if ( !isSnapshotMachine() 7136 7133 && medium->getChildren().size() != 0 7137 7134 ) … … 7183 7180 if (!medium.isNull()) 7184 7181 { 7185 if ( getClassID() == clsidSnapshotMachine)7182 if (isSnapshotMachine()) 7186 7183 rc = medium->attachTo(mData->mUuid, *aSnapshotId); 7187 7184 else … … 7565 7562 ensureNoStateDependencies(); 7566 7563 7567 AssertReturn( getClassID() == clsidMachine 7568 || getClassID() == clsidSessionMachine, 7564 AssertReturn(!isSnapshotMachine(), 7569 7565 E_FAIL); 7570 7566 … … 7655 7651 * to the client process that creates them) and thus don't need to 7656 7652 * inform callbacks. */ 7657 if ( getClassID() == clsidSessionMachine)7653 if (isSessionMachine()) 7658 7654 mParent->onMachineDataChange(mData->mUuid); 7659 7655 } … … 8397 8393 if (FAILED(rc)) 8398 8394 { 8399 MultiResult Ref mrc(rc);8395 MultiResult mrc = rc; 8400 8396 8401 8397 mrc = deleteImplicitDiffs(pfNeedsSaveSettings); … … 8744 8740 mMediaData.commit(); 8745 8741 8746 if ( getClassID() == clsidSessionMachine)8742 if (isSessionMachine()) 8747 8743 { 8748 8744 /* attach new data to the primary machine and reshare it */ … … 9095 9091 } 9096 9092 9097 if ( getClassID() == clsidSessionMachine)9093 if (isSessionMachine()) 9098 9094 { 9099 9095 /* attach new data to the primary machine and reshare it */ … … 9120 9116 void Machine::copyFrom(Machine *aThat) 9121 9117 { 9122 AssertReturnVoid( getClassID() == clsidMachine || getClassID() == clsidSessionMachine);9123 AssertReturnVoid(aThat-> getClassID() == clsidSnapshotMachine);9118 AssertReturnVoid(!isSnapshotMachine()); 9119 AssertReturnVoid(aThat->isSnapshotMachine()); 9124 9120 9125 9121 AssertReturnVoid(!Global::IsOnline(mData->mMachineState)); -
trunk/src/VBox/Main/MediumImpl.cpp
r30681 r30714 865 865 { 866 866 Assert(!m->strLastAccessError.isEmpty()); 867 rc = setError(E_FAIL, m->strLastAccessError.c_str());867 rc = setError(E_FAIL, "%s", m->strLastAccessError.c_str()); 868 868 } 869 869 else -
trunk/src/VBox/Main/ProgressImpl.cpp
r30681 r30714 104 104 * @return COM result indicator. 105 105 */ 106 HRESULT ProgressBase::protectedInit 106 HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan, 107 107 #if !defined (VBOX_COM_INPROC) 108 VirtualBox *aParent,108 VirtualBox *aParent, 109 109 #endif 110 IUnknown *aInitiator, 111 CBSTR aDescription, OUT_GUID aId /* = NULL */) 110 IUnknown *aInitiator, 111 CBSTR aDescription, 112 OUT_GUID aId /* = NULL */) 112 113 { 113 114 /* Guarantees subclasses call this method at the proper time */ … … 532 533 // public methods only for internal purposes 533 534 //////////////////////////////////////////////////////////////////////////////// 534 535 /**536 * Sets the error info stored in the given progress object as the error info on537 * the current thread.538 *539 * This method is useful if some other COM method uses IProgress to wait for540 * something and then wants to return a failed result of the operation it was541 * waiting for as its own result retaining the extended error info.542 *543 * If the operation tracked by this progress object is completed successfully544 * and returned S_OK, this method does nothing but returns S_OK. Otherwise, the545 * failed warning or error result code specified at progress completion is546 * returned and the extended error info object (if any) is set on the current547 * thread.548 *549 * Note that the given progress object must be completed, otherwise this method550 * will assert and fail.551 */552 /* static */553 HRESULT ProgressBase::setErrorInfoOnThread (IProgress *aProgress)554 {555 AssertReturn(aProgress != NULL, E_INVALIDARG);556 557 LONG iRc;558 HRESULT rc = aProgress->COMGETTER(ResultCode) (&iRc);559 AssertComRCReturnRC(rc);560 HRESULT resultCode = iRc;561 562 if (resultCode == S_OK)563 return resultCode;564 565 ComPtr<IVirtualBoxErrorInfo> errorInfo;566 rc = aProgress->COMGETTER(ErrorInfo) (errorInfo.asOutParam());567 AssertComRCReturnRC(rc);568 569 if (!errorInfo.isNull())570 setErrorInfo (errorInfo);571 572 return resultCode;573 }574 535 575 536 /** … … 1154 1115 HRESULT Progress::notifyComplete(HRESULT aResultCode, 1155 1116 const GUID &aIID, 1156 const Bstr &aComponent,1117 const char *pcszComponent, 1157 1118 const char *aText, 1158 1119 ...) … … 1160 1121 va_list va; 1161 1122 va_start(va, aText); 1162 HRESULT hrc = notifyCompleteV(aResultCode, aIID, aComponent, aText, va);1123 HRESULT hrc = notifyCompleteV(aResultCode, aIID, pcszComponent, aText, va); 1163 1124 va_end(va); 1164 1125 return hrc; … … 1180 1141 HRESULT Progress::notifyCompleteV(HRESULT aResultCode, 1181 1142 const GUID &aIID, 1182 const Bstr &aComponent,1143 const char *pcszComponent, 1183 1144 const char *aText, 1184 1145 va_list va) … … 1206 1167 if (SUCCEEDED(rc)) 1207 1168 { 1208 errorInfo->init(aResultCode, aIID, aComponent, Bstr(text));1169 errorInfo->init(aResultCode, aIID, pcszComponent, text); 1209 1170 errorInfo.queryInterfaceTo(mErrorInfo.asOutParam()); 1210 1171 } -
trunk/src/VBox/Main/ProgressProxyImpl.cpp
r30632 r30714 164 164 HRESULT ProgressProxy::notifyComplete(HRESULT aResultCode, 165 165 const GUID &aIID, 166 const Bstr &aComponent,166 const char *pcszComponent, 167 167 const char *aText, 168 168 ...) … … 176 176 va_list va; 177 177 va_start(va, aText); 178 hrc = Progress::notifyCompleteV(aResultCode, aIID, aComponent, aText, va);178 hrc = Progress::notifyCompleteV(aResultCode, aIID, pcszComponent, aText, va); 179 179 va_end(va); 180 180 } … … 372 372 Utf8Str strText(bstrText); 373 373 LogFlowThisFunc(("Got ErrorInfo(%s); hrcResult=%Rhrc\n", strText.c_str(), hrcResult)); 374 Progress::notifyComplete((HRESULT)hrcResult, Guid(bstrIID), bstrComponent, "%s", strText.c_str()); 374 Progress::notifyComplete((HRESULT)hrcResult, 375 Guid(bstrIID), 376 Utf8Str(bstrComponent).c_str(), 377 "%s", strText.c_str()); 375 378 } 376 379 else 377 380 { 378 381 LogFlowThisFunc(("ErrorInfo failed with hrc=%Rhrc; hrcResult=%Rhrc\n", hrc, hrcResult)); 379 Progress::notifyComplete((HRESULT)hrcResult, COM_IIDOF(IProgress), Bstr("ProgressProxy"), 382 Progress::notifyComplete((HRESULT)hrcResult, 383 COM_IIDOF(IProgress), 384 "ProgressProxy", 380 385 tr("No error info")); 381 386 } -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r30111 r30714 228 228 { 229 229 /* inform AutoUninitSpan ctor there are no more callers */ 230 RTSemEventSignal 230 RTSemEventSignal(mZeroCallersSem); 231 231 } 232 232 } … … 236 236 if (aState) 237 237 *aState = mState; 238 239 if (FAILED(rc)) 240 { 241 if (mState == VirtualBoxBase::Limited) 242 rc = setError(rc, "The object functionality is limited"); 243 else 244 rc = setError(rc, "The object is not ready"); 245 } 238 246 239 247 return rc; … … 284 292 AssertMsgFailed (("mState = %d!", mState)); 285 293 } 286 287 ////////////////////////////////////////////////////////////////////////////////288 //289 // AutoInitSpan methods290 //291 ////////////////////////////////////////////////////////////////////////////////292 293 /**294 * Creates a smart initialization span object that places the object to295 * InInit state.296 *297 * Please see the AutoInitSpan class description for more info.298 *299 * @param aObj |this| pointer of the managed VirtualBoxBase object whose300 * init() method is being called.301 * @param aResult Default initialization result.302 */303 AutoInitSpan::AutoInitSpan(VirtualBoxBase *aObj,304 Result aResult /* = Failed */)305 : mObj(aObj),306 mResult(aResult),307 mOk(false)308 {309 Assert(aObj);310 311 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);312 313 mOk = mObj->mState == VirtualBoxBase::NotReady;314 AssertReturnVoid (mOk);315 316 mObj->setState(VirtualBoxBase::InInit);317 }318 319 /**320 * Places the managed VirtualBoxBase object to Ready/Limited state if the321 * initialization succeeded or partly succeeded, or places it to InitFailed322 * state and calls the object's uninit() method.323 *324 * Please see the AutoInitSpan class description for more info.325 */326 AutoInitSpan::~AutoInitSpan()327 {328 /* if the state was other than NotReady, do nothing */329 if (!mOk)330 return;331 332 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);333 334 Assert(mObj->mState == VirtualBoxBase::InInit);335 336 if (mObj->mCallers > 0)337 {338 Assert(mObj->mInitUninitWaiters > 0);339 340 /* We have some pending addCaller() calls on other threads (created341 * during InInit), signal that InInit is finished and they may go on. */342 RTSemEventMultiSignal(mObj->mInitUninitSem);343 }344 345 if (mResult == Succeeded)346 {347 mObj->setState(VirtualBoxBase::Ready);348 }349 else350 if (mResult == Limited)351 {352 mObj->setState(VirtualBoxBase::Limited);353 }354 else355 {356 mObj->setState(VirtualBoxBase::InitFailed);357 /* leave the lock to prevent nesting when uninit() is called */358 stateLock.leave();359 /* call uninit() to let the object uninit itself after failed init() */360 mObj->uninit();361 /* Note: the object may no longer exist here (for example, it can call362 * the destructor in uninit()) */363 }364 }365 366 // AutoReinitSpan methods367 ////////////////////////////////////////////////////////////////////////////////368 369 /**370 * Creates a smart re-initialization span object and places the object to371 * InInit state.372 *373 * Please see the AutoInitSpan class description for more info.374 *375 * @param aObj |this| pointer of the managed VirtualBoxBase object whose376 * re-initialization method is being called.377 */378 AutoReinitSpan::AutoReinitSpan(VirtualBoxBase *aObj)379 : mObj(aObj),380 mSucceeded(false),381 mOk(false)382 {383 Assert(aObj);384 385 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);386 387 mOk = mObj->mState == VirtualBoxBase::Limited;388 AssertReturnVoid (mOk);389 390 mObj->setState(VirtualBoxBase::InInit);391 }392 393 /**394 * Places the managed VirtualBoxBase object to Ready state if the395 * re-initialization succeeded (i.e. #setSucceeded() has been called) or back to396 * Limited state otherwise.397 *398 * Please see the AutoInitSpan class description for more info.399 */400 AutoReinitSpan::~AutoReinitSpan()401 {402 /* if the state was other than Limited, do nothing */403 if (!mOk)404 return;405 406 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);407 408 Assert(mObj->mState == VirtualBoxBase::InInit);409 410 if (mObj->mCallers > 0 && mObj->mInitUninitWaiters > 0)411 {412 /* We have some pending addCaller() calls on other threads (created413 * during InInit), signal that InInit is finished and they may go on. */414 RTSemEventMultiSignal(mObj->mInitUninitSem);415 }416 417 if (mSucceeded)418 {419 mObj->setState(VirtualBoxBase::Ready);420 }421 else422 {423 mObj->setState(VirtualBoxBase::Limited);424 }425 }426 427 // AutoUninitSpan methods428 ////////////////////////////////////////////////////////////////////////////////429 430 /**431 * Creates a smart uninitialization span object and places this object to432 * InUninit state.433 *434 * Please see the AutoInitSpan class description for more info.435 *436 * @note This method blocks the current thread execution until the number of437 * callers of the managed VirtualBoxBase object drops to zero!438 *439 * @param aObj |this| pointer of the VirtualBoxBase object whose uninit()440 * method is being called.441 */442 AutoUninitSpan::AutoUninitSpan(VirtualBoxBase *aObj)443 : mObj(aObj),444 mInitFailed(false),445 mUninitDone(false)446 {447 Assert(aObj);448 449 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);450 451 Assert(mObj->mState != VirtualBoxBase::InInit);452 453 /* Set mUninitDone to |true| if this object is already uninitialized454 * (NotReady) or if another AutoUninitSpan is currently active on some455 * other thread (InUninit). */456 mUninitDone = mObj->mState == VirtualBoxBase::NotReady457 || mObj->mState == VirtualBoxBase::InUninit;458 459 if (mObj->mState == VirtualBoxBase::InitFailed)460 {461 /* we've been called by init() on failure */462 mInitFailed = true;463 }464 else465 {466 if (mUninitDone)467 {468 /* do nothing if already uninitialized */469 if (mObj->mState == VirtualBoxBase::NotReady)470 return;471 472 /* otherwise, wait until another thread finishes uninitialization.473 * This is necessary to make sure that when this method returns, the474 * object is NotReady and therefore can be deleted (for example).475 * In particular, this is used by476 * VirtualBoxBaseWithTypedChildrenNEXT::uninitDependentChildren(). */477 478 /* lazy semaphore creation */479 if (mObj->mInitUninitSem == NIL_RTSEMEVENTMULTI)480 {481 RTSemEventMultiCreate(&mObj->mInitUninitSem);482 Assert(mObj->mInitUninitWaiters == 0);483 }484 ++mObj->mInitUninitWaiters;485 486 LogFlowFunc(("{%p}: Waiting for AutoUninitSpan to finish...\n",487 mObj));488 489 stateLock.leave();490 RTSemEventMultiWait(mObj->mInitUninitSem, RT_INDEFINITE_WAIT);491 stateLock.enter();492 493 if (--mObj->mInitUninitWaiters == 0)494 {495 /* destroy the semaphore since no more necessary */496 RTSemEventMultiDestroy(mObj->mInitUninitSem);497 mObj->mInitUninitSem = NIL_RTSEMEVENTMULTI;498 }499 500 return;501 }502 }503 504 /* go to InUninit to prevent from adding new callers */505 mObj->setState(VirtualBoxBase::InUninit);506 507 /* wait for already existing callers to drop to zero */508 if (mObj->mCallers > 0)509 {510 /* lazy creation */511 Assert(mObj->mZeroCallersSem == NIL_RTSEMEVENT);512 RTSemEventCreate(&mObj->mZeroCallersSem);513 514 /* wait until remaining callers release the object */515 LogFlowFunc(("{%p}: Waiting for callers (%d) to drop to zero...\n",516 mObj, mObj->mCallers));517 518 stateLock.leave();519 RTSemEventWait(mObj->mZeroCallersSem, RT_INDEFINITE_WAIT);520 }521 }522 523 /**524 * Places the managed VirtualBoxBase object to the NotReady state.525 */526 AutoUninitSpan::~AutoUninitSpan()527 {528 /* do nothing if already uninitialized */529 if (mUninitDone)530 return;531 532 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS);533 534 Assert(mObj->mState == VirtualBoxBase::InUninit);535 536 mObj->setState(VirtualBoxBase::NotReady);537 }538 539 ////////////////////////////////////////////////////////////////////////////////540 //541 // VirtualBoxBase542 //543 ////////////////////////////////////////////////////////////////////////////////544 294 545 295 /** … … 563 313 */ 564 314 // static 565 const char *VirtualBoxBase::translate 566 315 const char *VirtualBoxBase::translate(const char * /* context */, const char *sourceText, 316 const char * /* comment */) 567 317 { 568 318 #if 0 … … 578 328 } 579 329 580 ////////////////////////////////////////////////////////////////////////////////581 //582 // VirtualBoxSupportTranslationBase583 //584 ////////////////////////////////////////////////////////////////////////////////585 586 /**587 * Modifies the given argument so that it will contain only a class name588 * (null-terminated). The argument must point to a <b>non-constant</b>589 * string containing a valid value, as it is generated by the590 * __PRETTY_FUNCTION__ built-in macro of the GCC compiler, or by the591 * __FUNCTION__ macro of any other compiler.592 *593 * The function assumes that the macro is used within the member of the594 * class derived from the VirtualBoxSupportTranslation<> template.595 *596 * @param prettyFunctionName string to modify597 * @return598 * true on success and false otherwise599 */600 bool VirtualBoxSupportTranslationBase::cutClassNameFrom__PRETTY_FUNCTION__ (char *fn)601 {602 Assert(fn);603 if (!fn)604 return false;605 606 #if defined (__GNUC__)607 608 // the format is like:609 // VirtualBoxSupportTranslation<C>::VirtualBoxSupportTranslation() [with C = VirtualBox]610 611 #define START " = "612 #define END "]"613 614 #elif defined (_MSC_VER)615 616 // the format is like:617 // VirtualBoxSupportTranslation<class VirtualBox>::__ctor618 619 #define START "<class "620 #define END ">::"621 622 #endif623 624 char *start = strstr(fn, START);625 Assert(start);626 if (start)627 {628 start += sizeof(START) - 1;629 char *end = strstr(start, END);630 Assert(end && (end > start));631 if (end && (end > start))632 {633 size_t len = end - start;634 memmove(fn, start, len);635 fn[len] = 0;636 return true;637 }638 }639 640 #undef END641 #undef START642 643 return false;644 }645 646 ////////////////////////////////////////////////////////////////////////////////647 //648 // VirtualBoxSupportErrorInfoImplBase649 //650 ////////////////////////////////////////////////////////////////////////////////651 652 RTTLS VirtualBoxSupportErrorInfoImplBase::MultiResult::sCounter = NIL_RTTLS;653 654 void VirtualBoxSupportErrorInfoImplBase::MultiResult::init()655 {656 if (sCounter == NIL_RTTLS)657 {658 sCounter = RTTlsAlloc();659 AssertReturnVoid (sCounter != NIL_RTTLS);660 }661 662 uintptr_t counter = (uintptr_t) RTTlsGet (sCounter);663 ++ counter;664 RTTlsSet (sCounter, (void *) counter);665 }666 667 VirtualBoxSupportErrorInfoImplBase::MultiResult::~MultiResult()668 {669 uintptr_t counter = (uintptr_t) RTTlsGet (sCounter);670 AssertReturnVoid (counter != 0);671 -- counter;672 RTTlsSet (sCounter, (void *) counter);673 }674 675 330 /** 676 331 * Sets error info for the current thread. This is an internal function that … … 682 337 */ 683 338 /* static */ 684 HRESULT VirtualBox SupportErrorInfoImplBase::setErrorInternal(HRESULT aResultCode,685 686 const wchar_t *aComponent,687 const Bstr &aText,688 689 339 HRESULT VirtualBoxBase::setErrorInternal(HRESULT aResultCode, 340 const GUID &aIID, 341 const char *pcszComponent, 342 const Utf8Str &aText, 343 bool aWarning, 344 bool aLogIt) 690 345 { 691 346 /* whether multi-error mode is turned on */ 692 bool preserve = ((uintptr_t)RTTlsGet(MultiResult::sCounter)) > 0; 693 694 Bstr bstrComponent((CBSTR)aComponent); 347 bool preserve = MultiResult::isMultiEnabled(); 695 348 696 349 if (aLogIt) 697 LogRel(("ERROR [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%ls} aText={%ls} " 698 "aWarning=%RTbool, preserve=%RTbool\n", 699 aResultCode, aResultCode, &aIID, bstrComponent.raw(), aText.raw(), aWarning, 350 LogRel(("ERROR [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%s} aText={%s} aWarning=%RTbool, preserve=%RTbool\n", 351 aResultCode, 352 aResultCode, 353 &aIID, 354 pcszComponent, 355 aText.c_str(), 356 aWarning, 700 357 preserve)); 701 358 … … 746 403 747 404 /* set the current error info and preserve the previous one if any */ 748 rc = info->init(aResultCode, aIID, bstrComponent, aText, curInfo);405 rc = info->init(aResultCode, aIID, pcszComponent, aText, curInfo); 749 406 if (FAILED(rc)) break; 750 407 … … 790 447 791 448 /* set the current error info and preserve the previous one if any */ 792 rc = info->init(aResultCode, aIID, bstrComponent, aText, curInfo);449 rc = info->init(aResultCode, aIID, pcszComponent, Bstr(aText), curInfo); 793 450 if (FAILED(rc)) break; 794 451 … … 809 466 * set the exception (nobody will be able to read it). 810 467 */ 811 LogWarningFunc (("Will not set an exception because " 812 "nsIExceptionService is not available " 813 "(NS_ERROR_UNEXPECTED). " 814 "XPCOM is being shutdown?\n")); 468 LogWarningFunc(("Will not set an exception because nsIExceptionService is not available " 469 "(NS_ERROR_UNEXPECTED). XPCOM is being shutdown?\n")); 815 470 rc = NS_OK; 816 471 } … … 825 480 } 826 481 482 /** 483 * Shortcut instance method to calling the static setErrorInternal with the 484 * class interface ID and component name inserted correctly. This uses the 485 * virtual getClassIID() and getComponentName() methods which are automatically 486 * defined by the VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT macro. 487 * @param aResultCode 488 * @param pcsz 489 * @return 490 */ 491 HRESULT VirtualBoxBase::setError(HRESULT aResultCode, const char *pcsz, ...) 492 { 493 va_list args; 494 va_start(args, pcsz); 495 HRESULT rc = setErrorInternal(aResultCode, 496 this->getClassIID(), 497 this->getComponentName(), 498 Utf8StrFmtVA(pcsz, args), 499 false /* aWarning */, 500 true /* aLogIt */); 501 va_end(args); 502 return rc; 503 } 504 505 /** 506 * Like setError(), but sets the "warning" bit in the call to setErrorInternal(). 507 * @param aResultCode 508 * @param pcsz 509 * @return 510 */ 511 HRESULT VirtualBoxBase::setWarning(HRESULT aResultCode, const char *pcsz, ...) 512 { 513 va_list args; 514 va_start(args, pcsz); 515 HRESULT rc = setErrorInternal(aResultCode, 516 this->getClassIID(), 517 this->getComponentName(), 518 Utf8StrFmtVA(pcsz, args), 519 true /* aWarning */, 520 true /* aLogIt */); 521 va_end(args); 522 return rc; 523 } 524 525 /** 526 * Like setError(), but disables the "log" flag in the call to setErrorInternal(). 527 * @param aResultCode 528 * @param pcsz 529 * @return 530 */ 531 HRESULT VirtualBoxBase::setErrorNoLog(HRESULT aResultCode, const char *pcsz, ...) 532 { 533 va_list args; 534 va_start(args, pcsz); 535 HRESULT rc = setErrorInternal(aResultCode, 536 this->getClassIID(), 537 this->getComponentName(), 538 Utf8StrFmtVA(pcsz, args), 539 false /* aWarning */, 540 false /* aLogIt */); 541 va_end(args); 542 return rc; 543 } 544 545 //////////////////////////////////////////////////////////////////////////////// 546 // 547 // AutoInitSpan methods 548 // 549 //////////////////////////////////////////////////////////////////////////////// 550 551 /** 552 * Creates a smart initialization span object that places the object to 553 * InInit state. 554 * 555 * Please see the AutoInitSpan class description for more info. 556 * 557 * @param aObj |this| pointer of the managed VirtualBoxBase object whose 558 * init() method is being called. 559 * @param aResult Default initialization result. 560 */ 561 AutoInitSpan::AutoInitSpan(VirtualBoxBase *aObj, 562 Result aResult /* = Failed */) 563 : mObj(aObj), 564 mResult(aResult), 565 mOk(false) 566 { 567 Assert(aObj); 568 569 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 570 571 mOk = mObj->mState == VirtualBoxBase::NotReady; 572 AssertReturnVoid (mOk); 573 574 mObj->setState(VirtualBoxBase::InInit); 575 } 576 577 /** 578 * Places the managed VirtualBoxBase object to Ready/Limited state if the 579 * initialization succeeded or partly succeeded, or places it to InitFailed 580 * state and calls the object's uninit() method. 581 * 582 * Please see the AutoInitSpan class description for more info. 583 */ 584 AutoInitSpan::~AutoInitSpan() 585 { 586 /* if the state was other than NotReady, do nothing */ 587 if (!mOk) 588 return; 589 590 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 591 592 Assert(mObj->mState == VirtualBoxBase::InInit); 593 594 if (mObj->mCallers > 0) 595 { 596 Assert(mObj->mInitUninitWaiters > 0); 597 598 /* We have some pending addCaller() calls on other threads (created 599 * during InInit), signal that InInit is finished and they may go on. */ 600 RTSemEventMultiSignal(mObj->mInitUninitSem); 601 } 602 603 if (mResult == Succeeded) 604 { 605 mObj->setState(VirtualBoxBase::Ready); 606 } 607 else 608 if (mResult == Limited) 609 { 610 mObj->setState(VirtualBoxBase::Limited); 611 } 612 else 613 { 614 mObj->setState(VirtualBoxBase::InitFailed); 615 /* leave the lock to prevent nesting when uninit() is called */ 616 stateLock.leave(); 617 /* call uninit() to let the object uninit itself after failed init() */ 618 mObj->uninit(); 619 /* Note: the object may no longer exist here (for example, it can call 620 * the destructor in uninit()) */ 621 } 622 } 623 624 // AutoReinitSpan methods 625 //////////////////////////////////////////////////////////////////////////////// 626 627 /** 628 * Creates a smart re-initialization span object and places the object to 629 * InInit state. 630 * 631 * Please see the AutoInitSpan class description for more info. 632 * 633 * @param aObj |this| pointer of the managed VirtualBoxBase object whose 634 * re-initialization method is being called. 635 */ 636 AutoReinitSpan::AutoReinitSpan(VirtualBoxBase *aObj) 637 : mObj(aObj), 638 mSucceeded(false), 639 mOk(false) 640 { 641 Assert(aObj); 642 643 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 644 645 mOk = mObj->mState == VirtualBoxBase::Limited; 646 AssertReturnVoid (mOk); 647 648 mObj->setState(VirtualBoxBase::InInit); 649 } 650 651 /** 652 * Places the managed VirtualBoxBase object to Ready state if the 653 * re-initialization succeeded (i.e. #setSucceeded() has been called) or back to 654 * Limited state otherwise. 655 * 656 * Please see the AutoInitSpan class description for more info. 657 */ 658 AutoReinitSpan::~AutoReinitSpan() 659 { 660 /* if the state was other than Limited, do nothing */ 661 if (!mOk) 662 return; 663 664 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 665 666 Assert(mObj->mState == VirtualBoxBase::InInit); 667 668 if (mObj->mCallers > 0 && mObj->mInitUninitWaiters > 0) 669 { 670 /* We have some pending addCaller() calls on other threads (created 671 * during InInit), signal that InInit is finished and they may go on. */ 672 RTSemEventMultiSignal(mObj->mInitUninitSem); 673 } 674 675 if (mSucceeded) 676 { 677 mObj->setState(VirtualBoxBase::Ready); 678 } 679 else 680 { 681 mObj->setState(VirtualBoxBase::Limited); 682 } 683 } 684 685 // AutoUninitSpan methods 686 //////////////////////////////////////////////////////////////////////////////// 687 688 /** 689 * Creates a smart uninitialization span object and places this object to 690 * InUninit state. 691 * 692 * Please see the AutoInitSpan class description for more info. 693 * 694 * @note This method blocks the current thread execution until the number of 695 * callers of the managed VirtualBoxBase object drops to zero! 696 * 697 * @param aObj |this| pointer of the VirtualBoxBase object whose uninit() 698 * method is being called. 699 */ 700 AutoUninitSpan::AutoUninitSpan(VirtualBoxBase *aObj) 701 : mObj(aObj), 702 mInitFailed(false), 703 mUninitDone(false) 704 { 705 Assert(aObj); 706 707 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 708 709 Assert(mObj->mState != VirtualBoxBase::InInit); 710 711 /* Set mUninitDone to |true| if this object is already uninitialized 712 * (NotReady) or if another AutoUninitSpan is currently active on some 713 * other thread (InUninit). */ 714 mUninitDone = mObj->mState == VirtualBoxBase::NotReady 715 || mObj->mState == VirtualBoxBase::InUninit; 716 717 if (mObj->mState == VirtualBoxBase::InitFailed) 718 { 719 /* we've been called by init() on failure */ 720 mInitFailed = true; 721 } 722 else 723 { 724 if (mUninitDone) 725 { 726 /* do nothing if already uninitialized */ 727 if (mObj->mState == VirtualBoxBase::NotReady) 728 return; 729 730 /* otherwise, wait until another thread finishes uninitialization. 731 * This is necessary to make sure that when this method returns, the 732 * object is NotReady and therefore can be deleted (for example). 733 * In particular, this is used by 734 * VirtualBoxBaseWithTypedChildrenNEXT::uninitDependentChildren(). */ 735 736 /* lazy semaphore creation */ 737 if (mObj->mInitUninitSem == NIL_RTSEMEVENTMULTI) 738 { 739 RTSemEventMultiCreate(&mObj->mInitUninitSem); 740 Assert(mObj->mInitUninitWaiters == 0); 741 } 742 ++mObj->mInitUninitWaiters; 743 744 LogFlowFunc(("{%p}: Waiting for AutoUninitSpan to finish...\n", 745 mObj)); 746 747 stateLock.leave(); 748 RTSemEventMultiWait(mObj->mInitUninitSem, RT_INDEFINITE_WAIT); 749 stateLock.enter(); 750 751 if (--mObj->mInitUninitWaiters == 0) 752 { 753 /* destroy the semaphore since no more necessary */ 754 RTSemEventMultiDestroy(mObj->mInitUninitSem); 755 mObj->mInitUninitSem = NIL_RTSEMEVENTMULTI; 756 } 757 758 return; 759 } 760 } 761 762 /* go to InUninit to prevent from adding new callers */ 763 mObj->setState(VirtualBoxBase::InUninit); 764 765 /* wait for already existing callers to drop to zero */ 766 if (mObj->mCallers > 0) 767 { 768 /* lazy creation */ 769 Assert(mObj->mZeroCallersSem == NIL_RTSEMEVENT); 770 RTSemEventCreate(&mObj->mZeroCallersSem); 771 772 /* wait until remaining callers release the object */ 773 LogFlowFunc(("{%p}: Waiting for callers (%d) to drop to zero...\n", 774 mObj, mObj->mCallers)); 775 776 stateLock.leave(); 777 RTSemEventWait(mObj->mZeroCallersSem, RT_INDEFINITE_WAIT); 778 } 779 } 780 781 /** 782 * Places the managed VirtualBoxBase object to the NotReady state. 783 */ 784 AutoUninitSpan::~AutoUninitSpan() 785 { 786 /* do nothing if already uninitialized */ 787 if (mUninitDone) 788 return; 789 790 AutoWriteLock stateLock(mObj->mStateLock COMMA_LOCKVAL_SRC_POS); 791 792 Assert(mObj->mState == VirtualBoxBase::InUninit); 793 794 mObj->setState(VirtualBoxBase::NotReady); 795 } 796 797 //////////////////////////////////////////////////////////////////////////////// 798 // 799 // VirtualBoxSupportTranslationBase 800 // 801 //////////////////////////////////////////////////////////////////////////////// 802 803 /** 804 * Modifies the given argument so that it will contain only a class name 805 * (null-terminated). The argument must point to a <b>non-constant</b> 806 * string containing a valid value, as it is generated by the 807 * __PRETTY_FUNCTION__ built-in macro of the GCC compiler, or by the 808 * __FUNCTION__ macro of any other compiler. 809 * 810 * The function assumes that the macro is used within the member of the 811 * class derived from the VirtualBoxSupportTranslation<> template. 812 * 813 * @param prettyFunctionName string to modify 814 * @return 815 * true on success and false otherwise 816 */ 817 bool VirtualBoxSupportTranslationBase::cutClassNameFrom__PRETTY_FUNCTION__ (char *fn) 818 { 819 Assert(fn); 820 if (!fn) 821 return false; 822 823 #if defined (__GNUC__) 824 825 // the format is like: 826 // VirtualBoxSupportTranslation<C>::VirtualBoxSupportTranslation() [with C = VirtualBox] 827 828 #define START " = " 829 #define END "]" 830 831 #elif defined (_MSC_VER) 832 833 // the format is like: 834 // VirtualBoxSupportTranslation<class VirtualBox>::__ctor 835 836 #define START "<class " 837 #define END ">::" 838 839 #endif 840 841 char *start = strstr(fn, START); 842 Assert(start); 843 if (start) 844 { 845 start += sizeof(START) - 1; 846 char *end = strstr(start, END); 847 Assert(end && (end > start)); 848 if (end && (end > start)) 849 { 850 size_t len = end - start; 851 memmove(fn, start, len); 852 fn[len] = 0; 853 return true; 854 } 855 } 856 857 #undef END 858 #undef START 859 860 return false; 861 } 862 863 //////////////////////////////////////////////////////////////////////////////// 864 // 865 // VirtualBoxBaseWithChildrenNEXT methods 866 // 867 //////////////////////////////////////////////////////////////////////////////// 827 868 828 869 /** -
trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp
r28800 r30714 22 22 //////////////////////////////////////////////////////////////////////////////// 23 23 24 HRESULT VirtualBoxErrorInfo::init (HRESULT aResultCode, const GUID &aIID, 25 CBSTR aComponent, CBSTR aText, 26 IVirtualBoxErrorInfo *aNext) 27 { 28 mResultCode = aResultCode; 29 mIID = aIID; 30 mComponent = aComponent; 31 mText = aText; 24 HRESULT VirtualBoxErrorInfo::init(HRESULT aResultCode, 25 const GUID &aIID, 26 const char *pcszComponent, 27 const Utf8Str &strText, 28 IVirtualBoxErrorInfo *aNext) 29 { 30 m_resultCode = aResultCode; 31 m_IID = aIID; 32 m_strComponent = pcszComponent; 33 m_strText = strText; 32 34 mNext = aNext; 33 35 … … 42 44 CheckComArgOutPointerValid(aResultCode); 43 45 44 *aResultCode = m ResultCode;46 *aResultCode = m_resultCode; 45 47 return S_OK; 46 48 } … … 50 52 CheckComArgOutPointerValid(aIID); 51 53 52 m IID.toUtf16().cloneTo(aIID);54 m_IID.toUtf16().cloneTo(aIID); 53 55 return S_OK; 54 56 } … … 58 60 CheckComArgOutPointerValid(aComponent); 59 61 60 m Component.cloneTo(aComponent);62 m_strComponent.cloneTo(aComponent); 61 63 return S_OK; 62 64 } … … 66 68 CheckComArgOutPointerValid(aText); 67 69 68 m Text.cloneTo(aText);70 m_strText.cloneTo(aText); 69 71 return S_OK; 70 72 } … … 94 96 * corresponding fields will simply remain null in this case). */ 95 97 96 m ResultCode = S_OK;97 rc = aInfo->GetGUID (mIID.asOutParam());98 m_resultCode = S_OK; 99 rc = aInfo->GetGUID(m_IID.asOutParam()); 98 100 AssertComRC (rc); 99 rc = aInfo->GetSource (mComponent.asOutParam()); 101 Bstr bstrComponent; 102 rc = aInfo->GetSource(bstrComponent.asOutParam()); 100 103 AssertComRC (rc); 101 rc = aInfo->GetDescription (mText.asOutParam()); 104 m_strComponent = bstrComponent; 105 Bstr bstrText; 106 rc = aInfo->GetDescription(bstrText.asOutParam()); 102 107 AssertComRC (rc); 108 m_strText = bstrText; 103 109 104 110 return S_OK; … … 153 159 * corresponding fields will simply remain null in this case). */ 154 160 155 rc = aInfo->GetResult(&m ResultCode);161 rc = aInfo->GetResult(&m_resultCode); 156 162 AssertComRC(rc); 157 163 … … 161 167 if (NS_SUCCEEDED(rc)) 162 168 { 163 m Text = Bstr(pszMsg);169 m_strText = pszMsg; 164 170 nsMemory::Free(pszMsg); 165 171 } 166 172 else 167 m Text.setNull();173 m_strText.setNull(); 168 174 169 175 return S_OK; … … 178 184 CheckComArgOutPointerValid(aMessage); 179 185 180 Utf8Str (mText).cloneTo(aMessage);186 m_strText.cloneTo(aMessage); 181 187 return S_OK; 182 188 } -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r30591 r30714 2396 2396 LogFlowFuncEnter(); 2397 2397 2398 std::auto_ptr 2399 d(static_cast <StartSVCHelperClientData*>(aUser));2398 std::auto_ptr<StartSVCHelperClientData> 2399 d(static_cast<StartSVCHelperClientData*>(aUser)); 2400 2400 2401 2401 HRESULT rc = S_OK; … … 2425 2425 if (RT_FAILURE(vrc)) 2426 2426 { 2427 rc = setError(E_FAIL,2428 tr("Could not create the communication channel (%Rrc)"), vrc);2427 rc = d->that->setError(E_FAIL, 2428 tr("Could not create the communication channel (%Rrc)"), vrc); 2429 2429 break; 2430 2430 } … … 2467 2467 * (pressing the Cancel button to close the Run As dialog) */ 2468 2468 if (vrc2 == VERR_CANCELLED) 2469 rc = setError(E_FAIL,2470 tr("Operation cancelled by the user"));2469 rc = d->that->setError(E_FAIL, 2470 tr("Operation cancelled by the user")); 2471 2471 else 2472 rc = setError(E_FAIL,2473 tr("Could not launch a privileged process '%s' (%Rrc)"),2474 exePath, vrc2);2472 rc = d->that->setError(E_FAIL, 2473 tr("Could not launch a privileged process '%s' (%Rrc)"), 2474 exePath, vrc2); 2475 2475 break; 2476 2476 } … … 2482 2482 if (RT_FAILURE(vrc)) 2483 2483 { 2484 rc = setError(E_FAIL,2485 tr("Could not launch a process '%s' (%Rrc)"), exePath, vrc);2484 rc = d->that->setError(E_FAIL, 2485 tr("Could not launch a process '%s' (%Rrc)"), exePath, vrc); 2486 2486 break; 2487 2487 } … … 2506 2506 if (SUCCEEDED(rc) && RT_FAILURE(vrc)) 2507 2507 { 2508 rc = setError(E_FAIL,2509 tr("Could not operate the communication channel (%Rrc)"), vrc);2508 rc = d->that->setError(E_FAIL, 2509 tr("Could not operate the communication channel (%Rrc)"), vrc); 2510 2510 break; 2511 2511 } … … 4040 4040 int vrc = RTDirCreateFullPath(strDir.c_str(), 0777); 4041 4041 if (RT_FAILURE(vrc)) 4042 return setError (E_FAIL,4043 tr("Could not create the directory '%s' (%Rrc)"),4044 strDir.c_str(),4045 vrc);4042 return setErrorStatic(E_FAIL, 4043 Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"), 4044 strDir.c_str(), 4045 vrc)); 4046 4046 } 4047 4047 … … 4081 4081 catch (const xml::Error &err) 4082 4082 { 4083 return setError(E_FAIL, tr("%s.\n%s[%d] (%s)"), 4084 err.what(), 4085 pszFile, iLine, pszFunction); 4083 return setErrorStatic(E_FAIL, 4084 Utf8StrFmt(tr("%s.\n%s[%d] (%s)"), 4085 err.what(), 4086 pszFile, iLine, pszFunction).c_str()); 4086 4087 } 4087 4088 catch (const std::exception &err) 4088 4089 { 4089 return setError(E_FAIL, tr("Unexpected exception: %s [%s]\n%s[%d] (%s)"), 4090 err.what(), typeid(err).name(), 4091 pszFile, iLine, pszFunction); 4090 return setErrorStatic(E_FAIL, 4091 Utf8StrFmt(tr("Unexpected exception: %s [%s]\n%s[%d] (%s)"), 4092 err.what(), typeid(err).name(), 4093 pszFile, iLine, pszFunction).c_str()); 4092 4094 } 4093 4095 catch (...) 4094 4096 { 4095 return setError(E_FAIL, tr("Unknown exception\n%s[%d] (%s)"), 4096 pszFile, iLine, pszFunction); 4097 return setErrorStatic(E_FAIL, 4098 Utf8StrFmt(tr("Unknown exception\n%s[%d] (%s)"), 4099 pszFile, iLine, pszFunction).c_str()); 4097 4100 } 4098 4101 -
trunk/src/VBox/Main/generic/NetIf-generic.cpp
r28800 r30714 149 149 if (RT_FAILURE(rc)) 150 150 { 151 progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), 151 progress->notifyComplete(E_FAIL, 152 COM_IIDOF(IHostNetworkInterface), 153 HostNetworkInterface::getStaticComponentName(), 152 154 "Failed to get program path, rc=%Rrc\n", rc); 153 155 return rc; … … 176 178 if (RT_FAILURE(rc)) 177 179 { 178 progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), 180 progress->notifyComplete(E_FAIL, 181 COM_IIDOF(IHostNetworkInterface), 182 HostNetworkInterface::getStaticComponentName(), 179 183 "Failed to get config info for %s (as reported by '" VBOXNETADPCTL_NAME " add')\n", szBuf); 180 184 } … … 194 198 if ((rc = pclose(fp)) != 0) 195 199 { 196 progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), "Failed to execute '"VBOXNETADPCTL_NAME " add' (exit status: %d)", rc); 200 progress->notifyComplete(E_FAIL, 201 COM_IIDOF(IHostNetworkInterface), 202 HostNetworkInterface::getStaticComponentName(), 203 "Failed to execute '"VBOXNETADPCTL_NAME " add' (exit status: %d)", rc); 197 204 rc = VERR_INTERNAL_ERROR; 198 205 } … … 241 248 rc = NetIfAdpCtl(Utf8Str(ifname).c_str(), "remove", NULL, NULL); 242 249 if (RT_FAILURE(rc)) 243 progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), "Failed to execute '"VBOXNETADPCTL_NAME "' (exit status: %d)", rc); 250 progress->notifyComplete(E_FAIL, 251 COM_IIDOF(IHostNetworkInterface), 252 HostNetworkInterface::getStaticComponentName(), 253 "Failed to execute '"VBOXNETADPCTL_NAME "' (exit status: %d)", rc); 244 254 else 245 255 progress->notifyComplete(S_OK); -
trunk/src/VBox/Main/glue/ErrorInfo.cpp
r30683 r30714 54 54 mText = x.mText; 55 55 56 if (x.m_pNext )56 if (x.m_pNext != NULL) 57 57 m_pNext = new ErrorInfo(x.m_pNext); 58 58 else … … 258 258 { 259 259 m_pNext = new ErrorInfo(next); 260 Assert(m_pNext );260 Assert(m_pNext != NULL); 261 261 if (!m_pNext) 262 262 rc = E_OUTOFMEMORY; -
trunk/src/VBox/Main/glue/SupportErrorInfo.cpp
r28800 r30714 63 63 } 64 64 65 // SupportErrorInfoBase methods 66 //////////////////////////////////////////////////////////////////////////////// 67 68 /** 69 * Sets error info for the current thread. This is an internal function that 70 * gets eventually called by all public setError(), setWarning() and 71 * setErrorInfo() variants. 72 * 73 * The previous error info object (if any) will be preserved if the multi-error 74 * mode (see MultiResult) is turned on for the current thread. 75 * 76 * If @a aWarning is @c true, then the highest (31) bit in the @a aResultCode 77 * value which indicates the error severity is reset to zero to make sure the 78 * receiver will recognize that the created error info object represents a 79 * warning rather than an error. 80 * 81 * If @a aInfo is not NULL then all other paremeters are ignored and the given 82 * error info object is set on the current thread. Note that in this case, the 83 * existing error info object (if any) will be preserved by attaching it to the 84 * tail of the error chain of the given aInfo object in multi-error mode. 85 * 86 * If the error info is successfully set then this method returns aResultCode 87 * (or the result code returned as an output parameter of the 88 * aInfo->GetResultCode() call when @a aInfo is not NULL). This is done for 89 * conveinence: this way, setError() and friends may be used in return 90 * statements of COM method implementations. 91 * 92 * If setting error info fails then this method asserts and the failed result 93 * code is returned. 94 */ 95 /* static */ 96 HRESULT SupportErrorInfoBase::setErrorInternal(HRESULT aResultCode, 97 const GUID *aIID, 98 const char *aComponent, 99 const Utf8Str &strText, 100 bool aWarning, 101 IVirtualBoxErrorInfo *aInfo /*= NULL*/) 65 /*static*/ 66 bool MultiResult::isMultiEnabled() 102 67 { 103 /* whether multi-error mode is turned on */ 104 bool preserve = ((uintptr_t)RTTlsGet(MultiResult::sCounter)) > 0; 105 106 LogRel(("ERROR [COM]: aRC=%#08x aIID={%RTuuid} aComponent={%s} aText={%s} aWarning=%RTbool, aInfo=%p, preserve=%RTbool\n", 107 aResultCode, 108 aIID, 109 aComponent, 110 strText.c_str(), 111 aWarning, 112 aInfo, 113 preserve)); 114 115 if (aInfo == NULL) 116 { 117 /* these are mandatory, others -- not */ 118 AssertReturn((!aWarning && FAILED(aResultCode)) || 119 (aWarning && aResultCode != S_OK), 120 E_FAIL); 121 AssertReturn(!strText.isEmpty(), E_FAIL); 122 123 /* reset the error severity bit if it's a warning */ 124 if (aWarning) 125 aResultCode &= ~0x80000000; 126 } 127 128 HRESULT rc = S_OK; 129 130 do 131 { 132 ComPtr<IVirtualBoxErrorInfo> info; 133 134 #if !defined (VBOX_WITH_XPCOM) 135 136 ComPtr<IVirtualBoxErrorInfo> curInfo; 137 if (preserve) 138 { 139 /* get the current error info if any */ 140 ComPtr<IErrorInfo> err; 141 rc = ::GetErrorInfo(0, err.asOutParam()); 142 if (FAILED(rc)) break; 143 rc = err.queryInterfaceTo(curInfo.asOutParam()); 144 if (FAILED(rc)) 145 { 146 /* create a IVirtualBoxErrorInfo wrapper for the native 147 * IErrorInfo object */ 148 ComObjPtr<VirtualBoxErrorInfo> wrapper; 149 rc = wrapper.createObject(); 150 if (SUCCEEDED(rc)) 151 { 152 rc = wrapper->init(err); 153 if (SUCCEEDED(rc)) 154 curInfo = wrapper; 155 } 156 } 157 } 158 /* On failure, curInfo will stay null */ 159 Assert(SUCCEEDED(rc) || curInfo.isNull()); 160 161 /* set the current error info and preserve the previous one if any */ 162 if (aInfo != NULL) 163 { 164 if (curInfo.isNull()) 165 { 166 info = aInfo; 167 } 168 else 169 { 170 ComObjPtr<VirtualBoxErrorInfoGlue> infoObj; 171 rc = infoObj.createObject(); 172 if (FAILED(rc)) break; 173 174 rc = infoObj->init(aInfo, curInfo); 175 if (FAILED(rc)) break; 176 177 info = infoObj; 178 } 179 180 /* we want to return the head's result code */ 181 rc = info->COMGETTER(ResultCode)(&aResultCode); 182 if (FAILED(rc)) break; 183 } 184 else 185 { 186 ComObjPtr<VirtualBoxErrorInfo> infoObj; 187 rc = infoObj.createObject(); 188 if (FAILED(rc)) break; 189 190 rc = infoObj->init(aResultCode, aIID, aComponent, strText.c_str(), curInfo); 191 if (FAILED(rc)) break; 192 193 info = infoObj; 194 } 195 196 ComPtr<IErrorInfo> err; 197 rc = info.queryInterfaceTo(err.asOutParam()); 198 if (SUCCEEDED(rc)) 199 rc = ::SetErrorInfo(0, err); 200 201 #else // !defined (VBOX_WITH_XPCOM) 202 203 nsCOMPtr <nsIExceptionService> es; 204 es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc); 205 if (NS_SUCCEEDED(rc)) 206 { 207 nsCOMPtr <nsIExceptionManager> em; 208 rc = es->GetCurrentExceptionManager(getter_AddRefs(em)); 209 if (FAILED(rc)) break; 210 211 ComPtr<IVirtualBoxErrorInfo> curInfo; 212 if (preserve) 213 { 214 /* get the current error info if any */ 215 ComPtr<nsIException> ex; 216 rc = em->GetCurrentException(ex.asOutParam()); 217 if (FAILED(rc)) break; 218 rc = ex.queryInterfaceTo(curInfo.asOutParam()); 219 if (FAILED(rc)) 220 { 221 /* create a IVirtualBoxErrorInfo wrapper for the native 222 * nsIException object */ 223 ComObjPtr<VirtualBoxErrorInfo> wrapper; 224 rc = wrapper.createObject(); 225 if (SUCCEEDED(rc)) 226 { 227 rc = wrapper->init(ex); 228 if (SUCCEEDED(rc)) 229 curInfo = wrapper; 230 } 231 } 232 } 233 /* On failure, curInfo will stay null */ 234 Assert(SUCCEEDED(rc) || curInfo.isNull()); 235 236 /* set the current error info and preserve the previous one if any */ 237 if (aInfo != NULL) 238 { 239 if (curInfo.isNull()) 240 { 241 info = aInfo; 242 } 243 else 244 { 245 ComObjPtr<VirtualBoxErrorInfoGlue> infoObj; 246 rc = infoObj.createObject(); 247 if (FAILED(rc)) break; 248 249 rc = infoObj->init(aInfo, curInfo); 250 if (FAILED(rc)) break; 251 252 info = infoObj; 253 } 254 255 /* we want to return the head's result code */ 256 PRInt32 lrc; 257 rc = info->COMGETTER(ResultCode)(&lrc); aResultCode = lrc; 258 if (FAILED(rc)) break; 259 } 260 else 261 { 262 ComObjPtr<VirtualBoxErrorInfo> infoObj; 263 rc = infoObj.createObject(); 264 if (FAILED(rc)) break; 265 266 rc = infoObj->init(aResultCode, aIID, aComponent, strText, curInfo); 267 if (FAILED(rc)) break; 268 269 info = infoObj; 270 } 271 272 ComPtr<nsIException> ex; 273 rc = info.queryInterfaceTo(ex.asOutParam()); 274 if (SUCCEEDED(rc)) 275 rc = em->SetCurrentException(ex); 276 } 277 else if (rc == NS_ERROR_UNEXPECTED) 278 { 279 /* 280 * It is possible that setError() is being called by the object 281 * after the XPCOM shutdown sequence has been initiated 282 * (for example, when XPCOM releases all instances it internally 283 * references, which can cause object's FinalConstruct() and then 284 * uninit()). In this case, do_GetService() above will return 285 * NS_ERROR_UNEXPECTED and it doesn't actually make sense to 286 * set the exception (nobody will be able to read it). 287 */ 288 LogWarningFunc (("Will not set an exception because " 289 "nsIExceptionService is not available " 290 "(NS_ERROR_UNEXPECTED). " 291 "XPCOM is being shutdown?\n")); 292 rc = NS_OK; 293 } 294 295 #endif // !defined (VBOX_WITH_XPCOM) 296 } 297 while (0); 298 299 AssertComRC(rc); 300 301 return SUCCEEDED(rc) ? aResultCode : rc; 302 } 303 304 /* static */ 305 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const GUID &aIID, 306 const char *aComponent, const char *aText, 307 ...) 308 { 309 va_list args; 310 va_start(args, aText); 311 HRESULT rc = setErrorV(aResultCode, aIID, aComponent, aText, args); 312 va_end(args); 313 return rc; 314 } 315 316 /* static */ 317 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const GUID &aIID, 318 const char *aComponent, const char *aText, 319 ...) 320 { 321 va_list args; 322 va_start(args, aText); 323 HRESULT rc = setWarningV(aResultCode, aIID, aComponent, aText, args); 324 va_end(args); 325 return rc; 326 } 327 328 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const char *aText, ...) 329 { 330 va_list args; 331 va_start(args, aText); 332 HRESULT rc = setErrorV(aResultCode, mainInterfaceID(), componentName(), 333 aText, args); 334 va_end(args); 335 return rc; 336 } 337 338 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const char *aText, ...) 339 { 340 va_list args; 341 va_start(args, aText); 342 HRESULT rc = setWarningV(aResultCode, mainInterfaceID(), componentName(), 343 aText, args); 344 va_end(args); 345 return rc; 346 } 347 348 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const GUID &aIID, 349 const char *aText, ...) 350 { 351 va_list args; 352 va_start(args, aText); 353 HRESULT rc = setErrorV(aResultCode, aIID, componentName(), aText, args); 354 va_end(args); 355 return rc; 356 } 357 358 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const GUID &aIID, 359 const char *aText, ...) 360 { 361 va_list args; 362 va_start(args, aText); 363 HRESULT rc = setWarningV(aResultCode, aIID, componentName(), aText, args); 364 va_end(args); 365 return rc; 68 return ((uintptr_t)RTTlsGet(MultiResult::sCounter)) > 0; 366 69 } 367 70 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r30702 r30714 3822 3822 <desc> 3823 3823 Tells VBoxSVC that <link to="IConsole::powerUp"/> has completed. 3824 3825 3826 3827 3824 This method may query status information from the progress object it 3825 received in <link to="IInternalMachineControl::beginPowerUp"/> and copy 3826 it over to any in progress <link to="IVirtualBox::openRemoteSession"/> 3827 call in order to complete that progress object. 3828 3828 </desc> 3829 3829 <param name="result" type="long" dir="in"/> … … 9045 9045 </interface> 9046 9046 9047 9048 9047 <!-- 9049 9048 // ISnapshot -
trunk/src/VBox/Main/idl/comimpl.xsl
r30627 r30714 67 67 </xsl:variable> 68 68 69 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $name, ') ')" />69 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $name, ') ')" /> 70 70 <xsl:choose> 71 71 <xsl:when test="$extends='$unknown'"> 72 <xsl:value-of select=" ' COM_INTERFACE_ENTRY(IDispatch) '" />72 <xsl:value-of select=" ' COM_INTERFACE_ENTRY(IDispatch) '" /> 73 73 </xsl:when> 74 74 <xsl:when test="//interface[@name=$extends]"> … … 381 381 <xsl:value-of select="concat(' ', $mType, ' ', $mName,'; ')" /> 382 382 <xsl:value-of select=" 'public: '" /> 383 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,') { ')" />383 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,') { ')" /> 384 384 <xsl:call-template name="genRetParam"> 385 385 <xsl:with-param name="type" select="@type" /> … … 392 392 393 393 <xsl:if test="not(@readonly='yes')"> 394 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,') { ')" />394 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,') { ')" /> 395 395 <xsl:call-template name="genSetParam"> 396 396 <xsl:with-param name="type" select="@type" /> … … 404 404 405 405 <xsl:value-of select=" ' // purely internal setter '" /> 406 <xsl:value-of select="concat(' int set_', @name,'(',$pTypeNameIn, '){ ')" />406 <xsl:value-of select="concat(' HRESULT set_', @name,'(',$pTypeNameIn, ') { ')" /> 407 407 <xsl:call-template name="genSetParam"> 408 408 <xsl:with-param name="type" select="@type" /> … … 439 439 440 440 <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName, 441 ' : public VirtualBoxBase,VBOX_SCRIPTABLE_IMPL(',441 ' : public VirtualBoxBase, VBOX_SCRIPTABLE_IMPL(', 442 442 @name, ') { ')" /> 443 443 <xsl:value-of select="'public: '" /> 444 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', $implName, ') ')" /> 445 <xsl:value-of select=" ' DECLARE_PROTECT_FINAL_CONSTRUCT() '" /> 446 <xsl:value-of select="concat(' BEGIN_COM_MAP(', $implName, ') ')" /> 444 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', $implName, ', ', @name, ') ')" /> 445 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', $implName, ') ')" /> 446 <xsl:value-of select=" ' DECLARE_PROTECT_FINAL_CONSTRUCT() '" /> 447 <xsl:value-of select="concat(' BEGIN_COM_MAP(', $implName, ') ')" /> 447 448 <xsl:call-template name="genComEntry"> 448 449 <xsl:with-param name="name" select="@name" /> 449 450 </xsl:call-template> 450 <xsl:value-of select=" ' END_COM_MAP() '" />451 <xsl:value-of select="concat(' ', $implName, '() {} ')" />452 <xsl:value-of select="concat(' virtual ~', $implName, '() {} ')" />451 <xsl:value-of select=" ' END_COM_MAP() '" /> 452 <xsl:value-of select="concat(' ', $implName, '() {} ')" /> 453 <xsl:value-of select="concat(' virtual ~', $implName, '() {} ')" /> 453 454 <xsl:text><![CDATA[ 454 455 HRESULT FinalConstruct() … … 456 457 return mEvent.createObject(); 457 458 } 458 void FinalRelease() { 459 void FinalRelease() 460 { 459 461 mEvent->FinalRelease(); 460 462 } … … 487 489 <xsl:when test="$isVeto='yes'"> 488 490 <xsl:text><![CDATA[ 489 HRESULT init 491 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE) 490 492 { 491 493 NOREF(aWaitable); … … 510 512 <xsl:otherwise> 511 513 <xsl:text><![CDATA[ 512 HRESULT init 514 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable) 513 515 { 514 516 return mEvent->init(aSource, aType, aWaitable); … … 575 577 <xsl:for-each select="//interface[@autogen=$G_kind]"> 576 578 <xsl:variable name="implName"> 577 <xsl:value-of select=" concat(@name,'Impl')" />579 <xsl:value-of select="substring(@name, 2)" /> 578 580 </xsl:variable> 579 581 <xsl:call-template name="genSwitchCase"> … … 610 612 <xsl:value-of select="concat('// ', @name, ' implementation code ')" /> 611 613 <xsl:variable name="implName"> 612 <xsl:value-of select=" concat(@name,'Impl')" />614 <xsl:value-of select="substring(@name, 2)" /> 613 615 </xsl:variable> 614 616 -
trunk/src/VBox/Main/include/ApplianceImpl.h
r29925 r30714 49 49 class ATL_NO_VTABLE Appliance : 50 50 public VirtualBoxBase, 51 public VirtualBoxSupportErrorInfoImpl<Appliance, IAppliance>,52 51 public VirtualBoxSupportTranslation<Appliance>, 53 52 VBOX_SCRIPTABLE_IMPL(IAppliance) 54 53 { 55 54 public: 56 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)55 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Appliance, IAppliance) 57 56 58 57 DECLARE_NOT_AGGREGATABLE(Appliance) … … 81 80 HRESULT init(VirtualBox *aVirtualBox); 82 81 void uninit(); 83 84 // for VirtualBoxSupportErrorInfoImpl85 static const wchar_t *getComponentName() { return L"Appliance"; }86 82 87 83 /* IAppliance properties */ … … 111 107 Data *m; 112 108 113 bool isApplianceIdle() const;109 bool isApplianceIdle(); 114 110 115 111 HRESULT searchUniqueVMName(Utf8Str& aName) const; … … 127 123 struct LocationInfo; 128 124 void parseURI(Utf8Str strUri, LocationInfo &locInfo) const; 129 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const;125 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket); 130 126 Utf8Str manifestFileName(Utf8Str aPath) const; 131 127 … … 195 191 class ATL_NO_VTABLE VirtualSystemDescription : 196 192 public VirtualBoxBase, 197 public VirtualBoxSupportErrorInfoImpl<VirtualSystemDescription, IVirtualSystemDescription>,198 193 public VirtualBoxSupportTranslation<VirtualSystemDescription>, 199 194 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription) … … 202 197 203 198 public: 204 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)199 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualSystemDescription, IVirtualSystemDescription) 205 200 206 201 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription) … … 222 217 HRESULT init(); 223 218 void uninit(); 224 225 // for VirtualBoxSupportErrorInfoImpl226 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }227 219 228 220 /* IVirtualSystemDescription properties */ -
trunk/src/VBox/Main/include/AudioAdapterImpl.h
r28800 r30714 30 30 class ATL_NO_VTABLE AudioAdapter : 31 31 public VirtualBoxBase, 32 public VirtualBoxSupportErrorInfoImpl<AudioAdapter, IAudioAdapter>,33 32 public VirtualBoxSupportTranslation<AudioAdapter>, 34 33 VBOX_SCRIPTABLE_IMPL(IAudioAdapter) … … 45 44 }; 46 45 47 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (AudioAdapter)46 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(AudioAdapter, IAudioAdapter) 48 47 49 48 DECLARE_NOT_AGGREGATABLE(AudioAdapter) … … 84 83 void copyFrom(AudioAdapter *aThat); 85 84 86 // for VirtualBoxSupportErrorInfoImpl87 static const wchar_t *getComponentName() { return L"AudioAdapter"; }88 89 85 private: 90 86 -
trunk/src/VBox/Main/include/BIOSSettingsImpl.h
r28800 r30714 31 31 32 32 class ATL_NO_VTABLE BIOSSettings : 33 public VirtualBoxSupportErrorInfoImpl<BIOSSettings, IBIOSSettings>,34 33 public VirtualBoxSupportTranslation<BIOSSettings>, 35 34 public VirtualBoxBase, … … 37 36 { 38 37 public: 38 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(BIOSSettings, IBIOSSettings) 39 39 40 DECLARE_NOT_AGGREGATABLE(BIOSSettings) 40 41 … … 85 86 void applyDefaults (GuestOSType *aOsType); 86 87 87 // for VirtualBoxSupportErrorInfoImpl88 static const wchar_t *getComponentName() { return L"BIOSSettings"; }89 90 88 private: 91 89 struct Data; -
trunk/src/VBox/Main/include/ConsoleImpl.h
r30510 r30714 81 81 class ATL_NO_VTABLE Console : 82 82 public VirtualBoxBaseWithChildrenNEXT, 83 public VirtualBoxSupportErrorInfoImpl<Console, IConsole>,84 83 public VirtualBoxSupportTranslation<Console>, 85 84 VBOX_SCRIPTABLE_IMPL(IConsole) … … 93 92 94 93 public: 94 95 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Console, IConsole) 95 96 96 97 DECLARE_NOT_AGGREGATABLE(Console) … … 240 241 static const PDMDRVREG DrvStatusReg; 241 242 242 void reportAuthLibraryError(const char *filename, int rc) 243 { 244 setError(E_FAIL, tr("Could not load the external authentication library '%s' (%Rrc)"), filename, rc); 245 } 243 static HRESULT setErrorStatic(HRESULT aResultCode, const char *pcsz, ...); 244 HRESULT setAuthLibraryError(const char *filename, int rc); 245 HRESULT setInvalidMachineStateError(); 246 246 247 247 static HRESULT handleUnexpectedExceptions(RT_SRC_POS_DECL); … … 249 249 static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType); 250 250 static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun); 251 252 // for VirtualBoxSupportErrorInfoImpl253 static const wchar_t *getComponentName() { return L"Console"; }254 251 255 252 private: -
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r30627 r30714 232 232 class ATL_NO_VTABLE RemoteDisplayInfo : 233 233 public VirtualBoxBase, 234 public VirtualBoxSupportErrorInfoImpl<RemoteDisplayInfo, IRemoteDisplayInfo>,235 234 public VirtualBoxSupportTranslation<RemoteDisplayInfo>, 236 235 VBOX_SCRIPTABLE_IMPL(IRemoteDisplayInfo) … … 238 237 public: 239 238 240 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (RemoteDisplayInfo)239 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteDisplayInfo, IRemoteDisplayInfo) 241 240 242 241 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo) … … 278 277 #undef DECL_GETTER 279 278 280 /* For VirtualBoxSupportErrorInfoImpl. */281 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }282 283 279 private: 284 280 -
trunk/src/VBox/Main/include/DHCPServerImpl.h
r28800 r30714 34 34 class ATL_NO_VTABLE DHCPServer : 35 35 public VirtualBoxBase, 36 public VirtualBoxSupportErrorInfoImpl<DHCPServer, IDHCPServer>,37 36 public VirtualBoxSupportTranslation<DHCPServer>, 38 37 VBOX_SCRIPTABLE_IMPL(IDHCPServer) … … 40 39 public: 41 40 42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (DHCPServer)41 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(DHCPServer, IDHCPServer) 43 42 44 43 DECLARE_NOT_AGGREGATABLE (DHCPServer) … … 79 78 STDMETHOD(Stop)(); 80 79 81 // for VirtualBoxSupportErrorInfoImpl82 static const wchar_t *getComponentName() { return L"DHCPServer"; }83 84 80 private: 85 81 /** weak VirtualBox parent */ -
trunk/src/VBox/Main/include/DisplayImpl.h
r30627 r30714 94 94 public VirtualBoxBase, 95 95 VBOX_SCRIPTABLE_IMPL(IEventListener), 96 public VirtualBoxSupportErrorInfoImpl<Display, IDisplay>,97 96 public VirtualBoxSupportTranslation<Display>, 98 97 VBOX_SCRIPTABLE_IMPL(IDisplay) 99 98 { 100 101 99 public: 102 100 103 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)101 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Display, IDisplay) 104 102 105 103 DECLARE_NOT_AGGREGATABLE(Display) … … 165 163 STDMETHOD(CompleteVHWACommand)(BYTE *pCommand); 166 164 167 // for VirtualBoxSupportErrorInfoImpl168 static const wchar_t *getComponentName() { return L"Display"; }169 170 165 static const PDMDRVREG DrvReg; 171 166 -
trunk/src/VBox/Main/include/EventImpl.h
r30553 r30714 23 23 class ATL_NO_VTABLE VBoxEvent : 24 24 public VirtualBoxBase, 25 public VirtualBoxSupportErrorInfoImpl<VBoxEvent, IEvent>,26 25 public VirtualBoxSupportTranslation<VBoxEvent>, 27 26 VBOX_SCRIPTABLE_IMPL(IEvent) 28 27 { 29 28 public: 30 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent )29 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent, IEvent) 31 30 32 31 DECLARE_NOT_AGGREGATABLE(VBoxEvent) … … 59 58 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult); 60 59 61 // for VirtualBoxSupportErrorInfoImpl62 static const wchar_t *getComponentName() { return L"Event"; }63 64 60 private: 65 61 struct Data; … … 73 69 { 74 70 public: 75 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxVetoEvent )71 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxVetoEvent, IVetoEvent) 76 72 77 73 DECLARE_NOT_AGGREGATABLE(VBoxVetoEvent) … … 125 121 STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos)); 126 122 127 // for VirtualBoxSupportErrorInfoImpl128 static const wchar_t *getComponentName() { return L"VetoEvent"; }129 130 123 private: 131 124 struct Data; … … 136 129 class ATL_NO_VTABLE EventSource : 137 130 public VirtualBoxBase, 138 public VirtualBoxSupportErrorInfoImpl<EventSource, IEventSource>,139 131 public VirtualBoxSupportTranslation<EventSource>, 140 132 VBOX_SCRIPTABLE_IMPL(IEventSource) … … 142 134 public: 143 135 144 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource )136 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource, IEventSource) 145 137 146 138 DECLARE_NOT_AGGREGATABLE(EventSource) … … 178 170 IEvent * aEvent); 179 171 180 // for VirtualBoxSupportErrorInfoImpl181 static const wchar_t *getComponentName() { return L"EventSource"; }182 183 172 private: 184 173 struct Data; -
trunk/src/VBox/Main/include/FramebufferImpl.h
r28800 r30714 32 32 public: 33 33 34 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Framebuffer)34 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Framebuffer, IFramebuffer) 35 35 36 36 DECLARE_NOT_AGGREGATABLE (Framebuffer) -
trunk/src/VBox/Main/include/GuestImpl.h
r30075 r30714 48 48 49 49 class ATL_NO_VTABLE Guest : 50 public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,51 50 public VirtualBoxSupportTranslation<Guest>, 52 51 public VirtualBoxBase, … … 54 53 { 55 54 public: 55 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest) 56 56 57 57 DECLARE_NOT_AGGREGATABLE(Guest) … … 109 109 HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal); 110 110 111 // for VirtualBoxSupportErrorInfoImpl112 static const wchar_t *getComponentName() { return L"Guest"; }113 114 111 # ifdef VBOX_WITH_GUEST_CONTROL 115 112 /** Static callback for handling guest notifications. */ … … 123 120 { 124 121 eVBoxGuestCtrlCallbackType mType; 125 /** Pointer to user-supplied data. */ 122 /** Pointer to user-supplied data. */ 126 123 void *pvData; 127 124 /** Size of user-supplied data. */ -
trunk/src/VBox/Main/include/GuestOSTypeImpl.h
r28826 r30714 26 26 class ATL_NO_VTABLE GuestOSType : 27 27 public VirtualBoxBase, 28 public VirtualBoxSupportErrorInfoImpl<GuestOSType, IGuestOSType>,29 28 public VirtualBoxSupportTranslation<GuestOSType>, 30 29 VBOX_SCRIPTABLE_IMPL(IGuestOSType) 31 30 { 32 31 public: 33 34 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (GuestOSType) 32 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestOSType, IGuestOSType) 35 33 36 34 DECLARE_NOT_AGGREGATABLE(GuestOSType) … … 93 91 uint32_t numSerialEnabled() const { return mNumSerialEnabled; } 94 92 95 // for VirtualBoxSupportErrorInfoImpl96 static const wchar_t *getComponentName() { return L"GuestOSType"; }97 98 93 private: 99 94 -
trunk/src/VBox/Main/include/HostImpl.h
r29615 r30714 36 36 class ATL_NO_VTABLE Host : 37 37 public VirtualBoxBase, 38 public VirtualBoxSupportErrorInfoImpl<Host, IHost>,39 38 public VirtualBoxSupportTranslation<Host>, 40 39 VBOX_SCRIPTABLE_IMPL(IHost) 41 40 { 42 41 public: 42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Host, IHost) 43 43 44 44 DECLARE_NOT_AGGREGATABLE(Host) … … 98 98 99 99 /** 100 * Simple run-time type identification without having to enable C++ RTTI.101 * The class IDs are defined in VirtualBoxBase.h.102 * @return103 */104 virtual VBoxClsID getClassID() const105 {106 return clsidHost;107 }108 109 /**110 100 * Override of the default locking class to be used for validating lock 111 101 * order with the standard member lock handle. … … 137 127 #endif /* !VBOX_WITH_USB */ 138 128 139 // for VirtualBoxSupportErrorInfoImpl140 static const wchar_t *getComponentName() { return L"Host"; }141 142 129 private: 143 130 -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r28800 r30714 32 32 class ATL_NO_VTABLE HostNetworkInterface : 33 33 public VirtualBoxBase, 34 public VirtualBoxSupportErrorInfoImpl<HostNetworkInterface, IHostNetworkInterface>,35 34 public VirtualBoxSupportTranslation<HostNetworkInterface>, 36 35 VBOX_SCRIPTABLE_IMPL(IHostNetworkInterface) … … 38 37 public: 39 38 40 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)39 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(HostNetworkInterface, IHostNetworkInterface) 41 40 42 41 DECLARE_NOT_AGGREGATABLE (HostNetworkInterface) … … 82 81 STDMETHOD(DhcpRediscover) (); 83 82 84 // for VirtualBoxSupportErrorInfoImpl 85 static const wchar_t *getComponentName() { return L"HostNetworkInterface"; } 83 HRESULT setVirtualBox(VirtualBox *pVBox); 86 84 87 HRESULT setVirtualBox(VirtualBox *pVBox);88 85 private: 89 86 const Bstr mInterfaceName; -
trunk/src/VBox/Main/include/KeyboardImpl.h
r28909 r30714 46 46 class ATL_NO_VTABLE Keyboard : 47 47 public VirtualBoxBase, 48 public VirtualBoxSupportErrorInfoImpl<Keyboard, IKeyboard>,49 48 public VirtualBoxSupportTranslation<Keyboard>, 50 49 VBOX_SCRIPTABLE_IMPL(IKeyboard) 51 50 { 52 53 51 public: 54 52 55 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Keyboard)53 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Keyboard, IKeyboard) 56 54 57 55 DECLARE_NOT_AGGREGATABLE(Keyboard) … … 78 76 ULONG *codesStored); 79 77 STDMETHOD(PutCAD)(); 80 81 // for VirtualBoxSupportErrorInfoImpl82 static const wchar_t *getComponentName() { return L"Keyboard"; }83 78 84 79 static const PDMDRVREG DrvReg; -
trunk/src/VBox/Main/include/MachineDebuggerImpl.h
r28800 r30714 27 27 class ATL_NO_VTABLE MachineDebugger : 28 28 public VirtualBoxBase, 29 public VirtualBoxSupportErrorInfoImpl<MachineDebugger, IMachineDebugger>,30 29 public VirtualBoxSupportTranslation<MachineDebugger>, 31 30 VBOX_SCRIPTABLE_IMPL(IMachineDebugger) … … 33 32 public: 34 33 35 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MachineDebugger )34 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MachineDebugger, IMachineDebugger) 36 35 37 36 DECLARE_NOT_AGGREGATABLE (MachineDebugger) … … 85 84 void flushQueuedSettings(); 86 85 87 // for VirtualBoxSupportErrorInfoImpl88 static const wchar_t *getComponentName() { return L"MachineDebugger"; }89 90 86 private: 91 87 // private methods -
trunk/src/VBox/Main/include/MachineImpl.h
r30380 r30714 82 82 class ATL_NO_VTABLE Machine : 83 83 public VirtualBoxBaseWithChildrenNEXT, 84 public VirtualBoxSupportErrorInfoImpl<Machine, IMachine>,85 84 public VirtualBoxSupportTranslation<Machine>, 86 85 VBOX_SCRIPTABLE_IMPL(IMachine) … … 319 318 }; 320 319 321 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine )320 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine, IMachine) 322 321 323 322 DECLARE_NOT_AGGREGATABLE(Machine) … … 511 510 // public methods only for internal purposes 512 511 513 /**514 * Simple run-time type identification without having to enable C++ RTTI.515 * The class IDs are defined in VirtualBoxBase.h.516 * @return517 */ 518 virtual VBoxClsID getClassID() const519 { 520 return clsidMachine;512 virtual bool isSnapshotMachine() const 513 { 514 return false; 515 } 516 517 virtual bool isSessionMachine() const 518 { 519 return false; 521 520 } 522 521 … … 693 692 BOOL *aRegistered = NULL); 694 693 void releaseStateDependency(); 695 696 // for VirtualBoxSupportErrorInfoImpl697 static const wchar_t *getComponentName() { return L"Machine"; }698 694 699 695 protected: … … 926 922 // public methods only for internal purposes 927 923 928 /** 929 * Simple run-time type identification without having to enable C++ RTTI. 930 * The class IDs are defined in VirtualBoxBase.h. 931 * @return 932 */ 933 virtual VBoxClsID getClassID() const 934 { 935 return clsidSessionMachine; 924 virtual bool isSessionMachine() const 925 { 926 return true; 936 927 } 937 928 … … 1106 1097 // public methods only for internal purposes 1107 1098 1108 /** 1109 * Simple run-time type identification without having to enable C++ RTTI. 1110 * The class IDs are defined in VirtualBoxBase.h. 1111 * @return 1112 */ 1113 virtual VBoxClsID getClassID() const 1114 { 1115 return clsidSnapshotMachine; 1099 virtual bool isSnapshotMachine() const 1100 { 1101 return true; 1116 1102 } 1117 1103 … … 1134 1120 inline const Guid &Machine::getSnapshotId() const 1135 1121 { 1136 return getClassID() != clsidSnapshotMachine1137 ? Guid::Empty1138 : static_cast<const SnapshotMachine*>(this)->getSnapshotId();1122 return (isSnapshotMachine()) 1123 ? static_cast<const SnapshotMachine*>(this)->getSnapshotId() 1124 : Guid::Empty; 1139 1125 } 1140 1126 -
trunk/src/VBox/Main/include/MediumAttachmentImpl.h
r28800 r30714 23 23 class ATL_NO_VTABLE MediumAttachment : 24 24 public VirtualBoxBase, 25 public com::SupportErrorInfoImpl<MediumAttachment, IMediumAttachment>,26 25 public VirtualBoxSupportTranslation<MediumAttachment>, 27 26 VBOX_SCRIPTABLE_IMPL(IMediumAttachment) 28 27 { 29 28 public: 29 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumAttachment, IMediumAttachment) 30 30 31 31 DECLARE_NOT_AGGREGATABLE(MediumAttachment) … … 90 90 const char* getLogName(void) const { return mLogName.c_str(); } 91 91 92 /** For com::SupportErrorInfoImpl. */93 static const char *ComponentName() { return "MediumAttachment"; }94 95 92 private: 96 93 struct Data; -
trunk/src/VBox/Main/include/MediumFormatImpl.h
r28800 r30714 40 40 class ATL_NO_VTABLE MediumFormat : 41 41 public VirtualBoxBase, 42 public VirtualBoxSupportErrorInfoImpl<MediumFormat, IMediumFormat>,43 42 public VirtualBoxSupportTranslation<MediumFormat>, 44 43 VBOX_SCRIPTABLE_IMPL(IMediumFormat) … … 69 68 }; 70 69 71 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MediumFormat)70 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumFormat, IMediumFormat) 72 71 73 72 DECLARE_NOT_AGGREGATABLE (MediumFormat) … … 117 116 const PropertyList &properties() const { return m.properties; } 118 117 119 // for VirtualBoxSupportErrorInfoImpl120 static const wchar_t *getComponentName() { return L"MediumFormat"; }121 122 118 private: 123 119 -
trunk/src/VBox/Main/include/MediumImpl.h
r29325 r30714 39 39 class ATL_NO_VTABLE Medium : 40 40 public VirtualBoxBase, 41 public com::SupportErrorInfoImpl<Medium, IMedium>,42 41 public VirtualBoxSupportTranslation<Medium>, 43 42 VBOX_SCRIPTABLE_IMPL(IMedium) 44 43 { 45 44 public: 46 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Medium )45 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Medium, IMedium) 47 46 48 47 DECLARE_NOT_AGGREGATABLE(Medium) … … 230 229 Bstr preferredDiffFormat(); 231 230 232 /** For com::SupportErrorInfoImpl. */233 static const char *ComponentName() { return "Medium"; }234 235 231 private: 236 232 -
trunk/src/VBox/Main/include/MouseImpl.h
r28800 r30714 51 51 #ifndef VBOXBFE_WITHOUT_COM 52 52 , 53 public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,54 53 public VirtualBoxSupportTranslation<Mouse>, 55 54 VBOX_SCRIPTABLE_IMPL(IMouse) … … 58 57 public: 59 58 60 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)59 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Mouse, IMouse) 61 60 62 61 DECLARE_NOT_AGGREGATABLE(Mouse) … … 89 88 STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw, 90 89 LONG buttonState); 91 92 // for VirtualBoxSupportErrorInfoImpl93 static const wchar_t *getComponentName() { return L"Mouse"; }94 90 95 91 static const PDMDRVREG DrvReg; -
trunk/src/VBox/Main/include/NATEngineImpl.h
r28864 r30714 32 32 class ATL_NO_VTABLE NATEngine : 33 33 public VirtualBoxBase, 34 public VirtualBoxSupportErrorInfoImpl<NATEngine, INATEngine>,35 34 public VirtualBoxSupportTranslation<NATEngine>, 36 35 VBOX_SCRIPTABLE_IMPL(INATEngine) … … 69 68 ULONG mAliasMode; 70 69 }; 71 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NATEngine)70 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NATEngine, INATEngine) 72 71 73 72 DECLARE_NOT_AGGREGATABLE(NATEngine) … … 126 125 STDMETHOD(RemoveRedirect)(IN_BSTR aName); 127 126 128 static const wchar_t *getComponentName() { return L"NATEngine"; }129 127 private: 130 128 Backupable<Data> mData; -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r28867 r30714 33 33 class ATL_NO_VTABLE NetworkAdapter : 34 34 public VirtualBoxBase, 35 public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,36 35 public VirtualBoxSupportTranslation<NetworkAdapter>, 37 36 VBOX_SCRIPTABLE_IMPL(INetworkAdapter) … … 73 72 }; 74 73 75 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)74 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NetworkAdapter, INetworkAdapter) 76 75 77 76 DECLARE_NOT_AGGREGATABLE(NetworkAdapter) … … 144 143 void applyDefaults (GuestOSType *aOsType); 145 144 146 // for VirtualBoxSupportErrorInfoImpl147 static const wchar_t *getComponentName() { return L"NetworkAdapter"; }148 149 145 private: 150 146 -
trunk/src/VBox/Main/include/ParallelPortImpl.h
r28800 r30714 29 29 class ATL_NO_VTABLE ParallelPort : 30 30 public VirtualBoxBase, 31 public VirtualBoxSupportErrorInfoImpl<ParallelPort, IParallelPort>,32 31 public VirtualBoxSupportTranslation<ParallelPort>, 33 32 VBOX_SCRIPTABLE_IMPL(IParallelPort) 34 33 { 35 34 public: 36 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ParallelPort)35 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ParallelPort, IParallelPort) 37 36 38 37 DECLARE_NOT_AGGREGATABLE(ParallelPort) … … 82 81 // (ensure there is a caller and a read lock before calling them!) 83 82 84 // for VirtualBoxSupportErrorInfoImpl85 static const wchar_t *getComponentName() { return L"ParallelPort"; }86 87 83 private: 88 84 HRESULT checkSetPath(const Utf8Str &str); -
trunk/src/VBox/Main/include/PerformanceImpl.h
r28800 r30714 52 52 { 53 53 public: 54 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PerformanceMetric, IPerformanceMetric) 54 55 55 56 DECLARE_NOT_AGGREGATABLE (PerformanceMetric) … … 115 116 class ATL_NO_VTABLE PerformanceCollector : 116 117 public VirtualBoxBase, 117 public VirtualBoxSupportErrorInfoImpl<PerformanceCollector, IPerformanceCollector>,118 118 public VirtualBoxSupportTranslation<PerformanceCollector>, 119 119 VBOX_SCRIPTABLE_IMPL(IPerformanceCollector) … … 121 121 public: 122 122 123 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceCollector)123 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PerformanceCollector, IPerformanceCollector) 124 124 125 125 DECLARE_NOT_AGGREGATABLE (PerformanceCollector) … … 188 188 pm::CollectorHAL *getHAL() { return m.hal; }; 189 189 190 // for VirtualBoxSupportErrorInfoImpl191 static const wchar_t *getComponentName() { return L"PerformanceCollector"; }192 193 190 private: 194 191 HRESULT toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst); -
trunk/src/VBox/Main/include/ProgressCombinedImpl.h
r29923 r30714 66 66 */ 67 67 class ATL_NO_VTABLE CombinedProgress : 68 public com::SupportErrorInfoDerived<ProgressBase, CombinedProgress, IProgress>, 68 // public com::SupportErrorInfoDerived<ProgressBase, CombinedProgress, IProgress>, 69 public Progress, 69 70 public VirtualBoxSupportTranslation<CombinedProgress> 70 71 { 71 72 72 73 public: 74 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(CombinedProgress, IProgress) 73 75 74 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE 76 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(CombinedProgress) 75 77 76 DECLARE_NOT_AGGREGATABLE 78 DECLARE_NOT_AGGREGATABLE(CombinedProgress) 77 79 78 80 DECLARE_PROTECT_FINAL_CONSTRUCT() … … 182 184 // public methods only for internal purposes 183 185 184 /** For com::SupportErrorInfoImpl. */185 static const char *ComponentName() { return "CombinedProgress"; }186 187 186 private: 188 187 -
trunk/src/VBox/Main/include/ProgressImpl.h
r29916 r30714 33 33 class ATL_NO_VTABLE ProgressBase : 34 34 public VirtualBoxBase, 35 public com::SupportErrorInfoBase,36 35 public VirtualBoxSupportTranslation<ProgressBase>, 37 36 VBOX_SCRIPTABLE_IMPL(IProgress) … … 39 38 protected: 40 39 41 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ProgressBase) 40 // VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressBase, IProgress) 41 // cannot be added here or Windows will not buuld; as a result, ProgressBase cannot be 42 // instantiated, but we're not doing that anyway (but only its children) 42 43 43 44 DECLARE_EMPTY_CTOR_DTOR (ProgressBase) … … 79 80 // public methods only for internal purposes 80 81 81 static HRESULT setErrorInfoOnThread (IProgress *aProgress);82 82 bool setCancelCallback(void (*pfnCallback)(void *), void *pvUser); 83 83 … … 134 134 */ 135 135 class ATL_NO_VTABLE Progress : 136 public com::SupportErrorInfoDerived<ProgressBase, Progress, IProgress>,136 public ProgressBase, 137 137 public VirtualBoxSupportTranslation<Progress> 138 138 { 139 139 140 140 public: 141 142 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (Progress) 141 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Progress, IProgress) 142 143 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(Progress) 143 144 144 145 DECLARE_NOT_AGGREGATABLE (Progress) … … 260 261 HRESULT notifyComplete(HRESULT aResultCode, 261 262 const GUID &aIID, 262 const Bstr &aComponent,263 const char *pcszComponent, 263 264 const char *aText, 264 265 ...); 265 266 HRESULT notifyCompleteV(HRESULT aResultCode, 266 267 const GUID &aIID, 267 const Bstr &aComponent,268 const char *pcszComponent, 268 269 const char *aText, 269 270 va_list va); 270 271 bool notifyPointOfNoReturn(void); 271 272 272 /** For com::SupportErrorInfoImpl. */273 static const char *ComponentName() { return "Progress"; }274 275 273 private: 276 274 -
trunk/src/VBox/Main/include/ProgressProxyImpl.h
r29937 r30714 33 33 { 34 34 public: 35 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressProxy, IProgress) 36 35 37 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(ProgressProxy) 38 36 39 DECLARE_NOT_AGGREGATABLE(ProgressProxy) 37 40 DECLARE_PROTECT_FINAL_CONSTRUCT() … … 92 95 HRESULT notifyComplete(HRESULT aResultCode, 93 96 const GUID &aIID, 94 const Bstr &aComponent,97 const char *pcszComponent, 95 98 const char *aText, ...); 96 bool 99 bool setOtherProgressObject(IProgress *pOtherProgress); 97 100 98 101 /** For com::SupportErrorInfoImpl. */ -
trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h
r28800 r30714 29 29 class ATL_NO_VTABLE RemoteUSBDevice : 30 30 public VirtualBoxBase, 31 public VirtualBoxSupportErrorInfoImpl<RemoteUSBDevice, IHostUSBDevice>,32 31 public VirtualBoxSupportTranslation<RemoteUSBDevice>, 33 32 VBOX_SCRIPTABLE_IMPL(IHostUSBDevice) … … 35 34 public: 36 35 37 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)36 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteUSBDevice, IHostUSBDevice) 38 37 39 38 DECLARE_NOT_AGGREGATABLE (RemoteUSBDevice) … … 96 95 } 97 96 98 // for VirtualBoxSupportErrorInfoImpl99 static const wchar_t *getComponentName() { return L"RemoteUSBDevice"; }100 101 97 private: 102 98 -
trunk/src/VBox/Main/include/SerialPortImpl.h
r28800 r30714 32 32 class ATL_NO_VTABLE SerialPort : 33 33 public VirtualBoxBase, 34 public VirtualBoxSupportErrorInfoImpl<SerialPort, ISerialPort>,35 34 public VirtualBoxSupportTranslation<SerialPort>, 36 35 VBOX_SCRIPTABLE_IMPL(ISerialPort) 37 36 { 38 37 public: 39 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SerialPort)38 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SerialPort, ISerialPort) 40 39 41 40 DECLARE_NOT_AGGREGATABLE(SerialPort) … … 90 89 // (ensure there is a caller and a read lock before calling them!) 91 90 92 // for VirtualBoxSupportErrorInfoImpl93 static const wchar_t *getComponentName() { return L"SerialPort"; }94 95 91 private: 96 92 HRESULT checkSetPath(const Utf8Str &str); -
trunk/src/VBox/Main/include/SessionImpl.h
r29363 r30714 29 29 * Use SYS V IPC for watching a session. 30 30 * This is defined in the Makefile since it's also used by MachineImpl.h/cpp. 31 *32 * @todo Dmitry, feel free to completely change this (and/or write a better description).33 * (The same goes for the other darwin changes.)34 31 */ 35 32 #ifdef DOXYGEN_RUNNING … … 39 36 class ATL_NO_VTABLE Session : 40 37 public VirtualBoxBase, 41 public VirtualBoxSupportErrorInfoImpl<Session, ISession>,42 38 public VirtualBoxSupportTranslation<Session>, 43 39 VBOX_SCRIPTABLE_IMPL(ISession), … … 48 44 { 49 45 public: 46 47 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Session, ISession) 50 48 51 49 DECLARE_CLASSFACTORY() … … 113 111 IProgress *aProgress); 114 112 115 // for VirtualBoxSupportErrorInfoImpl116 static const wchar_t *getComponentName() { return L"Session"; }117 118 113 private: 119 114 -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r28800 r30714 26 26 class ATL_NO_VTABLE SharedFolder : 27 27 public VirtualBoxBaseWithChildrenNEXT, 28 public VirtualBoxSupportErrorInfoImpl<SharedFolder, ISharedFolder>,29 28 public VirtualBoxSupportTranslation<SharedFolder>, 30 29 VBOX_SCRIPTABLE_IMPL(ISharedFolder) … … 42 41 }; 43 42 44 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SharedFolder)43 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SharedFolder, ISharedFolder) 45 44 46 45 DECLARE_NOT_AGGREGATABLE(SharedFolder) … … 83 82 BOOL isWritable() const { return m.writable; } 84 83 85 // for VirtualBoxSupportErrorInfoImpl86 static const wchar_t *getComponentName() { return L"SharedFolder"; }87 88 84 protected: 89 85 -
trunk/src/VBox/Main/include/SnapshotImpl.h
r28835 r30714 33 33 34 34 class ATL_NO_VTABLE Snapshot : 35 public VirtualBoxSupportErrorInfoImpl<Snapshot, ISnapshot>,36 35 public VirtualBoxSupportTranslation<Snapshot>, 37 36 public VirtualBoxBase, // WithTypedChildren<Snapshot>, … … 39 38 { 40 39 public: 40 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Snapshot, ISnapshot) 41 41 42 DECLARE_NOT_AGGREGATABLE(Snapshot) 42 43 … … 89 90 90 91 /** 91 * Simple run-time type identification without having to enable C++ RTTI.92 * The class IDs are defined in VirtualBoxBase.h.93 * @return94 */95 virtual VBoxClsID getClassID() const96 {97 return clsidSnapshot;98 }99 100 /**101 92 * Override of the default locking class to be used for validating lock 102 93 * order with the standard member lock handle. … … 134 125 HRESULT saveSnapshotImpl(settings::Snapshot &data, bool aAttrsOnly); 135 126 136 // for VirtualBoxSupportErrorInfoImpl137 static const wchar_t *getComponentName()138 {139 return L"Snapshot";140 }141 142 127 private: 143 128 struct Data; // opaque, defined in SnapshotImpl.cpp -
trunk/src/VBox/Main/include/StorageControllerImpl.h
r29480 r30714 25 25 class ATL_NO_VTABLE StorageController : 26 26 public VirtualBoxBase, 27 public VirtualBoxSupportErrorInfoImpl<StorageController, IStorageController>,28 27 public VirtualBoxSupportTranslation<StorageController>, 29 28 VBOX_SCRIPTABLE_IMPL(IStorageController) … … 31 30 public: 32 31 33 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (StorageController)32 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(StorageController, IStorageController) 34 33 35 34 DECLARE_NOT_AGGREGATABLE (StorageController) … … 100 99 ComObjPtr<StorageController> getPeer(); 101 100 102 // for VirtualBoxSupportErrorInfoImpl103 static const wchar_t *getComponentName() { return L"StorageController"; }104 105 101 private: 106 102 -
trunk/src/VBox/Main/include/SystemPropertiesImpl.h
r28800 r30714 35 35 class ATL_NO_VTABLE SystemProperties : 36 36 public VirtualBoxBase, 37 public VirtualBoxSupportErrorInfoImpl<SystemProperties, ISystemProperties>,38 37 public VirtualBoxSupportTranslation<SystemProperties>, 39 38 VBOX_SCRIPTABLE_IMPL(ISystemProperties) … … 41 40 public: 42 41 43 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SystemProperties )42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SystemProperties, ISystemProperties) 44 43 45 44 DECLARE_NOT_AGGREGATABLE(SystemProperties) … … 114 113 // (ensure there is a caller and a read lock before calling them!) 115 114 116 // for VirtualBoxSupportErrorInfoImpl117 static const wchar_t *getComponentName() { return L"SystemProperties"; }118 119 115 private: 120 116 -
trunk/src/VBox/Main/include/USBControllerImpl.h
r28800 r30714 33 33 class ATL_NO_VTABLE USBController : 34 34 public VirtualBoxBase, 35 public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>,36 35 public VirtualBoxSupportTranslation<USBController>, 37 36 VBOX_SCRIPTABLE_IMPL(IUSBController) 38 37 { 39 38 public: 40 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)39 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(USBController, IUSBController) 41 40 42 41 DECLARE_NOT_AGGREGATABLE (USBController) … … 98 97 Machine* getMachine(); 99 98 100 // for VirtualBoxSupportErrorInfoImpl101 static const wchar_t *getComponentName() { return L"USBController"; }102 103 99 private: 104 100 -
trunk/src/VBox/Main/include/USBDeviceImpl.h
r28800 r30714 28 28 class ATL_NO_VTABLE OUSBDevice : 29 29 public VirtualBoxBase, 30 public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,31 30 public VirtualBoxSupportTranslation<OUSBDevice>, 32 31 VBOX_SCRIPTABLE_IMPL(IUSBDevice) … … 34 33 public: 35 34 36 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)35 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(OUSBDevice, IUSBDevice) 37 36 38 37 DECLARE_NOT_AGGREGATABLE(OUSBDevice) … … 71 70 // public methods only for internal purposes 72 71 const Guid &id() const { return mData.id; } 73 74 // for VirtualBoxSupportErrorInfoImpl75 static const wchar_t *getComponentName() { return L"USBDevice"; }76 72 77 73 private: -
trunk/src/VBox/Main/include/VFSExplorerImpl.h
r28800 r30714 25 25 class ATL_NO_VTABLE VFSExplorer : 26 26 public VirtualBoxBase, 27 public VirtualBoxSupportErrorInfoImpl<VFSExplorer, IVFSExplorer>,28 27 public VirtualBoxSupportTranslation<VFSExplorer>, 29 28 VBOX_SCRIPTABLE_IMPL(IVFSExplorer) 30 29 { 31 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VFSExplorer)30 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VFSExplorer, IVFSExplorer) 32 31 33 32 DECLARE_NOT_AGGREGATABLE(VFSExplorer) … … 49 48 HRESULT init(VFSType_T aType, Utf8Str aFilePath, Utf8Str aHostname, Utf8Str aUsername, Utf8Str aPassword, VirtualBox *aVirtualBox); 50 49 void uninit(); 51 52 // for VirtualBoxSupportErrorInfoImpl53 static const wchar_t *getComponentName() { return L"VFSExplorer"; }54 50 55 51 /* IVFSExplorer properties */ -
trunk/src/VBox/Main/include/VRDPServerImpl.h
r28802 r30714 32 32 class ATL_NO_VTABLE VRDPServer : 33 33 public VirtualBoxBase, 34 public VirtualBoxSupportErrorInfoImpl<VRDPServer, IVRDPServer>,35 34 public VirtualBoxSupportTranslation<VRDPServer>, 36 35 VBOX_SCRIPTABLE_IMPL(IVRDPServer) … … 51 50 }; 52 51 53 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VRDPServer)52 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VRDPServer, IVRDPServer) 54 53 55 54 DECLARE_NOT_AGGREGATABLE(VRDPServer) … … 105 104 void copyFrom (VRDPServer *aThat); 106 105 107 // for VirtualBoxSupportErrorInfoImpl108 static const wchar_t *getComponentName() { return L"VRDPServer"; }109 110 106 private: 111 107 -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r29386 r30714 157 157 do { \ 158 158 if (RT_UNLIKELY(!(expr))) \ 159 setError(E_FAIL, "Assertion failed: [%s] at '%s' (%d) in %s.\n" \ 160 "Please contact the product vendor!", \ 161 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ 159 setErrorInternal(E_FAIL, \ 160 getStaticClassIID(), \ 161 getStaticComponentName(), \ 162 Utf8StrFmt("Assertion failed: [%s] at '%s' (%d) in %s.\nPlease contact the product vendor!", \ 163 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), \ 164 false, true); \ 162 165 } while (0) 163 166 #endif … … 178 181 do { \ 179 182 if (RT_UNLIKELY(!(expr))) \ 180 setError(E_FAIL, "Assertion failed: [%s] at '%s' (%d) in %s.\n" \ 181 "%s.\n" \ 182 "Please contact the product vendor!", \ 183 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__, Utf8StrFmt a .raw()); \ 183 setErrorInternal(E_FAIL, \ 184 getStaticClassIID(), \ 185 getStaticComponentName(), \ 186 Utf8StrFmt("Assertion failed: [%s] at '%s' (%d) in %s.\n%s.\nPlease contact the product vendor!", \ 187 #expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), \ 188 false, true); \ 184 189 } while (0) 185 190 #endif … … 393 398 if (RT_UNLIKELY(ComSafeArrayOutIsNull(arg))) \ 394 399 return setError(E_POINTER, \ 395 tr("Output argument %s points to invalid memory location (%p)"), \396 #arg, (void *)(arg)); \400 tr("Output argument %s points to invalid memory location (%p)"), \ 401 #arg, (void*)(arg)); \ 397 402 } while (0) 398 403 … … 435 440 //////////////////////////////////////////////////////////////////////////////// 436 441 437 /** 438 * This enum is used in the virtual method VirtualBoxBasePro::getClassID() to 439 * allow VirtualBox classes to identify themselves. Subclasses can override 440 * that method and return a value from this enum if run-time identification is 441 * needed anywhere. 442 */ 443 enum VBoxClsID 444 { 445 clsidVirtualBox, 446 clsidHost, 447 clsidMachine, 448 clsidSessionMachine, 449 clsidSnapshotMachine, 450 clsidSnapshot, 451 clsidOther 452 }; 442 #define VIRTUALBOXBASE_ADD_VIRTUAL_COMPONENT_METHODS(cls, iface) \ 443 virtual const IID& getClassIID() const \ 444 { \ 445 return cls::getStaticClassIID(); \ 446 } \ 447 static const IID& getStaticClassIID() \ 448 { \ 449 return COM_IIDOF(iface); \ 450 } \ 451 virtual const char* getComponentName() const \ 452 { \ 453 return cls::getStaticComponentName(); \ 454 } \ 455 static const char* getStaticComponentName() \ 456 { \ 457 return #cls; \ 458 } 459 460 /** 461 * VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT: 462 * This macro must be used once in the declaration of any class derived 463 * from VirtualBoxBase. It implements the pure virtual getClassIID() and 464 * getComponentName() methods. If this macro is not present, instances 465 * of a class derived from VirtualBoxBase cannot be instantiated. 466 * 467 * @param X The class name, e.g. "Class". 468 * @param IX The interface name which this class implements, e.g. "IClass". 469 */ 470 #ifdef VBOX_WITH_XPCOM 471 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls, iface) \ 472 VIRTUALBOXBASE_ADD_VIRTUAL_COMPONENT_METHODS(cls, iface) 473 #else // #ifdef VBOX_WITH_XPCOM 474 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls, iface) \ 475 VIRTUALBOXBASE_ADD_VIRTUAL_COMPONENT_METHODS(cls, iface) \ 476 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) \ 477 { \ 478 const _ATL_INTMAP_ENTRY* pEntries = cls::_GetEntries(); \ 479 Assert(pEntries); \ 480 if (!pEntries) \ 481 return S_FALSE; \ 482 BOOL bSupports = FALSE; \ 483 BOOL bISupportErrorInfoFound = FALSE; \ 484 while (pEntries->pFunc != NULL && !bSupports) \ 485 { \ 486 if (!bISupportErrorInfoFound) \ 487 bISupportErrorInfoFound = InlineIsEqualGUID(*(pEntries->piid), IID_ISupportErrorInfo); \ 488 else \ 489 bSupports = InlineIsEqualGUID(*(pEntries->piid), riid); \ 490 pEntries++; \ 491 } \ 492 Assert(bISupportErrorInfoFound); \ 493 return bSupports ? S_OK : S_FALSE; \ 494 } 495 #endif // #ifdef VBOX_WITH_XPCOM 453 496 454 497 /** … … 457 500 * 458 501 * Declares functionality that should be available in all components. 459 *460 * Note that this class is always subclassed using the virtual keyword so461 * that only one instance of its VTBL and data is present in each derived class462 * even in case if VirtualBoxBaseProto appears more than once among base classes463 * of the particular component as a result of multiple inheritance.464 *465 * This makes it possible to have intermediate base classes used by several466 * components that implement some common interface functionality but still let467 * the final component classes choose what VirtualBoxBase variant it wants to468 * use.469 502 * 470 503 * Among the basic functionality implemented by this class is the primary object … … 519 552 : public Lockable, 520 553 public CComObjectRootEx<CComMultiThreadModel> 554 #if !defined (VBOX_WITH_XPCOM) 555 , public ISupportErrorInfo 556 #endif 521 557 { 522 558 public: … … 528 564 static const char *translate(const char *context, const char *sourceText, 529 565 const char *comment = 0); 530 531 public:532 566 533 567 /** … … 548 582 virtual void uninit() {} 549 583 550 virtual HRESULT addCaller(State *aState = NULL, bool aLimited = false); 584 virtual HRESULT addCaller(State *aState = NULL, 585 bool aLimited = false); 551 586 virtual void releaseCaller(); 552 587 … … 562 597 563 598 /** 564 * Simple run-time type identification without having to enable C++ RTTI. 565 * The class IDs are defined in VirtualBoxBase.h. 566 * @return 567 */ 568 virtual VBoxClsID getClassID() const 569 { 570 return clsidOther; 571 } 572 573 /** 574 * Override of the default locking class to be used for validating lock 575 * order with the standard member lock handle. 599 * Pure virtual method for simple run-time type identification without 600 * having to enable C++ RTTI. 601 * 602 * This *must* be implemented by every subclass deriving from VirtualBoxBase; 603 * use the VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT macro to do that most easily. 604 */ 605 virtual const IID& getClassIID() const = 0; 606 607 /** 608 * Pure virtual method for simple run-time type identification without 609 * having to enable C++ RTTI. 610 * 611 * This *must* be implemented by every subclass deriving from VirtualBoxBase; 612 * use the VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT macro to do that most easily. 613 */ 614 virtual const char* getComponentName() const = 0; 615 616 /** 617 * Virtual method which determins the locking class to be used for validating 618 * lock order with the standard member lock handle. This method is overridden 619 * in a number of subclasses. 576 620 */ 577 621 virtual VBoxLockingClass getLockingClass() const … … 589 633 */ 590 634 WriteLockHandle *stateLockHandle() { return &mStateLock; } 635 636 static HRESULT setErrorInternal(HRESULT aResultCode, 637 const GUID &aIID, 638 const char *aComponent, 639 const Utf8Str &aText, 640 bool aWarning, 641 bool aLogIt); 642 643 HRESULT setError(HRESULT aResultCode, const char *pcsz, ...); 644 HRESULT setWarning(HRESULT aResultCode, const char *pcsz, ...); 645 HRESULT setErrorNoLog(HRESULT aResultCode, const char *pcsz, ...); 591 646 592 647 private: … … 624 679 625 680 //////////////////////////////////////////////////////////////////////////////// 626 //627 // VirtualBoxSupportTranslation, VirtualBoxSupportErrorInfoImpl628 //629 ////////////////////////////////////////////////////////////////////////////////630 631 /**632 * This macro adds the error info support to methods of the VirtualBoxBase633 * class (by overriding them). Place it to the public section of the634 * VirtualBoxBase subclass and the following methods will set the extended635 * error info in case of failure instead of just returning the result code:636 *637 * <ul>638 * <li>VirtualBoxBase::addCaller()639 * </ul>640 *641 * @note The given VirtualBoxBase subclass must also inherit from both642 * VirtualBoxSupportErrorInfoImpl and VirtualBoxSupportTranslation templates!643 *644 * @param C VirtualBoxBase subclass to add the error info support to645 */646 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(C) \647 virtual HRESULT addCaller(VirtualBoxBase::State *aState = NULL, \648 bool aLimited = false) \649 { \650 VirtualBoxBase::State protoState; \651 HRESULT rc = VirtualBoxBase::addCaller(&protoState, aLimited); \652 if (FAILED(rc)) \653 { \654 if (protoState == VirtualBoxBase::Limited) \655 rc = setError(rc, tr("The object functionality is limited")); \656 else \657 rc = setError(rc, tr("The object is not ready")); \658 } \659 if (aState) \660 *aState = protoState; \661 return rc; \662 } \663 664 ////////////////////////////////////////////////////////////////////////////////665 681 666 682 /** Helper for VirtualBoxSupportTranslation. */ … … 764 780 765 781 //////////////////////////////////////////////////////////////////////////////// 766 767 /**768 * Helper for the VirtualBoxSupportErrorInfoImpl template.769 */770 /// @todo switch to com::SupportErrorInfo* and remove771 class VirtualBoxSupportErrorInfoImplBase772 {773 static HRESULT setErrorInternal(HRESULT aResultCode,774 const GUID &aIID,775 const wchar_t *aComponent,776 const Bstr &aText,777 bool aWarning,778 bool aLogIt);779 780 protected:781 782 /**783 * The MultiResult class is a com::FWResult enhancement that also acts as a784 * switch to turn on multi-error mode for #setError() or #setWarning()785 * calls.786 *787 * When an instance of this class is created, multi-error mode is turned on788 * for the current thread and the turn-on counter is increased by one. In789 * multi-error mode, a call to #setError() or #setWarning() does not790 * overwrite the current error or warning info object possibly set on the791 * current thread by other method calls, but instead it stores this old792 * object in the IVirtualBoxErrorInfo::next attribute of the new error793 * object being set.794 *795 * This way, error/warning objects are stacked together and form a chain of796 * errors where the most recent error is the first one retrieved by the797 * calling party, the preceding error is what the798 * IVirtualBoxErrorInfo::next attribute of the first error points to, and so799 * on, up to the first error or warning occurred which is the last in the800 * chain. See IVirtualBoxErrorInfo documentation for more info.801 *802 * When the instance of the MultiResult class goes out of scope and gets803 * destroyed, it automatically decreases the turn-on counter by one. If804 * the counter drops to zero, multi-error mode for the current thread is805 * turned off and the thread switches back to single-error mode where every806 * next error or warning object overwrites the previous one.807 *808 * Note that the caller of a COM method uses a non-S_OK result code to809 * decide if the method has returned an error (negative codes) or a warning810 * (positive non-zero codes) and will query extended error info only in811 * these two cases. However, since multi-error mode implies that the method812 * doesn't return control return to the caller immediately after the first813 * error or warning but continues its execution, the functionality provided814 * by the base com::FWResult class becomes very useful because it allows to815 * preserve the error or the warning result code even if it is later assigned816 * a S_OK value multiple times. See com::FWResult for details.817 *818 * Here is the typical usage pattern:819 * <code>820 821 HRESULT Bar::method()822 {823 // assume multi-errors are turned off here...824 825 if (something)826 {827 // Turn on multi-error mode and make sure severity is preserved828 MultiResult rc = foo->method1();829 830 // return on fatal error, but continue on warning or on success831 if (FAILED(rc)) return rc;832 833 rc = foo->method2();834 // no matter what result, stack it and continue835 836 // ...837 838 // return the last worst result code (it will be preserved even if839 // foo->method2() returns S_OK.840 return rc;841 }842 843 // multi-errors are turned off here again...844 845 return S_OK;846 }847 848 * </code>849 *850 *851 * @note This class is intended to be instantiated on the stack, therefore852 * You cannot create them using new(). Although it is possible to copy853 * instances of MultiResult or return them by value, please never do854 * that as it is breaks the class semantics (and will assert).855 */856 class MultiResult : public com::FWResult857 {858 public:859 860 /**861 * @copydoc com::FWResult::FWResult().862 */863 MultiResult(HRESULT aRC = E_FAIL) : FWResult(aRC) { init(); }864 865 MultiResult(const MultiResult &aThat) : FWResult(aThat)866 {867 /* We need this copy constructor only for GCC that wants to have868 * it in case of expressions like |MultiResult rc = E_FAIL;|. But869 * we assert since the optimizer should actually avoid the870 * temporary and call the other constructor directly instead. */871 AssertFailed();872 init();873 }874 875 ~MultiResult();876 877 MultiResult &operator=(HRESULT aRC)878 {879 com::FWResult::operator=(aRC);880 return *this;881 }882 883 MultiResult &operator=(const MultiResult &aThat)884 {885 /* We need this copy constructor only for GCC that wants to have886 * it in case of expressions like |MultiResult rc = E_FAIL;|. But887 * we assert since the optimizer should actually avoid the888 * temporary and call the other constructor directly instead. */889 AssertFailed();890 com::FWResult::operator=(aThat);891 return *this;892 }893 894 private:895 896 DECLARE_CLS_NEW_DELETE_NOOP(MultiResult)897 898 void init();899 900 static RTTLS sCounter;901 902 friend class VirtualBoxSupportErrorInfoImplBase;903 };904 905 static HRESULT setError(HRESULT aResultCode,906 const GUID &aIID,907 const wchar_t *aComponent,908 const Bstr &aText,909 bool aLogIt = true)910 {911 return setErrorInternal(aResultCode, aIID, aComponent, aText,912 false /* aWarning */, aLogIt);913 }914 915 static HRESULT setWarning(HRESULT aResultCode,916 const GUID &aIID,917 const wchar_t *aComponent,918 const Bstr &aText)919 {920 return setErrorInternal(aResultCode, aIID, aComponent, aText,921 true /* aWarning */, true /* aLogIt */);922 }923 924 static HRESULT setError(HRESULT aResultCode,925 const GUID &aIID,926 const wchar_t *aComponent,927 const char *aText, va_list aArgs, bool aLogIt = true)928 {929 return setErrorInternal(aResultCode, aIID, aComponent,930 Utf8StrFmtVA (aText, aArgs),931 false /* aWarning */, aLogIt);932 }933 934 static HRESULT setWarning(HRESULT aResultCode,935 const GUID &aIID,936 const wchar_t *aComponent,937 const char *aText, va_list aArgs)938 {939 return setErrorInternal(aResultCode, aIID, aComponent,940 Utf8StrFmtVA (aText, aArgs),941 true /* aWarning */, true /* aLogIt */);942 }943 };944 945 /**946 * This template implements ISupportErrorInfo for the given component class947 * and provides the #setError() method to conveniently set the error information948 * from within interface methods' implementations.949 *950 * On Windows, the template argument must define a COM interface map using951 * BEGIN_COM_MAP / END_COM_MAP macros and this map must contain a952 * COM_INTERFACE_ENTRY(ISupportErrorInfo) definition. All interface entries953 * that follow it will be considered to support IErrorInfo, i.e. the954 * InterfaceSupportsErrorInfo() implementation will return S_OK for the955 * corresponding IID.956 *957 * On all platforms, the template argument must also define the following958 * method: |public static const wchar_t *C::getComponentName()|. See959 * #setError(HRESULT, const char *, ...) for a description on how it is960 * used.961 *962 * @param C963 * component class that implements one or more COM interfaces964 * @param I965 * default interface for the component. This interface's IID is used966 * by the shortest form of #setError, for convenience.967 */968 /// @todo switch to com::SupportErrorInfo* and remove969 template<class C, class I>970 class ATL_NO_VTABLE VirtualBoxSupportErrorInfoImpl971 : protected VirtualBoxSupportErrorInfoImplBase972 #if !defined (VBOX_WITH_XPCOM)973 , public ISupportErrorInfo974 #else975 #endif976 {977 public:978 979 #if !defined (VBOX_WITH_XPCOM)980 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)981 {982 const _ATL_INTMAP_ENTRY* pEntries = C::_GetEntries();983 Assert(pEntries);984 if (!pEntries)985 return S_FALSE;986 987 BOOL bSupports = FALSE;988 BOOL bISupportErrorInfoFound = FALSE;989 990 while (pEntries->pFunc != NULL && !bSupports)991 {992 if (!bISupportErrorInfoFound)993 {994 // skip the com map entries until ISupportErrorInfo is found995 bISupportErrorInfoFound =996 InlineIsEqualGUID(*(pEntries->piid), IID_ISupportErrorInfo);997 }998 else999 {1000 // look for the requested interface in the rest of the com map1001 bSupports = InlineIsEqualGUID(*(pEntries->piid), riid);1002 }1003 pEntries++;1004 }1005 1006 Assert(bISupportErrorInfoFound);1007 1008 return bSupports ? S_OK : S_FALSE;1009 }1010 #endif // !defined (VBOX_WITH_XPCOM)1011 1012 protected:1013 1014 /**1015 * Sets the error information for the current thread.1016 * This information can be retrieved by a caller of an interface method1017 * using IErrorInfo on Windows or nsIException on Linux, or the cross-platform1018 * IVirtualBoxErrorInfo interface that provides extended error info (only1019 * for components from the VirtualBox COM library). Alternatively, the1020 * platform-independent class com::ErrorInfo (defined in VBox[XP]COM.lib)1021 * can be used to retrieve error info in a convenient way.1022 *1023 * It is assumed that the interface method that uses this function returns1024 * an unsuccessful result code to the caller (otherwise, there is no reason1025 * for the caller to try to retrieve error info after method invocation).1026 *1027 * Here is a table of correspondence between this method's arguments1028 * and IErrorInfo/nsIException/IVirtualBoxErrorInfo attributes/methods:1029 *1030 * argument IErrorInfo nsIException IVirtualBoxErrorInfo1031 * ----------------------------------------------------------------1032 * resultCode -- result resultCode1033 * iid GetGUID -- interfaceID1034 * component GetSource -- component1035 * text GetDescription message text1036 *1037 * This method is rarely needs to be used though. There are more convenient1038 * overloaded versions, that automatically substitute some arguments1039 * taking their values from the template parameters. See1040 * #setError(HRESULT, const char *, ...) for an example.1041 *1042 * @param aResultCode result (error) code, must not be S_OK1043 * @param aIID IID of the interface that defines the error1044 * @param aComponent name of the component that generates the error1045 * @param aText error message (must not be null), an RTStrPrintf-like1046 * format string in UTF-8 encoding1047 * @param ... list of arguments for the format string1048 *1049 * @return1050 * the error argument, for convenience, If an error occurs while1051 * creating error info itself, that error is returned instead of the1052 * error argument.1053 */1054 static HRESULT setError(HRESULT aResultCode, const GUID &aIID,1055 const wchar_t *aComponent,1056 const char *aText, ...)1057 {1058 va_list args;1059 va_start(args, aText);1060 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setError(aResultCode,1061 aIID,1062 aComponent,1063 aText,1064 args,1065 true /* aLogIt */);1066 va_end(args);1067 return rc;1068 }1069 1070 /**1071 * This method is the same as #setError() except that it makes sure @a1072 * aResultCode doesn't have the error severity bit (31) set when passed1073 * down to the created IVirtualBoxErrorInfo object.1074 *1075 * The error severity bit is always cleared by this call, thereof you can1076 * use ordinary E_XXX result code constants, for convenience. However, this1077 * behavior may be non-standard on some COM platforms.1078 */1079 static HRESULT setWarning(HRESULT aResultCode, const GUID &aIID,1080 const wchar_t *aComponent,1081 const char *aText, ...)1082 {1083 va_list args;1084 va_start(args, aText);1085 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setWarning(1086 aResultCode, aIID, aComponent, aText, args);1087 va_end(args);1088 return rc;1089 }1090 1091 /**1092 * Sets the error information for the current thread.1093 * A convenience method that automatically sets the default interface1094 * ID (taken from the I template argument) and the component name1095 * (a value of C::getComponentName()).1096 *1097 * See #setError(HRESULT, const GUID &, const wchar_t *, const char *text, ...)1098 * for details.1099 *1100 * This method is the most common (and convenient) way to set error1101 * information from within interface methods. A typical pattern of usage1102 * is looks like this:1103 *1104 * <code>1105 * return setError(E_FAIL, "Terrible Error");1106 * </code>1107 * or1108 * <code>1109 * HRESULT rc = setError(E_FAIL, "Terrible Error");1110 * ...1111 * return rc;1112 * </code>1113 */1114 static HRESULT setError(HRESULT aResultCode, const char *aText, ...)1115 {1116 va_list args;1117 va_start(args, aText);1118 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setError(aResultCode,1119 COM_IIDOF(I),1120 C::getComponentName(),1121 aText,1122 args,1123 true /* aLogIt */);1124 va_end(args);1125 return rc;1126 }1127 1128 /**1129 * This method is the same as #setError() except that it makes sure @a1130 * aResultCode doesn't have the error severity bit (31) set when passed1131 * down to the created IVirtualBoxErrorInfo object.1132 *1133 * The error severity bit is always cleared by this call, thereof you can1134 * use ordinary E_XXX result code constants, for convenience. However, this1135 * behavior may be non-standard on some COM platforms.1136 */1137 static HRESULT setWarning(HRESULT aResultCode, const char *aText, ...)1138 {1139 va_list args;1140 va_start(args, aText);1141 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setWarning(aResultCode,1142 COM_IIDOF(I),1143 C::getComponentName(),1144 aText,1145 args);1146 va_end(args);1147 return rc;1148 }1149 1150 /**1151 * Sets the error information for the current thread, va_list variant.1152 * A convenience method that automatically sets the default interface1153 * ID (taken from the I template argument) and the component name1154 * (a value of C::getComponentName()).1155 *1156 * See #setError(HRESULT, const GUID &, const wchar_t *, const char *text, ...)1157 * and #setError(HRESULT, const char *, ...) for details.1158 */1159 static HRESULT setErrorV(HRESULT aResultCode, const char *aText,1160 va_list aArgs)1161 {1162 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setError(aResultCode,1163 COM_IIDOF(I),1164 C::getComponentName(),1165 aText,1166 aArgs,1167 true /* aLogIt */);1168 return rc;1169 }1170 1171 /**1172 * This method is the same as #setErrorV() except that it makes sure @a1173 * aResultCode doesn't have the error severity bit (31) set when passed1174 * down to the created IVirtualBoxErrorInfo object.1175 *1176 * The error severity bit is always cleared by this call, thereof you can1177 * use ordinary E_XXX result code constants, for convenience. However, this1178 * behavior may be non-standard on some COM platforms.1179 */1180 static HRESULT setWarningV(HRESULT aResultCode, const char *aText,1181 va_list aArgs)1182 {1183 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setWarning(aResultCode,1184 COM_IIDOF(I),1185 C::getComponentName(),1186 aText,1187 aArgs);1188 return rc;1189 }1190 1191 /**1192 * Sets the error information for the current thread.1193 * A convenience method that automatically sets the component name1194 * (a value of C::getComponentName()), but allows to specify the interface1195 * id manually.1196 *1197 * See #setError(HRESULT, const GUID &, const wchar_t *, const char *text, ...)1198 * for details.1199 */1200 static HRESULT setError(HRESULT aResultCode, const GUID &aIID,1201 const char *aText, ...)1202 {1203 va_list args;1204 va_start(args, aText);1205 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setError(aResultCode,1206 aIID,1207 C::getComponentName(),1208 aText,1209 args,1210 true /* aLogIt */);1211 va_end(args);1212 return rc;1213 }1214 1215 /**1216 * This method is the same as #setError() except that it makes sure @a1217 * aResultCode doesn't have the error severity bit (31) set when passed1218 * down to the created IVirtualBoxErrorInfo object.1219 *1220 * The error severity bit is always cleared by this call, thereof you can1221 * use ordinary E_XXX result code constants, for convenience. However, this1222 * behavior may be non-standard on some COM platforms.1223 */1224 static HRESULT setWarning(HRESULT aResultCode, const GUID &aIID,1225 const char *aText, ...)1226 {1227 va_list args;1228 va_start(args, aText);1229 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setWarning(aResultCode,1230 aIID,1231 C::getComponentName(),1232 aText,1233 args);1234 va_end(args);1235 return rc;1236 }1237 1238 /**1239 * Sets the error information for the current thread but doesn't put1240 * anything in the release log. This is very useful for avoiding1241 * harmless error from causing confusion.1242 *1243 * It is otherwise identical to #setError(HRESULT, const char *text, ...).1244 */1245 static HRESULT setErrorNoLog(HRESULT aResultCode, const char *aText, ...)1246 {1247 va_list args;1248 va_start(args, aText);1249 HRESULT rc = VirtualBoxSupportErrorInfoImplBase::setError(aResultCode,1250 COM_IIDOF(I),1251 C::getComponentName(),1252 aText,1253 args,1254 false /* aLogIt */);1255 va_end(args);1256 return rc;1257 }1258 1259 private:1260 1261 };1262 1263 782 1264 783 /** … … 1441 960 1442 961 1443 /// @todo (dmik) remove after we switch to VirtualBoxBaseNEXT completely1444 962 /** 1445 963 * Simple template that manages data structure allocation/deallocation -
trunk/src/VBox/Main/include/VirtualBoxCallbackImpl.h
r30381 r30714 21 21 class ATL_NO_VTABLE CallbackWrapper : 22 22 public VirtualBoxBase, 23 public VirtualBoxSupportErrorInfoImpl<CallbackWrapper, IVirtualBoxCallback>,24 23 public VirtualBoxSupportTranslation<CallbackWrapper>, 25 24 VBOX_SCRIPTABLE_IMPL(ILocalOwner), … … 31 30 { 32 31 public: 32 33 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(CallbackWrapper, IVirtualBoxCallback) 33 34 34 35 DECLARE_CLASSFACTORY() … … 95 96 STDMETHOD(OnShowWindow)(ULONG64 *winId); 96 97 97 // for VirtualBoxSupportErrorInfoImpl98 static const wchar_t *getComponentName() { return L"CallbackWrapper"; }99 100 98 private: 101 99 ComPtr<IVirtualBoxCallback> mVBoxCallback; -
trunk/src/VBox/Main/include/VirtualBoxErrorInfoImpl.h
r30013 r30714 83 83 #endif 84 84 85 VirtualBoxErrorInfo() : mResultCode(S_OK) {} 85 VirtualBoxErrorInfo() 86 : m_resultCode(S_OK) 87 {} 86 88 87 89 // public initializer/uninitializer for internal purposes only 88 HRESULT init(HRESULT aResultCode, const GUID &aIID, 89 CBSTR aComponent, CBSTR aText, 90 HRESULT init(HRESULT aResultCode, 91 const GUID &aIID, 92 const char *pcszComponent, 93 const Utf8Str &strText, 90 94 IVirtualBoxErrorInfo *aNext = NULL); 91 95 … … 106 110 void * /* c */) { return rc; } 107 111 108 HRESULT m ResultCode;109 Bstr mText;110 Guid mIID;111 Bstr mComponent;112 HRESULT m_resultCode; 113 Utf8Str m_strText; 114 Guid m_IID; 115 Utf8Str m_strComponent; 112 116 ComPtr<IVirtualBoxErrorInfo> mNext; 113 117 }; -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r30380 r30714 58 58 class ATL_NO_VTABLE VirtualBox : 59 59 public VirtualBoxBase, 60 public VirtualBoxSupportErrorInfoImpl<VirtualBox, IVirtualBox>,61 60 public VirtualBoxSupportTranslation<VirtualBox>, 62 61 VBOX_SCRIPTABLE_IMPL(IVirtualBox) … … 76 75 friend class CallbackEvent; 77 76 78 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualBox )77 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualBox, IVirtualBox) 79 78 80 79 DECLARE_CLASSFACTORY_SINGLETON(VirtualBox) … … 191 190 192 191 /** 193 * Simple run-time type identification without having to enable C++ RTTI.194 * The class IDs are defined in VirtualBoxBase.h.195 * @return196 */197 virtual VBoxClsID getClassID() const198 {199 return clsidVirtualBox;200 }201 202 /**203 192 * Override of the default locking class to be used for validating lock 204 193 * order with the standard member lock handle. … … 303 292 RWLockHandle& getMediaTreeLockHandle(); 304 293 305 /* for VirtualBoxSupportErrorInfoImpl */306 static const wchar_t *getComponentName() { return L"VirtualBox"; }307 308 294 private: 295 296 static HRESULT setErrorStatic(HRESULT aResultCode, 297 const Utf8Str &aText) 298 { 299 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true); 300 } 309 301 310 302 HRESULT checkMediaForConflicts2(const Guid &aId, const Utf8Str &aLocation, -
trunk/src/VBox/Main/testcase/tstUSBLinux.h
r30269 r30714 39 39 { 40 40 public: 41 USBProxyServiceLinux() : mLastError(VINF_SUCCESS) {} 41 USBProxyServiceLinux() 42 : mLastError(VINF_SUCCESS) 43 {} 44 42 45 HRESULT initSysfs(void); 43 46 PUSBDEVICE getDevicesFromSysfs(void); 44 int getLastError(void) { return mLastError; } 47 int getLastError(void) 48 { 49 return mLastError; 50 } 45 51 46 52 private:
Note:
See TracChangeset
for help on using the changeset viewer.