VirtualBox

Changeset 30714 in vbox


Ignore:
Timestamp:
Jul 7, 2010 4:20:03 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63479
Message:

Main: remove SupportErrorInfo template magic

Location:
trunk
Files:
65 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/SupportErrorInfo.h

    r28800 r30714  
    155155    }
    156156
     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
    157164private:
    158165
     
    164171    static RTTLS sCounter;
    165172
    166     friend class SupportErrorInfoBase;
    167173    friend class MultiResultRef;
    168174};
     
    202208};
    203209
    204 /**
    205  * The SupportErrorInfoBase template class provides basic error info support.
    206  *
    207  * Basic error info support includes a group of setError() methods to set
    208  * extended error information on the current thread. This support does not
    209  * include all necessary implementation details (for example, implementation of
    210  * the ISupportErrorInfo interface on MS COM) to make the error info support
    211  * fully functional in a target component. These details are provided by the
    212  * SupportErrorInfoDerived class.
    213  *
    214  * This way, this class is intended to be directly inherited only by
    215  * intermediate component base classes that will be then inherited by final
    216  * component classes through the SupportErrorInfoDerived template class. In
    217  * all other cases, the SupportErrorInfoImpl class should be used as a base for
    218  * final component classes instead.
    219  */
    220 class SupportErrorInfoBase
    221 {
    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() variants
    233      * to specify the interface that has defined the error. Must be implemented
    234      * 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 short
    240      * 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 *) but
    247      * interprets the @a aText argument as a RTPrintf-like format string and the
    248      * @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 and
    262      * 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 *) but
    276      * interprets the @a aText argument as a RTPrintf-like format string and
    277      * 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 and
    288      * 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 info
    298      * object (if any) will be preserved by attaching it to the tail of the
    299      * 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 @a
    312      * aIID argument and the return value of the componentName() method as a @a
    313      * aComponent argument.
    314      *
    315      * This method is the most common (and convenient) way to set error
    316      * information from within a component method. The typical usage pattern is:
    317      * <code>
    318      *     return setError (E_FAIL, "Terrible Error");
    319      * </code>
    320      * or
    321      * <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 @a
    334      * aIID argument and the return value of the componentName() method as a @a
    335      * aComponent argument.
    336      *
    337      * This method is the most common (and convenient) way to set warning
    338      * information from within a component method. The typical usage pattern is:
    339      * <code>
    340      *     return setWarning (E_FAIL, "Dangerous warning");
    341      * </code>
    342      * or
    343      * <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_list
    353      * 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_list
    363      * 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 the
    373      * 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 specify
    380      * 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 parts
    390  * of error info support in addition to SupportErrorInfoBase.
    391  *
    392  * These parts include the ISupportErrorInfo implementation on the MS COM
    393  * platform and implementations of mandatory SupportErrorInfoBase virtual
    394  * methods.
    395  *
    396  * On MS COM, the @a C template argument must declare a COM interface map using
    397  * BEGIN_COM_MAP / END_COM_MAP macros and this map must contain a
    398  * COM_INTERFACE_ENTRY(ISupportErrorInfo) definition. All interface entries that
    399  * follow it will be considered to support IErrorInfo, i.e. the
    400  * InterfaceSupportsErrorInfo() implementation will return S_OK for the
    401  * corresponding IIDs.
    402  *
    403  * On all platforms, the @a C template argument must be a subclass of
    404  * SupportErrorInfoBase and also define the following method: <tt>public static
    405  * const char *ComponentName()</tt> that will be used as a value returned by the
    406  * SupportErrorInfoBase::componentName() implementation.
    407  *
    408  * If SupportErrorInfoBase is used as a base for an intermediate component base
    409  * class FooBase then the final component FooFinal that inherits FooBase should
    410  * 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 should
    419  * 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 B
    428 #if !defined (VBOX_WITH_XPCOM)
    429     , public ISupportErrorInfo
    430 #endif
    431 {
    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             else
    454             {
    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 support
    478  * for COM component classes.
    479  *
    480  * Complete error info support includes what both SupportErrorInfoBase and
    481  * SupportErrorInfoDerived provide, e.g. a variety of setError() methods to
    482  * set extended error information from within a component's method
    483  * implementation and all necessary additional interface implementations (see
    484  * descriptions of these classes for details).
    485  *
    486  * To add error info support to a Foo component that implements a IFoo
    487  * 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 the
    500  * 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 SupportErrorInfoImpl
    508     : public SupportErrorInfoDerived <SupportErrorInfoBase, C, I>
    509 {
    510 };
    511210
    512211} /* namespace com */
  • trunk/include/VBox/com/VirtualBoxErrorInfo.h

    r28800 r30714  
    144144
    145145    // IVirtualBoxErrorInfo properties
    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)
     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)
    150150    STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext);
    151151
  • trunk/include/VBox/com/defs.h

    r30681 r30714  
    225225 *  @param i    interface class
    226226 */
    227 #define COM_IIDOF(I) _ATL_IIDOF (I)
     227#define COM_IIDOF(I) _ATL_IIDOF(I)
    228228
    229229#else /* defined (RT_OS_WINDOWS) */
     
    349349#define STDMETHODIMP NS_IMETHODIMP
    350350
    351 #define COM_IIDOF(I) NS_GET_IID (I)
     351#define COM_IIDOF(I) NS_GET_IID(I)
    352352
    353353/* A few very simple ATL emulator classes to provide
  • trunk/src/VBox/Frontends/VBoxBFE/VirtualBoxBase.h

    r28800 r30714  
    277277    cls::cls () {}; cls::~cls () {};
    278278
    279 #define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls)
     279#define VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(cls, iface)
    280280
    281281////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r30681 r30714  
    538538 * @return
    539539 */
    540 bool Appliance::isApplianceIdle() const
     540bool Appliance::isApplianceIdle()
    541541{
    542542    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"));
    544544    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"));
    546546    else
    547547        return true;
     
    864864}
    865865
    866 void Appliance::parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const
     866void Appliance::parseBucket(Utf8Str &aPath, Utf8Str &aBucket)
    867867{
    868868    /* Buckets are S3 specific. So parse the bucket out of the file path */
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r30629 r30714  
    12691269    if (RT_FAILURE(vrc))
    12701270        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);
    12731273
    12741274    mSavedStateDataLoaded = true;
     
    15161516    if (VERR_BUFFER_OVERFLOW == vrc)
    15171517        return setError(E_UNEXPECTED,
    1518             tr("Temporary failure due to guest activity, please retry"));
     1518                        tr("Temporary failure due to guest activity, please retry"));
    15191519
    15201520    /*
     
    18711871        /** @todo r=bird: This should be allowed on paused VMs as well. Later.  */
    18721872       )
    1873         return setError(VBOX_E_INVALID_VM_STATE,
    1874             tr("Invalid machine state: %s"),
    1875             Global::stringifyMachineState(mMachineState));
     1873        return setInvalidMachineStateError();
    18761874
    18771875    /* protect mpVM */
     
    18861884    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
    18871885        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);
    18901888
    18911889    LogFlowThisFunc(("mMachineState=%d, rc=%08X\n", mMachineState, rc));
     
    19221920        && mMachineState != MachineState_LiveSnapshotting
    19231921       )
    1924         return setError(VBOX_E_INVALID_VM_STATE,
    1925             tr("Invalid machine state: %s"),
    1926             Global::stringifyMachineState(mMachineState));
     1922        return setInvalidMachineStateError();
    19271923
    19281924    /* protect mpVM */
     
    20772073        /** @todo r=bird: This should be allowed on paused VMs as well. Later.  */
    20782074       )
    2079         return setError(VBOX_E_INVALID_VM_STATE,
    2080             tr("Invalid machine state: %s"),
    2081             Global::stringifyMachineState(mMachineState));
     2075        return setInvalidMachineStateError();
    20822076
    20832077    /* protect mpVM */
     
    21182112    rc = RT_SUCCESS(vrc) ? S_OK :
    21192113        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);
    21222116
    21232117    if (RT_SUCCESS(vrc))
     
    21602154
    21612155        default:
    2162             return setError(VBOX_E_INVALID_VM_STATE,
    2163                             tr("Invalid machine state: %s"),
    2164                             Global::stringifyMachineState(mMachineState));
     2156            return setInvalidMachineStateError();
    21652157    }
    21662158
     
    21962188    if (mMachineState != MachineState_Paused)
    21972189        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));
    22002192
    22012193    /* protect mpVM */
     
    22162208    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
    22172209        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);
    22202212
    22212213    LogFlowThisFunc(("rc=%08X\n", rc));
     
    22372229        && mMachineState != MachineState_LiveSnapshotting
    22382230       )
    2239         return setError(VBOX_E_INVALID_VM_STATE,
    2240             tr("Invalid machine state: %s"),
    2241             Global::stringifyMachineState(mMachineState));
     2231        return setInvalidMachineStateError();
    22422232
    22432233    /* protect mpVM */
     
    22562246    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
    22572247        setError(VBOX_E_PDM_ERROR,
    2258             tr("Controlled power off failed (%Rrc)"),
    2259             vrc);
     2248                 tr("Controlled power off failed (%Rrc)"),
     2249                 vrc);
    22602250
    22612251    LogFlowThisFunc(("rc=%08X\n", rc));
     
    22802270        && mMachineState != MachineState_LiveSnapshotting
    22812271       )
    2282         return setError(VBOX_E_INVALID_VM_STATE,
    2283             tr("Invalid machine state: %s"),
    2284             Global::stringifyMachineState(mMachineState));
     2272        return setInvalidMachineStateError();
    22852273
    22862274    /* protect mpVM */
     
    23602348
    23612349    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();
    23652351
    23662352    /* protect mpVM */
     
    32033189/////////////////////////////////////////////////////////////////////////////
    32043190
     3191/*static*/
     3192HRESULT 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
     3206HRESULT 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
     3211HRESULT Console::setInvalidMachineStateError()
     3212{
     3213    return setError(VBOX_E_INVALID_VM_STATE,
     3214                    tr("Invalid machine state: %s"),
     3215                    Global::stringifyMachineState(mMachineState));
     3216}
     3217
     3218
    32053219/**
    32063220 * @copydoc VirtualBox::handleUnexpectedExceptions
     
    32163230    catch (const std::exception &err)
    32173231    {
    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);
    32213236    }
    32223237    catch (...)
    32233238    {
    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);
    32263242    }
    32273243
     
    34703486
    34713487        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*/);
    34733494
    34743495        default:
     
    45514572
    45524573        default:
    4553             return setError(VBOX_E_INVALID_VM_STATE,
    4554                             tr("Invalid machine state: %s"),
    4555                             Global::stringifyMachineState(mMachineState));
     4574            return setInvalidMachineStateError();
    45564575    }
    45574576
     
    74757494            LogRel(("Failed to launch VRDP server (%Rrc), error message: '%s'\n",
    74767495                     vrc, errMsg.raw()));
    7477             throw setError(E_FAIL, errMsg.c_str());
     7496            throw setErrorStatic(E_FAIL, errMsg.c_str());
    74787497        }
    74797498
     
    76777696            /* Set the error message as the COM error.
    76787697             * 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());
    76807699        }
    76817700    }
     
    79127931            alock.enter();
    79137932            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);
    79177936
    79187937            pTask->mProgress->setCancelCallback(NULL, NULL);
    79197938            if (!pTask->mProgress->notifyPointOfNoReturn())
    7920                 throw setError(E_FAIL, tr("Cancelled"));
     7939                throw setErrorStatic(E_FAIL, tr("Cancelled"));
    79217940            that->mptrCancelableProgress.setNull();
    79227941
     
    79928011                                      &rc);
    79938012                if (RT_FAILURE(vrc))
    7994                     throw setError(E_FAIL, Console::tr("%Rrc"), vrc);
     8013                    throw setErrorStatic(E_FAIL, Console::tr("%Rrc"), vrc);
    79958014                if (FAILED(rc))
    79968015                    throw rc;
     
    80508069                if (RT_FAILURE(vrc))
    80518070                {
    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);
    80538072                    pTask->mProgress->notifyComplete(rc);
    80548073                    if (that->mMachineState == MachineState_Saving)
     
    82108229            task->mProgress->notifyComplete(rc,
    82118230                                            COM_IIDOF(IConsole),
    8212                                             (CBSTR)Console::getComponentName(),
     8231                                            Console::getStaticComponentName(),
    82138232                                            errMsg.c_str());
    82148233        else
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r30681 r30714  
    15131513        if (RT_FAILURE(rc))
    15141514        {
    1515             mConsole->reportAuthLibraryError(filename.raw(), rc);
     1515            mConsole->setAuthLibraryError(filename.raw(), rc);
    15161516
    15171517            mpfnAuthEntry = NULL;
  • trunk/src/VBox/Main/EventImpl.cpp

    r30706 r30714  
    6666{
    6767    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)
    7372    {}
     73
    7474    VBoxEventType_T         mType;
    7575    RTSEMEVENT              mWaitEvent;
     
    9595}
    9696
    97 
    9897HRESULT VBoxEvent::init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable)
    9998{
     
    113112        if (aWaitable)
    114113        {
    115             int vrc = ::RTSemEventCreate (&m->mWaitEvent);
     114            int vrc = ::RTSemEventCreate(&m->mWaitEvent);
    116115
    117116            if (RT_FAILURE(vrc))
     
    915914class ATL_NO_VTABLE PassiveEventListener :
    916915    public VirtualBoxBase,
    917     public VirtualBoxSupportErrorInfoImpl<PassiveEventListener, IEventListener>,
    918916    public VirtualBoxSupportTranslation<PassiveEventListener>,
    919917    VBOX_SCRIPTABLE_IMPL(IEventListener)
     
    921919public:
    922920
    923     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PassiveEventListener)
     921    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PassiveEventListener, IEventListener)
    924922
    925923    DECLARE_NOT_AGGREGATABLE(PassiveEventListener)
     
    951949                        E_FAIL);
    952950    }
    953     // for VirtualBoxSupportErrorInfoImpl
    954     static const wchar_t *getComponentName() { return L"PassiveEventListener"; }
    955951};
    956952
  • trunk/src/VBox/Main/GuestImpl.cpp

    r30662 r30714  
    650650                || fCancelled) /* If cancelled we have to report E_FAIL! */
    651651            {
    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());
    654656                AssertComRC(hr2);
    655657                LogFlowFunc(("Process (context ID=%u, status=%u) reported error: %s\n",
     
    705707        if (SUCCEEDED(it->second.pProgress->COMGETTER(Canceled)(&fCancelled)) && fCancelled)
    706708        {
    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"));
    709713        }
    710714        else
     
    783787             * progress object to become signalled.
    784788             */
    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"));
    787793        }
    788794        /*
  • trunk/src/VBox/Main/HostImpl.cpp

    r30377 r30714  
    227227    m->pUSBProxyService = new USBProxyServiceLinux(this);
    228228# elif defined (RT_OS_OS2)
    229     m->pUSBProxyService = new USBProxyServiceOs2 (this);
     229    m->pUSBProxyService = new USBProxyServiceOs2(this);
    230230# elif defined (RT_OS_SOLARIS)
    231231    m->pUSBProxyService = new USBProxyServiceSolaris(this);
     
    13951395    }
    13961396
    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);
    14001400
    14011401#else   /* !VBOX_WITH_USB */
     
    23022302
    23032303        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());
    23082307        if (m->pUSBProxyService->getLastError() == VINF_SUCCESS)
    23092308#ifdef RT_OS_LINUX
  • trunk/src/VBox/Main/MachineImpl.cpp

    r30632 r30714  
    626626HRESULT Machine::registeredInit()
    627627{
    628     AssertReturn(getClassID() == clsidMachine, E_FAIL);
     628    AssertReturn(!isSessionMachine(), E_FAIL);
     629    AssertReturn(!isSnapshotMachine(), E_FAIL);
    629630    AssertReturn(!mData->mUuid.isEmpty(), E_FAIL);
    630631    AssertReturn(!mData->mAccessible, E_FAIL);
     
    726727        return;
    727728
    728     Assert(getClassID() == clsidMachine);
     729    Assert(!isSnapshotMachine());
     730    Assert(!isSessionMachine());
    729731    Assert(!!mData);
    730732
     
    881883        errorInfo->init(mData->mAccessError.getResultCode(),
    882884                        mData->mAccessError.getInterfaceID(),
    883                         mData->mAccessError.getComponent(),
    884                         mData->mAccessError.getText());
     885                        Utf8Str(mData->mAccessError.getComponent()).c_str(),
     886                        Utf8Str(mData->mAccessError.getText()));
    885887        rc = errorInfo.queryInterfaceTo(aAccessError);
    886888    }
     
    24222424    if (    aEnabled
    24232425        &&  mData->mRegistered
    2424         &&  (   getClassID() != clsidSessionMachine
     2426        &&  (   !isSessionMachine()
    24252427             || (   mData->mMachineState != MachineState_PoweredOff
    24262428                 && mData->mMachineState != MachineState_Teleported
     
    25612563    if (    aEnabled
    25622564        &&  mData->mRegistered
    2563         &&  (   getClassID() != clsidSessionMachine
     2565        &&  (   !isSessionMachine()
    25642566             || (   mData->mMachineState != MachineState_PoweredOff
    25652567                 && mData->mMachineState != MachineState_Teleported
     
    36413643        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    36423644
    3643         if (getClassID() == clsidSnapshotMachine)
     3645        if (isSnapshotMachine())
    36443646        {
    36453647            HRESULT rc = checkStateDependency(MutableStateDep);
     
    61626164        {
    61636165            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) */
    61656167                    || (   mData->mMachineState != MachineState_Paused
    61666168                        && mData->mMachineState != MachineState_Running
     
    61796181        {
    61806182            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) */
    61826184                    || (   mData->mMachineState != MachineState_Paused
    61836185                        && mData->mMachineState != MachineState_Running
     
    63526354     * disk attachments will already be uninitialized and deleted, so this
    63536355     * code will not affect them. */
    6354     VBoxClsID clsid = getClassID();
    63556356    if (    !!mMediaData
    6356          && (clsid == clsidMachine || clsid == clsidSnapshotMachine)
     6357         && (!isSessionMachine())
    63576358       )
    63586359    {
     
    63696370    }
    63706371
    6371     if (getClassID() == clsidMachine)
     6372    if (!isSessionMachine() && !isSnapshotMachine())
    63726373    {
    63736374        // clean up the snapshots list (Snapshot::uninit() will handle the snapshot's children recursively)
     
    64046405Machine* Machine::getMachine()
    64056406{
    6406     if (getClassID() == clsidSessionMachine)
     6407    if (isSessionMachine())
    64076408        return (Machine*)mPeer;
    64086409    return this;
     
    66536654                              Snapshot *aParentSnapshot)
    66546655{
    6655     AssertReturn(getClassID() == clsidMachine, E_FAIL);
     6656    AssertReturn(!isSnapshotMachine(), E_FAIL);
     6657    AssertReturn(!isSessionMachine(), E_FAIL);
    66566658
    66576659    HRESULT rc = S_OK;
     
    67246726HRESULT Machine::loadHardware(const settings::Hardware &data)
    67256727{
    6726     AssertReturn(getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL);
     6728    AssertReturn(!isSessionMachine(), E_FAIL);
    67276729
    67286730    HRESULT rc = S_OK;
     
    69316933                                        const Guid *aSnapshotId /* = NULL */)
    69326934{
    6933     AssertReturn(getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL);
     6935    AssertReturn(!isSessionMachine(), E_FAIL);
    69346936
    69356937    HRESULT rc = S_OK;
     
    70007002                                    const Guid *aSnapshotId /*= NULL*/)
    70017003{
    7002     AssertReturn(   (getClassID() == clsidMachine && aSnapshotId == NULL)
    7003                  || (getClassID() == clsidSnapshotMachine && aSnapshotId != NULL),
    7004                  E_FAIL);
    7005 
    70067004    HRESULT rc = S_OK;
    70077005
     
    70967094                if (FAILED(rc))
    70977095                {
    7098                     VBoxClsID clsid = getClassID();
    7099                     if (clsid == clsidSnapshotMachine)
     7096                    if (isSnapshotMachine())
    71007097                    {
    71017098                        // wrap another error message around the "cannot find hard disk" set by findHardDisk
     
    71157112                if (medium->getType() == MediumType_Immutable)
    71167113                {
    7117                     if (getClassID() == clsidSnapshotMachine)
     7114                    if (isSnapshotMachine())
    71187115                        return setError(E_FAIL,
    71197116                                        tr("Immutable hard disk '%s' with UUID {%RTuuid} cannot be directly attached to snapshot with UUID {%RTuuid} "
     
    71337130                }
    71347131
    7135                 if (    getClassID() != clsidSnapshotMachine
     7132                if (    !isSnapshotMachine()
    71367133                     && medium->getChildren().size() != 0
    71377134                   )
     
    71837180        if (!medium.isNull())
    71847181        {
    7185             if (getClassID() == clsidSnapshotMachine)
     7182            if (isSnapshotMachine())
    71867183                rc = medium->attachTo(mData->mUuid, *aSnapshotId);
    71877184            else
     
    75657562    ensureNoStateDependencies();
    75667563
    7567     AssertReturn(    getClassID() == clsidMachine
    7568                   || getClassID() == clsidSessionMachine,
     7564    AssertReturn(!isSnapshotMachine(),
    75697565                 E_FAIL);
    75707566
     
    76557651         * to the client process that creates them) and thus don't need to
    76567652         * inform callbacks. */
    7657         if (getClassID() == clsidSessionMachine)
     7653        if (isSessionMachine())
    76587654            mParent->onMachineDataChange(mData->mUuid);
    76597655    }
     
    83978393    if (FAILED(rc))
    83988394    {
    8399         MultiResultRef mrc(rc);
     8395        MultiResult mrc = rc;
    84008396
    84018397        mrc = deleteImplicitDiffs(pfNeedsSaveSettings);
     
    87448740    mMediaData.commit();
    87458741
    8746     if (getClassID() == clsidSessionMachine)
     8742    if (isSessionMachine())
    87478743    {
    87488744        /* attach new data to the primary machine and reshare it */
     
    90959091    }
    90969092
    9097     if (getClassID() == clsidSessionMachine)
     9093    if (isSessionMachine())
    90989094    {
    90999095        /* attach new data to the primary machine and reshare it */
     
    91209116void Machine::copyFrom(Machine *aThat)
    91219117{
    9122     AssertReturnVoid(getClassID() == clsidMachine || getClassID() == clsidSessionMachine);
    9123     AssertReturnVoid(aThat->getClassID() == clsidSnapshotMachine);
     9118    AssertReturnVoid(!isSnapshotMachine());
     9119    AssertReturnVoid(aThat->isSnapshotMachine());
    91249120
    91259121    AssertReturnVoid(!Global::IsOnline(mData->mMachineState));
  • trunk/src/VBox/Main/MediumImpl.cpp

    r30681 r30714  
    865865        {
    866866            Assert(!m->strLastAccessError.isEmpty());
    867             rc = setError(E_FAIL, m->strLastAccessError.c_str());
     867            rc = setError(E_FAIL, "%s", m->strLastAccessError.c_str());
    868868        }
    869869        else
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r30681 r30714  
    104104 * @return              COM result indicator.
    105105 */
    106 HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan,
     106HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan,
    107107#if !defined (VBOX_COM_INPROC)
    108                             VirtualBox *aParent,
     108                                    VirtualBox *aParent,
    109109#endif
    110                             IUnknown *aInitiator,
    111                             CBSTR aDescription, OUT_GUID aId /* = NULL */)
     110                                    IUnknown *aInitiator,
     111                                    CBSTR aDescription,
     112                                    OUT_GUID aId /* = NULL */)
    112113{
    113114    /* Guarantees subclasses call this method at the proper time */
     
    532533// public methods only for internal purposes
    533534////////////////////////////////////////////////////////////////////////////////
    534 
    535 /**
    536  * Sets the error info stored in the given progress object as the error info on
    537  * the current thread.
    538  *
    539  * This method is useful if some other COM method uses IProgress to wait for
    540  * something and then wants to return a failed result of the operation it was
    541  * waiting for as its own result retaining the extended error info.
    542  *
    543  * If the operation tracked by this progress object is completed successfully
    544  * and returned S_OK, this method does nothing but returns S_OK. Otherwise, the
    545  * failed warning or error result code specified at progress completion is
    546  * returned and the extended error info object (if any) is set on the current
    547  * thread.
    548  *
    549  * Note that the given progress object must be completed, otherwise this method
    550  * 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 }
    574535
    575536/**
     
    11541115HRESULT Progress::notifyComplete(HRESULT aResultCode,
    11551116                                 const GUID &aIID,
    1156                                  const Bstr &aComponent,
     1117                                 const char *pcszComponent,
    11571118                                 const char *aText,
    11581119                                 ...)
     
    11601121    va_list va;
    11611122    va_start(va, aText);
    1162     HRESULT hrc = notifyCompleteV(aResultCode, aIID, aComponent, aText, va);
     1123    HRESULT hrc = notifyCompleteV(aResultCode, aIID, pcszComponent, aText, va);
    11631124    va_end(va);
    11641125    return hrc;
     
    11801141HRESULT Progress::notifyCompleteV(HRESULT aResultCode,
    11811142                                  const GUID &aIID,
    1182                                   const Bstr &aComponent,
     1143                                  const char *pcszComponent,
    11831144                                  const char *aText,
    11841145                                  va_list va)
     
    12061167    if (SUCCEEDED(rc))
    12071168    {
    1208         errorInfo->init(aResultCode, aIID, aComponent, Bstr(text));
     1169        errorInfo->init(aResultCode, aIID, pcszComponent, text);
    12091170        errorInfo.queryInterfaceTo(mErrorInfo.asOutParam());
    12101171    }
  • trunk/src/VBox/Main/ProgressProxyImpl.cpp

    r30632 r30714  
    164164HRESULT ProgressProxy::notifyComplete(HRESULT aResultCode,
    165165                                      const GUID &aIID,
    166                                       const Bstr &aComponent,
     166                                      const char *pcszComponent,
    167167                                      const char *aText,
    168168                                      ...)
     
    176176        va_list va;
    177177        va_start(va, aText);
    178         hrc = Progress::notifyCompleteV(aResultCode, aIID, aComponent, aText, va);
     178        hrc = Progress::notifyCompleteV(aResultCode, aIID, pcszComponent, aText, va);
    179179        va_end(va);
    180180    }
     
    372372                        Utf8Str strText(bstrText);
    373373                        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());
    375378                    }
    376379                    else
    377380                    {
    378381                        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",
    380385                                                 tr("No error info"));
    381386                    }
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r30111 r30714  
    228228                {
    229229                    /* inform AutoUninitSpan ctor there are no more callers */
    230                     RTSemEventSignal (mZeroCallersSem);
     230                    RTSemEventSignal(mZeroCallersSem);
    231231                }
    232232            }
     
    236236    if (aState)
    237237        *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    }
    238246
    239247    return rc;
     
    284292    AssertMsgFailed (("mState = %d!", mState));
    285293}
    286 
    287 ////////////////////////////////////////////////////////////////////////////////
    288 //
    289 // AutoInitSpan methods
    290 //
    291 ////////////////////////////////////////////////////////////////////////////////
    292 
    293 /**
    294  * Creates a smart initialization span object that places the object to
    295  * InInit state.
    296  *
    297  * Please see the AutoInitSpan class description for more info.
    298  *
    299  * @param aObj      |this| pointer of the managed VirtualBoxBase object whose
    300  *                  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 the
    321  * initialization succeeded or partly succeeded, or places it to InitFailed
    322  * 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 (created
    341          * 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     else
    350     if (mResult == Limited)
    351     {
    352         mObj->setState(VirtualBoxBase::Limited);
    353     }
    354     else
    355     {
    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 call
    362          * the destructor in uninit()) */
    363     }
    364 }
    365 
    366 // AutoReinitSpan methods
    367 ////////////////////////////////////////////////////////////////////////////////
    368 
    369 /**
    370  * Creates a smart re-initialization span object and places the object to
    371  * InInit state.
    372  *
    373  * Please see the AutoInitSpan class description for more info.
    374  *
    375  * @param aObj      |this| pointer of the managed VirtualBoxBase object whose
    376  *                  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 the
    395  * re-initialization succeeded (i.e. #setSucceeded() has been called) or back to
    396  * 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 (created
    413          * 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     else
    422     {
    423         mObj->setState(VirtualBoxBase::Limited);
    424     }
    425 }
    426 
    427 // AutoUninitSpan methods
    428 ////////////////////////////////////////////////////////////////////////////////
    429 
    430 /**
    431  * Creates a smart uninitialization span object and places this object to
    432  * 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 of
    437  *       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 uninitialized
    454      * (NotReady) or if another AutoUninitSpan is currently active on some
    455      *  other thread (InUninit). */
    456     mUninitDone =    mObj->mState == VirtualBoxBase::NotReady
    457                   || 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     else
    465     {
    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, the
    474              * object is NotReady and therefore can be deleted (for example).
    475              * In particular, this is used by
    476              * 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 // VirtualBoxBase
    542 //
    543 ////////////////////////////////////////////////////////////////////////////////
    544294
    545295/**
     
    563313 */
    564314// static
    565 const char *VirtualBoxBase::translate (const char * /* context */, const char *sourceText,
    566                                        const char * /* comment */)
     315const char *VirtualBoxBase::translate(const char * /* context */, const char *sourceText,
     316                                      const char * /* comment */)
    567317{
    568318#if 0
     
    578328}
    579329
    580 ////////////////////////////////////////////////////////////////////////////////
    581 //
    582 // VirtualBoxSupportTranslationBase
    583 //
    584 ////////////////////////////////////////////////////////////////////////////////
    585 
    586 /**
    587  *  Modifies the given argument so that it will contain only a class name
    588  *  (null-terminated). The argument must point to a <b>non-constant</b>
    589  *  string containing a valid value, as it is generated by the
    590  *  __PRETTY_FUNCTION__ built-in macro of the GCC compiler, or by the
    591  *  __FUNCTION__ macro of any other compiler.
    592  *
    593  *  The function assumes that the macro is used within the member of the
    594  *  class derived from the VirtualBoxSupportTranslation<> template.
    595  *
    596  *  @param prettyFunctionName   string to modify
    597  *  @return
    598  *      true on success and false otherwise
    599  */
    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>::__ctor
    618 
    619     #define START "<class "
    620     #define END   ">::"
    621 
    622 #endif
    623 
    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 END
    641     #undef START
    642 
    643     return false;
    644 }
    645 
    646 ////////////////////////////////////////////////////////////////////////////////
    647 //
    648 // VirtualBoxSupportErrorInfoImplBase
    649 //
    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 
    675330/**
    676331 *  Sets error info for the current thread. This is an internal function that
     
    682337 */
    683338/* static */
    684 HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal(HRESULT aResultCode,
    685                                                              const GUID &aIID,
    686                                                              const wchar_t *aComponent,
    687                                                              const Bstr &aText,
    688                                                              bool aWarning,
    689                                                              bool aLogIt)
     339HRESULT VirtualBoxBase::setErrorInternal(HRESULT aResultCode,
     340                                         const GUID &aIID,
     341                                         const char *pcszComponent,
     342                                         const Utf8Str &aText,
     343                                         bool aWarning,
     344                                         bool aLogIt)
    690345{
    691346    /* 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();
    695348
    696349    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,
    700357                preserve));
    701358
     
    746403
    747404        /* 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);
    749406        if (FAILED(rc)) break;
    750407
     
    790447
    791448            /* 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);
    793450            if (FAILED(rc)) break;
    794451
     
    809466             *  set the exception (nobody will be able to read it).
    810467             */
    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"));
    815470            rc = NS_OK;
    816471        }
     
    825480}
    826481
     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 */
     491HRESULT 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 */
     511HRESULT 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 */
     531HRESULT 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 */
     561AutoInitSpan::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 */
     584AutoInitSpan::~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 */
     636AutoReinitSpan::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 */
     658AutoReinitSpan::~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 */
     700AutoUninitSpan::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 */
     784AutoUninitSpan::~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 */
     817bool 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////////////////////////////////////////////////////////////////////////////////
    827868
    828869/**
  • trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp

    r28800 r30714  
    2222////////////////////////////////////////////////////////////////////////////////
    2323
    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;
     24HRESULT 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;
    3234    mNext = aNext;
    3335
     
    4244    CheckComArgOutPointerValid(aResultCode);
    4345
    44     *aResultCode = mResultCode;
     46    *aResultCode = m_resultCode;
    4547    return S_OK;
    4648}
     
    5052    CheckComArgOutPointerValid(aIID);
    5153
    52     mIID.toUtf16().cloneTo(aIID);
     54    m_IID.toUtf16().cloneTo(aIID);
    5355    return S_OK;
    5456}
     
    5860    CheckComArgOutPointerValid(aComponent);
    5961
    60     mComponent.cloneTo(aComponent);
     62    m_strComponent.cloneTo(aComponent);
    6163    return S_OK;
    6264}
     
    6668    CheckComArgOutPointerValid(aText);
    6769
    68     mText.cloneTo(aText);
     70    m_strText.cloneTo(aText);
    6971    return S_OK;
    7072}
     
    9496     * corresponding fields will simply remain null in this case). */
    9597
    96     mResultCode = S_OK;
    97     rc = aInfo->GetGUID (mIID.asOutParam());
     98    m_resultCode = S_OK;
     99    rc = aInfo->GetGUID(m_IID.asOutParam());
    98100    AssertComRC (rc);
    99     rc = aInfo->GetSource (mComponent.asOutParam());
     101    Bstr bstrComponent;
     102    rc = aInfo->GetSource(bstrComponent.asOutParam());
    100103    AssertComRC (rc);
    101     rc = aInfo->GetDescription (mText.asOutParam());
     104    m_strComponent = bstrComponent;
     105    Bstr bstrText;
     106    rc = aInfo->GetDescription(bstrText.asOutParam());
    102107    AssertComRC (rc);
     108    m_strText = bstrText;
    103109
    104110    return S_OK;
     
    153159     * corresponding fields will simply remain null in this case). */
    154160
    155     rc = aInfo->GetResult(&mResultCode);
     161    rc = aInfo->GetResult(&m_resultCode);
    156162    AssertComRC(rc);
    157163
     
    161167    if (NS_SUCCEEDED(rc))
    162168    {
    163         mText = Bstr(pszMsg);
     169        m_strText = pszMsg;
    164170        nsMemory::Free(pszMsg);
    165171    }
    166172    else
    167         mText.setNull();
     173        m_strText.setNull();
    168174
    169175    return S_OK;
     
    178184    CheckComArgOutPointerValid(aMessage);
    179185
    180     Utf8Str (mText).cloneTo(aMessage);
     186    m_strText.cloneTo(aMessage);
    181187    return S_OK;
    182188}
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r30591 r30714  
    23962396    LogFlowFuncEnter();
    23972397
    2398     std::auto_ptr <StartSVCHelperClientData>
    2399         d(static_cast <StartSVCHelperClientData *>(aUser));
     2398    std::auto_ptr<StartSVCHelperClientData>
     2399        d(static_cast<StartSVCHelperClientData*>(aUser));
    24002400
    24012401    HRESULT rc = S_OK;
     
    24252425        if (RT_FAILURE(vrc))
    24262426        {
    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);
    24292429            break;
    24302430        }
     
    24672467                 * (pressing the Cancel button to close the Run As dialog) */
    24682468                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"));
    24712471                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);
    24752475                break;
    24762476            }
     
    24822482            if (RT_FAILURE(vrc))
    24832483            {
    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);
    24862486                break;
    24872487            }
     
    25062506        if (SUCCEEDED(rc) && RT_FAILURE(vrc))
    25072507        {
    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);
    25102510            break;
    25112511        }
     
    40404040        int vrc = RTDirCreateFullPath(strDir.c_str(), 0777);
    40414041        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));
    40464046    }
    40474047
     
    40814081    catch (const xml::Error &err)
    40824082    {
    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());
    40864087    }
    40874088    catch (const std::exception &err)
    40884089    {
    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());
    40924094    }
    40934095    catch (...)
    40944096    {
    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());
    40974100    }
    40984101
  • trunk/src/VBox/Main/generic/NetIf-generic.cpp

    r28800 r30714  
    149149            if (RT_FAILURE(rc))
    150150            {
    151                 progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(),
     151                progress->notifyComplete(E_FAIL,
     152                                         COM_IIDOF(IHostNetworkInterface),
     153                                         HostNetworkInterface::getStaticComponentName(),
    152154                                         "Failed to get program path, rc=%Rrc\n", rc);
    153155                return rc;
     
    176178                        if (RT_FAILURE(rc))
    177179                        {
    178                             progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(),
     180                            progress->notifyComplete(E_FAIL,
     181                                                     COM_IIDOF(IHostNetworkInterface),
     182                                                     HostNetworkInterface::getStaticComponentName(),
    179183                                                     "Failed to get config info for %s (as reported by '" VBOXNETADPCTL_NAME " add')\n", szBuf);
    180184                        }
     
    194198                if ((rc = pclose(fp)) != 0)
    195199                {
    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);
    197204                    rc = VERR_INTERNAL_ERROR;
    198205                }
     
    241248            rc = NetIfAdpCtl(Utf8Str(ifname).c_str(), "remove", NULL, NULL);
    242249            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);
    244254            else
    245255                progress->notifyComplete(S_OK);
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r30683 r30714  
    5454    mText = x.mText;
    5555
    56     if (x.m_pNext)
     56    if (x.m_pNext != NULL)
    5757        m_pNext = new ErrorInfo(x.m_pNext);
    5858    else
     
    258258    {
    259259        m_pNext = new ErrorInfo(next);
    260         Assert(m_pNext);
     260        Assert(m_pNext != NULL);
    261261        if (!m_pNext)
    262262            rc = E_OUTOFMEMORY;
  • trunk/src/VBox/Main/glue/SupportErrorInfo.cpp

    r28800 r30714  
    6363}
    6464
    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*/
     66bool MultiResult::isMultiEnabled()
    10267{
    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;
    36669}
    36770
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r30702 r30714  
    38223822      <desc>
    38233823        Tells VBoxSVC that <link to="IConsole::powerUp"/> has completed.
    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.
     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.
    38283828      </desc>
    38293829      <param name="result" type="long" dir="in"/>
     
    90459045  </interface>
    90469046
    9047 
    90489047  <!--
    90499048  // ISnapshot
  • trunk/src/VBox/Main/idl/comimpl.xsl

    r30627 r30714  
    6767  </xsl:variable>
    6868
    69   <xsl:value-of select="concat('      COM_INTERFACE_ENTRY(', $name, ')&#10;')" />
     69  <xsl:value-of select="concat('        COM_INTERFACE_ENTRY(', $name, ')&#10;')" />
    7070  <xsl:choose>
    7171    <xsl:when test="$extends='$unknown'">
    72       <xsl:value-of select="   '      COM_INTERFACE_ENTRY(IDispatch)&#10;'" />
     72      <xsl:value-of select="   '        COM_INTERFACE_ENTRY(IDispatch)&#10;'" />
    7373    </xsl:when>
    7474    <xsl:when test="//interface[@name=$extends]">
     
    381381    <xsl:value-of select="concat('    ', $mType, '    ', $mName,';&#10;')" />
    382382    <xsl:value-of select="       'public:&#10;'" />
    383     <xsl:value-of select="concat('    STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,') {&#10;')" />
     383    <xsl:value-of select="concat('    STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,')&#10;    {&#10;')" />
    384384    <xsl:call-template name="genRetParam">
    385385      <xsl:with-param name="type" select="@type" />
     
    392392
    393393    <xsl:if test="not(@readonly='yes')">
    394       <xsl:value-of select="concat('    STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,') {&#10;')" />
     394      <xsl:value-of select="concat('    STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,')&#10;    {&#10;')" />
    395395      <xsl:call-template name="genSetParam">
    396396        <xsl:with-param name="type" select="@type" />
     
    404404
    405405    <xsl:value-of select="       '    // purely internal setter&#10;'" />
    406     <xsl:value-of select="concat('    int set_', @name,'(',$pTypeNameIn, ') {&#10;')" />
     406    <xsl:value-of select="concat('    HRESULT set_', @name,'(',$pTypeNameIn, ')&#10;    {&#10;')" />
    407407    <xsl:call-template name="genSetParam">
    408408      <xsl:with-param name="type" select="@type" />
     
    439439
    440440  <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName,
    441                         ' : public VirtualBoxBase, VBOX_SCRIPTABLE_IMPL(',
     441                        '&#10;    : public VirtualBoxBase,&#10;      VBOX_SCRIPTABLE_IMPL(',
    442442                        @name, ')&#10;{&#10;')" />
    443443  <xsl:value-of select="'public:&#10;'" />
    444   <xsl:value-of select="concat('   DECLARE_NOT_AGGREGATABLE(', $implName, ')&#10;')" />
    445   <xsl:value-of select="       '   DECLARE_PROTECT_FINAL_CONSTRUCT()&#10;'" />
    446   <xsl:value-of select="concat('   BEGIN_COM_MAP(', $implName, ')&#10;')" />
     444  <xsl:value-of select="concat('    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', $implName, ', ', @name, ')&#10;')" />
     445  <xsl:value-of select="concat('    DECLARE_NOT_AGGREGATABLE(', $implName, ')&#10;')" />
     446  <xsl:value-of select="       '    DECLARE_PROTECT_FINAL_CONSTRUCT()&#10;'" />
     447  <xsl:value-of select="concat('    BEGIN_COM_MAP(', $implName, ')&#10;')" />
    447448  <xsl:call-template name="genComEntry">
    448449    <xsl:with-param name="name" select="@name" />
    449450  </xsl:call-template>
    450   <xsl:value-of select="       '   END_COM_MAP()&#10;'" />
    451   <xsl:value-of select="concat('   ', $implName, '() {}&#10;')" />
    452   <xsl:value-of select="concat('   virtual ~', $implName, '() {}&#10;')" />
     451  <xsl:value-of select="       '    END_COM_MAP()&#10;'" />
     452  <xsl:value-of select="concat('    ', $implName, '() {}&#10;')" />
     453  <xsl:value-of select="concat('    virtual ~', $implName, '() {}&#10;')" />
    453454  <xsl:text><![CDATA[
    454455    HRESULT FinalConstruct()
     
    456457        return mEvent.createObject();
    457458    }
    458     void FinalRelease() {
     459    void FinalRelease()
     460    {
    459461        mEvent->FinalRelease();
    460462    }
     
    487489    <xsl:when test="$isVeto='yes'">
    488490<xsl:text><![CDATA[
    489     HRESULT init (IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)
     491    HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)
    490492    {
    491493        NOREF(aWaitable);
     
    510512    <xsl:otherwise>
    511513<xsl:text><![CDATA[
    512     HRESULT init (IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable)
     514    HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable)
    513515    {
    514516        return mEvent->init(aSource, aType, aWaitable);
     
    575577  <xsl:for-each select="//interface[@autogen=$G_kind]">
    576578    <xsl:variable name="implName">
    577       <xsl:value-of select="concat(@name,'Impl')" />
     579      <xsl:value-of select="substring(@name, 2)" />
    578580    </xsl:variable>
    579581    <xsl:call-template name="genSwitchCase">
     
    610612    <xsl:value-of select="concat('// ', @name,  ' implementation code &#10;')" />
    611613    <xsl:variable name="implName">
    612       <xsl:value-of select="concat(@name,'Impl')" />
     614      <xsl:value-of select="substring(@name, 2)" />
    613615    </xsl:variable>
    614616
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r29925 r30714  
    4949class ATL_NO_VTABLE Appliance :
    5050    public VirtualBoxBase,
    51     public VirtualBoxSupportErrorInfoImpl<Appliance, IAppliance>,
    5251    public VirtualBoxSupportTranslation<Appliance>,
    5352    VBOX_SCRIPTABLE_IMPL(IAppliance)
    5453{
    5554public:
    56     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
     55    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Appliance, IAppliance)
    5756
    5857    DECLARE_NOT_AGGREGATABLE(Appliance)
     
    8180    HRESULT init(VirtualBox *aVirtualBox);
    8281    void uninit();
    83 
    84     // for VirtualBoxSupportErrorInfoImpl
    85     static const wchar_t *getComponentName() { return L"Appliance"; }
    8682
    8783    /* IAppliance properties */
     
    111107    Data *m;
    112108
    113     bool isApplianceIdle() const;
     109    bool isApplianceIdle();
    114110
    115111    HRESULT searchUniqueVMName(Utf8Str& aName) const;
     
    127123    struct LocationInfo;
    128124    void parseURI(Utf8Str strUri, LocationInfo &locInfo) const;
    129     void parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const;
     125    void parseBucket(Utf8Str &aPath, Utf8Str &aBucket);
    130126    Utf8Str manifestFileName(Utf8Str aPath) const;
    131127
     
    195191class ATL_NO_VTABLE VirtualSystemDescription :
    196192    public VirtualBoxBase,
    197     public VirtualBoxSupportErrorInfoImpl<VirtualSystemDescription, IVirtualSystemDescription>,
    198193    public VirtualBoxSupportTranslation<VirtualSystemDescription>,
    199194    VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
     
    202197
    203198public:
    204     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
     199    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualSystemDescription, IVirtualSystemDescription)
    205200
    206201    DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
     
    222217    HRESULT init();
    223218    void uninit();
    224 
    225     // for VirtualBoxSupportErrorInfoImpl
    226     static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
    227219
    228220    /* IVirtualSystemDescription properties */
  • trunk/src/VBox/Main/include/AudioAdapterImpl.h

    r28800 r30714  
    3030class ATL_NO_VTABLE AudioAdapter :
    3131    public VirtualBoxBase,
    32     public VirtualBoxSupportErrorInfoImpl<AudioAdapter, IAudioAdapter>,
    3332    public VirtualBoxSupportTranslation<AudioAdapter>,
    3433    VBOX_SCRIPTABLE_IMPL(IAudioAdapter)
     
    4544    };
    4645
    47     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (AudioAdapter)
     46    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(AudioAdapter, IAudioAdapter)
    4847
    4948    DECLARE_NOT_AGGREGATABLE(AudioAdapter)
     
    8483    void copyFrom(AudioAdapter *aThat);
    8584
    86     // for VirtualBoxSupportErrorInfoImpl
    87     static const wchar_t *getComponentName() { return L"AudioAdapter"; }
    88 
    8985private:
    9086
  • trunk/src/VBox/Main/include/BIOSSettingsImpl.h

    r28800 r30714  
    3131
    3232class ATL_NO_VTABLE BIOSSettings :
    33     public VirtualBoxSupportErrorInfoImpl<BIOSSettings, IBIOSSettings>,
    3433    public VirtualBoxSupportTranslation<BIOSSettings>,
    3534    public VirtualBoxBase,
     
    3736{
    3837public:
     38    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(BIOSSettings, IBIOSSettings)
     39
    3940    DECLARE_NOT_AGGREGATABLE(BIOSSettings)
    4041
     
    8586    void applyDefaults (GuestOSType *aOsType);
    8687
    87     // for VirtualBoxSupportErrorInfoImpl
    88     static const wchar_t *getComponentName() { return L"BIOSSettings"; }
    89 
    9088private:
    9189    struct Data;
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r30510 r30714  
    8181class ATL_NO_VTABLE Console :
    8282    public VirtualBoxBaseWithChildrenNEXT,
    83     public VirtualBoxSupportErrorInfoImpl<Console, IConsole>,
    8483    public VirtualBoxSupportTranslation<Console>,
    8584    VBOX_SCRIPTABLE_IMPL(IConsole)
     
    9392
    9493public:
     94
     95    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Console, IConsole)
    9596
    9697    DECLARE_NOT_AGGREGATABLE(Console)
     
    240241    static const PDMDRVREG DrvStatusReg;
    241242
    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();
    246246
    247247    static HRESULT handleUnexpectedExceptions(RT_SRC_POS_DECL);
     
    249249    static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
    250250    static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
    251 
    252     // for VirtualBoxSupportErrorInfoImpl
    253     static const wchar_t *getComponentName() { return L"Console"; }
    254251
    255252private:
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r30627 r30714  
    232232class ATL_NO_VTABLE RemoteDisplayInfo :
    233233    public VirtualBoxBase,
    234     public VirtualBoxSupportErrorInfoImpl<RemoteDisplayInfo, IRemoteDisplayInfo>,
    235234    public VirtualBoxSupportTranslation<RemoteDisplayInfo>,
    236235    VBOX_SCRIPTABLE_IMPL(IRemoteDisplayInfo)
     
    238237public:
    239238
    240     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (RemoteDisplayInfo)
     239    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteDisplayInfo, IRemoteDisplayInfo)
    241240
    242241    DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
     
    278277    #undef DECL_GETTER
    279278
    280     /* For VirtualBoxSupportErrorInfoImpl. */
    281     static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
    282 
    283279private:
    284280
  • trunk/src/VBox/Main/include/DHCPServerImpl.h

    r28800 r30714  
    3434class ATL_NO_VTABLE DHCPServer :
    3535    public VirtualBoxBase,
    36     public VirtualBoxSupportErrorInfoImpl<DHCPServer, IDHCPServer>,
    3736    public VirtualBoxSupportTranslation<DHCPServer>,
    3837    VBOX_SCRIPTABLE_IMPL(IDHCPServer)
     
    4039public:
    4140
    42     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (DHCPServer)
     41    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(DHCPServer, IDHCPServer)
    4342
    4443    DECLARE_NOT_AGGREGATABLE (DHCPServer)
     
    7978    STDMETHOD(Stop)();
    8079
    81     // for VirtualBoxSupportErrorInfoImpl
    82     static const wchar_t *getComponentName() { return L"DHCPServer"; }
    83 
    8480private:
    8581    /** weak VirtualBox parent */
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r30627 r30714  
    9494    public VirtualBoxBase,
    9595    VBOX_SCRIPTABLE_IMPL(IEventListener),
    96     public VirtualBoxSupportErrorInfoImpl<Display, IDisplay>,
    9796    public VirtualBoxSupportTranslation<Display>,
    9897    VBOX_SCRIPTABLE_IMPL(IDisplay)
    9998{
    100 
    10199public:
    102100
    103     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)
     101    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Display, IDisplay)
    104102
    105103    DECLARE_NOT_AGGREGATABLE(Display)
     
    165163    STDMETHOD(CompleteVHWACommand)(BYTE *pCommand);
    166164
    167     // for VirtualBoxSupportErrorInfoImpl
    168     static const wchar_t *getComponentName() { return L"Display"; }
    169 
    170165    static const PDMDRVREG  DrvReg;
    171166
  • trunk/src/VBox/Main/include/EventImpl.h

    r30553 r30714  
    2323class ATL_NO_VTABLE VBoxEvent :
    2424    public VirtualBoxBase,
    25     public VirtualBoxSupportErrorInfoImpl<VBoxEvent, IEvent>,
    2625    public VirtualBoxSupportTranslation<VBoxEvent>,
    2726    VBOX_SCRIPTABLE_IMPL(IEvent)
    2827{
    2928public:
    30     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent)
     29    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent, IEvent)
    3130
    3231    DECLARE_NOT_AGGREGATABLE(VBoxEvent)
     
    5958    STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult);
    6059
    61     // for VirtualBoxSupportErrorInfoImpl
    62     static const wchar_t *getComponentName() { return L"Event"; }
    63 
    6460private:
    6561    struct Data;
     
    7369{
    7470public:
    75     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxVetoEvent)
     71    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxVetoEvent, IVetoEvent)
    7672
    7773    DECLARE_NOT_AGGREGATABLE(VBoxVetoEvent)
     
    125121    STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos));
    126122
    127     // for VirtualBoxSupportErrorInfoImpl
    128     static const wchar_t *getComponentName() { return L"VetoEvent"; }
    129 
    130123private:
    131124    struct Data;
     
    136129class ATL_NO_VTABLE EventSource :
    137130    public VirtualBoxBase,
    138     public VirtualBoxSupportErrorInfoImpl<EventSource, IEventSource>,
    139131    public VirtualBoxSupportTranslation<EventSource>,
    140132    VBOX_SCRIPTABLE_IMPL(IEventSource)
     
    142134public:
    143135
    144     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource)
     136    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource, IEventSource)
    145137
    146138    DECLARE_NOT_AGGREGATABLE(EventSource)
     
    178170                              IEvent *         aEvent);
    179171
    180     // for VirtualBoxSupportErrorInfoImpl
    181     static const wchar_t *getComponentName() { return L"EventSource"; }
    182 
    183172private:
    184173    struct Data;
  • trunk/src/VBox/Main/include/FramebufferImpl.h

    r28800 r30714  
    3232public:
    3333
    34     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Framebuffer)
     34    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Framebuffer, IFramebuffer)
    3535
    3636    DECLARE_NOT_AGGREGATABLE (Framebuffer)
  • trunk/src/VBox/Main/include/GuestImpl.h

    r30075 r30714  
    4848
    4949class ATL_NO_VTABLE Guest :
    50     public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
    5150    public VirtualBoxSupportTranslation<Guest>,
    5251    public VirtualBoxBase,
     
    5453{
    5554public:
     55    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest)
    5656
    5757    DECLARE_NOT_AGGREGATABLE(Guest)
     
    109109    HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
    110110
    111     // for VirtualBoxSupportErrorInfoImpl
    112     static const wchar_t *getComponentName() { return L"Guest"; }
    113 
    114111# ifdef VBOX_WITH_GUEST_CONTROL
    115112    /** Static callback for handling guest notifications. */
     
    123120    {
    124121        eVBoxGuestCtrlCallbackType  mType;
    125         /** Pointer to user-supplied data. */       
     122        /** Pointer to user-supplied data. */
    126123        void                       *pvData;
    127124        /** Size of user-supplied data. */
  • trunk/src/VBox/Main/include/GuestOSTypeImpl.h

    r28826 r30714  
    2626class ATL_NO_VTABLE GuestOSType :
    2727    public VirtualBoxBase,
    28     public VirtualBoxSupportErrorInfoImpl<GuestOSType, IGuestOSType>,
    2928    public VirtualBoxSupportTranslation<GuestOSType>,
    3029    VBOX_SCRIPTABLE_IMPL(IGuestOSType)
    3130{
    3231public:
    33 
    34     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (GuestOSType)
     32    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestOSType, IGuestOSType)
    3533
    3634    DECLARE_NOT_AGGREGATABLE(GuestOSType)
     
    9391    uint32_t numSerialEnabled() const { return mNumSerialEnabled; }
    9492
    95     // for VirtualBoxSupportErrorInfoImpl
    96     static const wchar_t *getComponentName() { return L"GuestOSType"; }
    97 
    9893private:
    9994
  • trunk/src/VBox/Main/include/HostImpl.h

    r29615 r30714  
    3636class ATL_NO_VTABLE Host :
    3737    public VirtualBoxBase,
    38     public VirtualBoxSupportErrorInfoImpl<Host, IHost>,
    3938    public VirtualBoxSupportTranslation<Host>,
    4039    VBOX_SCRIPTABLE_IMPL(IHost)
    4140{
    4241public:
     42    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Host, IHost)
    4343
    4444    DECLARE_NOT_AGGREGATABLE(Host)
     
    9898
    9999    /**
    100      * Simple run-time type identification without having to enable C++ RTTI.
    101      * The class IDs are defined in VirtualBoxBase.h.
    102      * @return
    103      */
    104     virtual VBoxClsID getClassID() const
    105     {
    106         return clsidHost;
    107     }
    108 
    109     /**
    110100     * Override of the default locking class to be used for validating lock
    111101     * order with the standard member lock handle.
     
    137127#endif /* !VBOX_WITH_USB */
    138128
    139     // for VirtualBoxSupportErrorInfoImpl
    140     static const wchar_t *getComponentName() { return L"Host"; }
    141 
    142129private:
    143130
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r28800 r30714  
    3232class ATL_NO_VTABLE HostNetworkInterface :
    3333    public VirtualBoxBase,
    34     public VirtualBoxSupportErrorInfoImpl<HostNetworkInterface, IHostNetworkInterface>,
    3534    public VirtualBoxSupportTranslation<HostNetworkInterface>,
    3635    VBOX_SCRIPTABLE_IMPL(IHostNetworkInterface)
     
    3837public:
    3938
    40     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)
     39    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(HostNetworkInterface, IHostNetworkInterface)
    4140
    4241    DECLARE_NOT_AGGREGATABLE (HostNetworkInterface)
     
    8281    STDMETHOD(DhcpRediscover) ();
    8382
    84     // for VirtualBoxSupportErrorInfoImpl
    85     static const wchar_t *getComponentName() { return L"HostNetworkInterface"; }
     83    HRESULT setVirtualBox(VirtualBox *pVBox);
    8684
    87     HRESULT setVirtualBox(VirtualBox *pVBox);
    8885private:
    8986    const Bstr mInterfaceName;
  • trunk/src/VBox/Main/include/KeyboardImpl.h

    r28909 r30714  
    4646class ATL_NO_VTABLE Keyboard :
    4747    public VirtualBoxBase,
    48     public VirtualBoxSupportErrorInfoImpl<Keyboard, IKeyboard>,
    4948    public VirtualBoxSupportTranslation<Keyboard>,
    5049    VBOX_SCRIPTABLE_IMPL(IKeyboard)
    5150{
    52 
    5351public:
    5452
    55     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Keyboard)
     53    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Keyboard, IKeyboard)
    5654
    5755    DECLARE_NOT_AGGREGATABLE(Keyboard)
     
    7876                            ULONG *codesStored);
    7977    STDMETHOD(PutCAD)();
    80 
    81     // for VirtualBoxSupportErrorInfoImpl
    82     static const wchar_t *getComponentName() { return L"Keyboard"; }
    8378
    8479    static const PDMDRVREG  DrvReg;
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r28800 r30714  
    2727class ATL_NO_VTABLE MachineDebugger :
    2828    public VirtualBoxBase,
    29     public VirtualBoxSupportErrorInfoImpl<MachineDebugger, IMachineDebugger>,
    3029    public VirtualBoxSupportTranslation<MachineDebugger>,
    3130    VBOX_SCRIPTABLE_IMPL(IMachineDebugger)
     
    3332public:
    3433
    35     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MachineDebugger)
     34    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MachineDebugger, IMachineDebugger)
    3635
    3736    DECLARE_NOT_AGGREGATABLE (MachineDebugger)
     
    8584    void flushQueuedSettings();
    8685
    87     // for VirtualBoxSupportErrorInfoImpl
    88     static const wchar_t *getComponentName() { return L"MachineDebugger"; }
    89 
    9086private:
    9187    // private methods
  • trunk/src/VBox/Main/include/MachineImpl.h

    r30380 r30714  
    8282class ATL_NO_VTABLE Machine :
    8383    public VirtualBoxBaseWithChildrenNEXT,
    84     public VirtualBoxSupportErrorInfoImpl<Machine, IMachine>,
    8584    public VirtualBoxSupportTranslation<Machine>,
    8685    VBOX_SCRIPTABLE_IMPL(IMachine)
     
    319318    };
    320319
    321     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine)
     320    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine, IMachine)
    322321
    323322    DECLARE_NOT_AGGREGATABLE(Machine)
     
    511510    // public methods only for internal purposes
    512511
    513     /**
    514      * Simple run-time type identification without having to enable C++ RTTI.
    515      * The class IDs are defined in VirtualBoxBase.h.
    516      * @return
    517      */
    518     virtual VBoxClsID getClassID() const
    519     {
    520         return clsidMachine;
     512    virtual bool isSnapshotMachine() const
     513    {
     514        return false;
     515    }
     516
     517    virtual bool isSessionMachine() const
     518    {
     519        return false;
    521520    }
    522521
     
    693692                               BOOL *aRegistered = NULL);
    694693    void releaseStateDependency();
    695 
    696     // for VirtualBoxSupportErrorInfoImpl
    697     static const wchar_t *getComponentName() { return L"Machine"; }
    698694
    699695protected:
     
    926922    // public methods only for internal purposes
    927923
    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;
    936927    }
    937928
     
    11061097    // public methods only for internal purposes
    11071098
    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;
    11161102    }
    11171103
     
    11341120inline const Guid &Machine::getSnapshotId() const
    11351121{
    1136     return getClassID() != clsidSnapshotMachine
    1137                 ? Guid::Empty
    1138                 : static_cast<const SnapshotMachine*>(this)->getSnapshotId();
     1122    return (isSnapshotMachine())
     1123                ? static_cast<const SnapshotMachine*>(this)->getSnapshotId()
     1124                : Guid::Empty;
    11391125}
    11401126
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r28800 r30714  
    2323class ATL_NO_VTABLE MediumAttachment :
    2424    public VirtualBoxBase,
    25     public com::SupportErrorInfoImpl<MediumAttachment, IMediumAttachment>,
    2625    public VirtualBoxSupportTranslation<MediumAttachment>,
    2726    VBOX_SCRIPTABLE_IMPL(IMediumAttachment)
    2827{
    2928public:
     29    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumAttachment, IMediumAttachment)
    3030
    3131    DECLARE_NOT_AGGREGATABLE(MediumAttachment)
     
    9090    const char* getLogName(void) const { return mLogName.c_str(); }
    9191
    92     /** For com::SupportErrorInfoImpl. */
    93     static const char *ComponentName() { return "MediumAttachment"; }
    94 
    9592private:
    9693    struct Data;
  • trunk/src/VBox/Main/include/MediumFormatImpl.h

    r28800 r30714  
    4040class ATL_NO_VTABLE MediumFormat :
    4141    public VirtualBoxBase,
    42     public VirtualBoxSupportErrorInfoImpl<MediumFormat, IMediumFormat>,
    4342    public VirtualBoxSupportTranslation<MediumFormat>,
    4443    VBOX_SCRIPTABLE_IMPL(IMediumFormat)
     
    6968    };
    7069
    71     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (MediumFormat)
     70    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumFormat, IMediumFormat)
    7271
    7372    DECLARE_NOT_AGGREGATABLE (MediumFormat)
     
    117116    const PropertyList &properties() const { return m.properties; }
    118117
    119     // for VirtualBoxSupportErrorInfoImpl
    120     static const wchar_t *getComponentName() { return L"MediumFormat"; }
    121 
    122118private:
    123119
  • trunk/src/VBox/Main/include/MediumImpl.h

    r29325 r30714  
    3939class ATL_NO_VTABLE Medium :
    4040    public VirtualBoxBase,
    41     public com::SupportErrorInfoImpl<Medium, IMedium>,
    4241    public VirtualBoxSupportTranslation<Medium>,
    4342    VBOX_SCRIPTABLE_IMPL(IMedium)
    4443{
    4544public:
    46     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Medium)
     45    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Medium, IMedium)
    4746
    4847    DECLARE_NOT_AGGREGATABLE(Medium)
     
    230229    Bstr preferredDiffFormat();
    231230
    232     /** For com::SupportErrorInfoImpl. */
    233     static const char *ComponentName() { return "Medium"; }
    234 
    235231private:
    236232
  • trunk/src/VBox/Main/include/MouseImpl.h

    r28800 r30714  
    5151#ifndef VBOXBFE_WITHOUT_COM
    5252    ,
    53     public VirtualBoxSupportErrorInfoImpl<Mouse, IMouse>,
    5453    public VirtualBoxSupportTranslation<Mouse>,
    5554    VBOX_SCRIPTABLE_IMPL(IMouse)
     
    5857public:
    5958
    60     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Mouse)
     59    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Mouse, IMouse)
    6160
    6261    DECLARE_NOT_AGGREGATABLE(Mouse)
     
    8988    STDMETHOD(PutMouseEventAbsolute)(LONG x, LONG y, LONG dz, LONG dw,
    9089                                     LONG buttonState);
    91 
    92     // for VirtualBoxSupportErrorInfoImpl
    93     static const wchar_t *getComponentName() { return L"Mouse"; }
    9490
    9591    static const PDMDRVREG  DrvReg;
  • trunk/src/VBox/Main/include/NATEngineImpl.h

    r28864 r30714  
    3232class ATL_NO_VTABLE NATEngine :
    3333    public VirtualBoxBase,
    34     public VirtualBoxSupportErrorInfoImpl<NATEngine, INATEngine>,
    3534    public VirtualBoxSupportTranslation<NATEngine>,
    3635    VBOX_SCRIPTABLE_IMPL(INATEngine)
     
    6968        ULONG    mAliasMode;
    7069    };
    71     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NATEngine)
     70    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NATEngine, INATEngine)
    7271
    7372    DECLARE_NOT_AGGREGATABLE(NATEngine)
     
    126125    STDMETHOD(RemoveRedirect)(IN_BSTR aName);
    127126
    128     static const wchar_t *getComponentName() { return L"NATEngine"; }
    129127private:
    130128    Backupable<Data> mData;
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r28867 r30714  
    3333class ATL_NO_VTABLE NetworkAdapter :
    3434    public VirtualBoxBase,
    35     public VirtualBoxSupportErrorInfoImpl<NetworkAdapter, INetworkAdapter>,
    3635    public VirtualBoxSupportTranslation<NetworkAdapter>,
    3736    VBOX_SCRIPTABLE_IMPL(INetworkAdapter)
     
    7372    };
    7473
    75     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (NetworkAdapter)
     74    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NetworkAdapter, INetworkAdapter)
    7675
    7776    DECLARE_NOT_AGGREGATABLE(NetworkAdapter)
     
    144143    void applyDefaults (GuestOSType *aOsType);
    145144
    146     // for VirtualBoxSupportErrorInfoImpl
    147     static const wchar_t *getComponentName() { return L"NetworkAdapter"; }
    148 
    149145private:
    150146
  • trunk/src/VBox/Main/include/ParallelPortImpl.h

    r28800 r30714  
    2929class ATL_NO_VTABLE ParallelPort :
    3030    public VirtualBoxBase,
    31     public VirtualBoxSupportErrorInfoImpl<ParallelPort, IParallelPort>,
    3231    public VirtualBoxSupportTranslation<ParallelPort>,
    3332    VBOX_SCRIPTABLE_IMPL(IParallelPort)
    3433{
    3534public:
    36     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ParallelPort)
     35    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ParallelPort, IParallelPort)
    3736
    3837    DECLARE_NOT_AGGREGATABLE(ParallelPort)
     
    8281    // (ensure there is a caller and a read lock before calling them!)
    8382
    84     // for VirtualBoxSupportErrorInfoImpl
    85     static const wchar_t *getComponentName() { return L"ParallelPort"; }
    86 
    8783private:
    8884    HRESULT checkSetPath(const Utf8Str &str);
  • trunk/src/VBox/Main/include/PerformanceImpl.h

    r28800 r30714  
    5252{
    5353public:
     54    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PerformanceMetric, IPerformanceMetric)
    5455
    5556    DECLARE_NOT_AGGREGATABLE (PerformanceMetric)
     
    115116class ATL_NO_VTABLE PerformanceCollector :
    116117    public VirtualBoxBase,
    117     public VirtualBoxSupportErrorInfoImpl<PerformanceCollector, IPerformanceCollector>,
    118118    public VirtualBoxSupportTranslation<PerformanceCollector>,
    119119    VBOX_SCRIPTABLE_IMPL(IPerformanceCollector)
     
    121121public:
    122122
    123     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceCollector)
     123    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(PerformanceCollector, IPerformanceCollector)
    124124
    125125    DECLARE_NOT_AGGREGATABLE (PerformanceCollector)
     
    188188    pm::CollectorHAL *getHAL() { return m.hal; };
    189189
    190     // for VirtualBoxSupportErrorInfoImpl
    191     static const wchar_t *getComponentName() { return L"PerformanceCollector"; }
    192 
    193190private:
    194191    HRESULT toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst);
  • trunk/src/VBox/Main/include/ProgressCombinedImpl.h

    r29923 r30714  
    6666 */
    6767class ATL_NO_VTABLE CombinedProgress :
    68     public com::SupportErrorInfoDerived<ProgressBase, CombinedProgress, IProgress>,
     68//     public com::SupportErrorInfoDerived<ProgressBase, CombinedProgress, IProgress>,
     69    public Progress,
    6970    public VirtualBoxSupportTranslation<CombinedProgress>
    7071{
    7172
    7273public:
     74    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(CombinedProgress, IProgress)
    7375
    74     VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (CombinedProgress)
     76    VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(CombinedProgress)
    7577
    76     DECLARE_NOT_AGGREGATABLE (CombinedProgress)
     78    DECLARE_NOT_AGGREGATABLE(CombinedProgress)
    7779
    7880    DECLARE_PROTECT_FINAL_CONSTRUCT()
     
    182184    // public methods only for internal purposes
    183185
    184     /** For com::SupportErrorInfoImpl. */
    185     static const char *ComponentName() { return "CombinedProgress"; }
    186 
    187186private:
    188187
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r29916 r30714  
    3333class ATL_NO_VTABLE ProgressBase :
    3434    public VirtualBoxBase,
    35     public com::SupportErrorInfoBase,
    3635    public VirtualBoxSupportTranslation<ProgressBase>,
    3736    VBOX_SCRIPTABLE_IMPL(IProgress)
     
    3938protected:
    4039
    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)
    4243
    4344    DECLARE_EMPTY_CTOR_DTOR (ProgressBase)
     
    7980    // public methods only for internal purposes
    8081
    81     static HRESULT setErrorInfoOnThread (IProgress *aProgress);
    8282    bool setCancelCallback(void (*pfnCallback)(void *), void *pvUser);
    8383
     
    134134 */
    135135class ATL_NO_VTABLE Progress :
    136     public com::SupportErrorInfoDerived<ProgressBase, Progress, IProgress>,
     136    public ProgressBase,
    137137    public VirtualBoxSupportTranslation<Progress>
    138138{
    139139
    140140public:
    141 
    142     VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (Progress)
     141    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Progress, IProgress)
     142
     143    VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(Progress)
    143144
    144145    DECLARE_NOT_AGGREGATABLE (Progress)
     
    260261    HRESULT notifyComplete(HRESULT aResultCode,
    261262                           const GUID &aIID,
    262                            const Bstr &aComponent,
     263                           const char *pcszComponent,
    263264                           const char *aText,
    264265                           ...);
    265266    HRESULT notifyCompleteV(HRESULT aResultCode,
    266267                            const GUID &aIID,
    267                             const Bstr &aComponent,
     268                            const char *pcszComponent,
    268269                            const char *aText,
    269270                            va_list va);
    270271    bool notifyPointOfNoReturn(void);
    271272
    272     /** For com::SupportErrorInfoImpl. */
    273     static const char *ComponentName() { return "Progress"; }
    274 
    275273private:
    276274
  • trunk/src/VBox/Main/include/ProgressProxyImpl.h

    r29937 r30714  
    3333{
    3434public:
     35    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressProxy, IProgress)
     36
    3537    VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(ProgressProxy)
     38
    3639    DECLARE_NOT_AGGREGATABLE(ProgressProxy)
    3740    DECLARE_PROTECT_FINAL_CONSTRUCT()
     
    9295    HRESULT notifyComplete(HRESULT aResultCode,
    9396                           const GUID &aIID,
    94                            const Bstr &aComponent,
     97                           const char *pcszComponent,
    9598                           const char *aText, ...);
    96     bool    setOtherProgressObject(IProgress *pOtherProgress);
     99    bool setOtherProgressObject(IProgress *pOtherProgress);
    97100
    98101    /** For com::SupportErrorInfoImpl. */
  • trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h

    r28800 r30714  
    2929class ATL_NO_VTABLE RemoteUSBDevice :
    3030    public VirtualBoxBase,
    31     public VirtualBoxSupportErrorInfoImpl<RemoteUSBDevice, IHostUSBDevice>,
    3231    public VirtualBoxSupportTranslation<RemoteUSBDevice>,
    3332    VBOX_SCRIPTABLE_IMPL(IHostUSBDevice)
     
    3534public:
    3635
    37     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)
     36    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteUSBDevice, IHostUSBDevice)
    3837
    3938    DECLARE_NOT_AGGREGATABLE (RemoteUSBDevice)
     
    9695    }
    9796
    98     // for VirtualBoxSupportErrorInfoImpl
    99     static const wchar_t *getComponentName() { return L"RemoteUSBDevice"; }
    100 
    10197private:
    10298
  • trunk/src/VBox/Main/include/SerialPortImpl.h

    r28800 r30714  
    3232class ATL_NO_VTABLE SerialPort :
    3333    public VirtualBoxBase,
    34     public VirtualBoxSupportErrorInfoImpl<SerialPort, ISerialPort>,
    3534    public VirtualBoxSupportTranslation<SerialPort>,
    3635    VBOX_SCRIPTABLE_IMPL(ISerialPort)
    3736{
    3837public:
    39     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SerialPort)
     38    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SerialPort, ISerialPort)
    4039
    4140    DECLARE_NOT_AGGREGATABLE(SerialPort)
     
    9089    // (ensure there is a caller and a read lock before calling them!)
    9190
    92     // for VirtualBoxSupportErrorInfoImpl
    93     static const wchar_t *getComponentName() { return L"SerialPort"; }
    94 
    9591private:
    9692    HRESULT checkSetPath(const Utf8Str &str);
  • trunk/src/VBox/Main/include/SessionImpl.h

    r29363 r30714  
    2929 *  Use SYS V IPC for watching a session.
    3030 *  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.)
    3431 */
    3532#ifdef DOXYGEN_RUNNING
     
    3936class ATL_NO_VTABLE Session :
    4037    public VirtualBoxBase,
    41     public VirtualBoxSupportErrorInfoImpl<Session, ISession>,
    4238    public VirtualBoxSupportTranslation<Session>,
    4339    VBOX_SCRIPTABLE_IMPL(ISession),
     
    4844{
    4945public:
     46
     47    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Session, ISession)
    5048
    5149    DECLARE_CLASSFACTORY()
     
    113111                                 IProgress *aProgress);
    114112
    115     // for VirtualBoxSupportErrorInfoImpl
    116     static const wchar_t *getComponentName() { return L"Session"; }
    117 
    118113private:
    119114
  • trunk/src/VBox/Main/include/SharedFolderImpl.h

    r28800 r30714  
    2626class ATL_NO_VTABLE SharedFolder :
    2727    public VirtualBoxBaseWithChildrenNEXT,
    28     public VirtualBoxSupportErrorInfoImpl<SharedFolder, ISharedFolder>,
    2928    public VirtualBoxSupportTranslation<SharedFolder>,
    3029    VBOX_SCRIPTABLE_IMPL(ISharedFolder)
     
    4241    };
    4342
    44     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SharedFolder)
     43    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SharedFolder, ISharedFolder)
    4544
    4645    DECLARE_NOT_AGGREGATABLE(SharedFolder)
     
    8382    BOOL isWritable() const { return m.writable; }
    8483
    85     // for VirtualBoxSupportErrorInfoImpl
    86     static const wchar_t *getComponentName() { return L"SharedFolder"; }
    87 
    8884protected:
    8985
  • trunk/src/VBox/Main/include/SnapshotImpl.h

    r28835 r30714  
    3333
    3434class ATL_NO_VTABLE Snapshot :
    35     public VirtualBoxSupportErrorInfoImpl<Snapshot, ISnapshot>,
    3635    public VirtualBoxSupportTranslation<Snapshot>,
    3736    public VirtualBoxBase, // WithTypedChildren<Snapshot>,
     
    3938{
    4039public:
     40    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Snapshot, ISnapshot)
     41
    4142    DECLARE_NOT_AGGREGATABLE(Snapshot)
    4243
     
    8990
    9091    /**
    91      * Simple run-time type identification without having to enable C++ RTTI.
    92      * The class IDs are defined in VirtualBoxBase.h.
    93      * @return
    94      */
    95     virtual VBoxClsID getClassID() const
    96     {
    97         return clsidSnapshot;
    98     }
    99 
    100     /**
    10192     * Override of the default locking class to be used for validating lock
    10293     * order with the standard member lock handle.
     
    134125    HRESULT saveSnapshotImpl(settings::Snapshot &data, bool aAttrsOnly);
    135126
    136     // for VirtualBoxSupportErrorInfoImpl
    137     static const wchar_t *getComponentName()
    138     {
    139         return L"Snapshot";
    140     }
    141 
    142127private:
    143128    struct Data;            // opaque, defined in SnapshotImpl.cpp
  • trunk/src/VBox/Main/include/StorageControllerImpl.h

    r29480 r30714  
    2525class ATL_NO_VTABLE StorageController :
    2626    public VirtualBoxBase,
    27     public VirtualBoxSupportErrorInfoImpl<StorageController, IStorageController>,
    2827    public VirtualBoxSupportTranslation<StorageController>,
    2928    VBOX_SCRIPTABLE_IMPL(IStorageController)
     
    3130public:
    3231
    33     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (StorageController)
     32    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(StorageController, IStorageController)
    3433
    3534    DECLARE_NOT_AGGREGATABLE (StorageController)
     
    10099    ComObjPtr<StorageController> getPeer();
    101100
    102     // for VirtualBoxSupportErrorInfoImpl
    103     static const wchar_t *getComponentName() { return L"StorageController"; }
    104 
    105101private:
    106102
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r28800 r30714  
    3535class ATL_NO_VTABLE SystemProperties :
    3636    public VirtualBoxBase,
    37     public VirtualBoxSupportErrorInfoImpl<SystemProperties, ISystemProperties>,
    3837    public VirtualBoxSupportTranslation<SystemProperties>,
    3938    VBOX_SCRIPTABLE_IMPL(ISystemProperties)
     
    4140public:
    4241
    43     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SystemProperties)
     42    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (SystemProperties, ISystemProperties)
    4443
    4544    DECLARE_NOT_AGGREGATABLE(SystemProperties)
     
    114113    // (ensure there is a caller and a read lock before calling them!)
    115114
    116     // for VirtualBoxSupportErrorInfoImpl
    117     static const wchar_t *getComponentName() { return L"SystemProperties"; }
    118 
    119115private:
    120116
  • trunk/src/VBox/Main/include/USBControllerImpl.h

    r28800 r30714  
    3333class ATL_NO_VTABLE USBController :
    3434    public VirtualBoxBase,
    35     public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>,
    3635    public VirtualBoxSupportTranslation<USBController>,
    3736    VBOX_SCRIPTABLE_IMPL(IUSBController)
    3837{
    3938public:
    40     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
     39    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(USBController, IUSBController)
    4140
    4241    DECLARE_NOT_AGGREGATABLE (USBController)
     
    9897    Machine* getMachine();
    9998
    100     // for VirtualBoxSupportErrorInfoImpl
    101     static const wchar_t *getComponentName() { return L"USBController"; }
    102 
    10399private:
    104100
  • trunk/src/VBox/Main/include/USBDeviceImpl.h

    r28800 r30714  
    2828class ATL_NO_VTABLE OUSBDevice :
    2929    public VirtualBoxBase,
    30     public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,
    3130    public VirtualBoxSupportTranslation<OUSBDevice>,
    3231    VBOX_SCRIPTABLE_IMPL(IUSBDevice)
     
    3433public:
    3534
    36     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)
     35    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(OUSBDevice, IUSBDevice)
    3736
    3837    DECLARE_NOT_AGGREGATABLE(OUSBDevice)
     
    7170    // public methods only for internal purposes
    7271    const Guid &id() const { return mData.id; }
    73 
    74     // for VirtualBoxSupportErrorInfoImpl
    75     static const wchar_t *getComponentName() { return L"USBDevice"; }
    7672
    7773private:
  • trunk/src/VBox/Main/include/VFSExplorerImpl.h

    r28800 r30714  
    2525class ATL_NO_VTABLE VFSExplorer :
    2626    public VirtualBoxBase,
    27     public VirtualBoxSupportErrorInfoImpl<VFSExplorer, IVFSExplorer>,
    2827    public VirtualBoxSupportTranslation<VFSExplorer>,
    2928    VBOX_SCRIPTABLE_IMPL(IVFSExplorer)
    3029{
    31     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VFSExplorer)
     30    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VFSExplorer, IVFSExplorer)
    3231
    3332    DECLARE_NOT_AGGREGATABLE(VFSExplorer)
     
    4948    HRESULT init(VFSType_T aType, Utf8Str aFilePath, Utf8Str aHostname, Utf8Str aUsername, Utf8Str aPassword, VirtualBox *aVirtualBox);
    5049    void uninit();
    51 
    52     // for VirtualBoxSupportErrorInfoImpl
    53     static const wchar_t *getComponentName() { return L"VFSExplorer"; }
    5450
    5551    /* IVFSExplorer properties */
  • trunk/src/VBox/Main/include/VRDPServerImpl.h

    r28802 r30714  
    3232class ATL_NO_VTABLE VRDPServer :
    3333    public VirtualBoxBase,
    34     public VirtualBoxSupportErrorInfoImpl<VRDPServer, IVRDPServer>,
    3534    public VirtualBoxSupportTranslation<VRDPServer>,
    3635    VBOX_SCRIPTABLE_IMPL(IVRDPServer)
     
    5150    };
    5251
    53     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VRDPServer)
     52    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VRDPServer, IVRDPServer)
    5453
    5554    DECLARE_NOT_AGGREGATABLE(VRDPServer)
     
    105104    void copyFrom (VRDPServer *aThat);
    106105
    107     // for VirtualBoxSupportErrorInfoImpl
    108     static const wchar_t *getComponentName() { return L"VRDPServer"; }
    109 
    110106private:
    111107
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r29386 r30714  
    157157    do { \
    158158        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); \
    162165    } while (0)
    163166#endif
     
    178181    do { \
    179182        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); \
    184189    } while (0)
    185190#endif
     
    393398        if (RT_UNLIKELY(ComSafeArrayOutIsNull(arg))) \
    394399            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)); \
    397402    } while (0)
    398403
     
    435440////////////////////////////////////////////////////////////////////////////////
    436441
    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
    453496
    454497/**
     
    457500 *
    458501 * Declares functionality that should be available in all components.
    459  *
    460  * Note that this class is always subclassed using the virtual keyword so
    461  * that only one instance of its VTBL and data is present in each derived class
    462  * even in case if VirtualBoxBaseProto appears more than once among base classes
    463  * of the particular component as a result of multiple inheritance.
    464  *
    465  * This makes it possible to have intermediate base classes used by several
    466  * components that implement some common interface functionality but still let
    467  * the final component classes choose what VirtualBoxBase variant it wants to
    468  * use.
    469502 *
    470503 * Among the basic functionality implemented by this class is the primary object
     
    519552    : public Lockable,
    520553      public CComObjectRootEx<CComMultiThreadModel>
     554#if !defined (VBOX_WITH_XPCOM)
     555    , public ISupportErrorInfo
     556#endif
    521557{
    522558public:
     
    528564    static const char *translate(const char *context, const char *sourceText,
    529565                                 const char *comment = 0);
    530 
    531 public:
    532566
    533567    /**
     
    548582    virtual void uninit() {}
    549583
    550     virtual HRESULT addCaller(State *aState = NULL, bool aLimited = false);
     584    virtual HRESULT addCaller(State *aState = NULL,
     585                              bool aLimited = false);
    551586    virtual void releaseCaller();
    552587
     
    562597
    563598    /**
    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.
    576620     */
    577621    virtual VBoxLockingClass getLockingClass() const
     
    589633     */
    590634    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, ...);
    591646
    592647private:
     
    624679
    625680////////////////////////////////////////////////////////////////////////////////
    626 //
    627 // VirtualBoxSupportTranslation, VirtualBoxSupportErrorInfoImpl
    628 //
    629 ////////////////////////////////////////////////////////////////////////////////
    630 
    631 /**
    632  *  This macro adds the error info support to methods of the VirtualBoxBase
    633  *  class (by overriding them). Place it to the public section of the
    634  *  VirtualBoxBase subclass and the following methods will set the extended
    635  *  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 both
    642  *  VirtualBoxSupportErrorInfoImpl and VirtualBoxSupportTranslation templates!
    643  *
    644  *  @param C    VirtualBoxBase subclass to add the error info support to
    645  */
    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 ////////////////////////////////////////////////////////////////////////////////
    665681
    666682/** Helper for VirtualBoxSupportTranslation. */
     
    764780
    765781////////////////////////////////////////////////////////////////////////////////
    766 
    767 /**
    768  *  Helper for the VirtualBoxSupportErrorInfoImpl template.
    769  */
    770 /// @todo switch to com::SupportErrorInfo* and remove
    771 class VirtualBoxSupportErrorInfoImplBase
    772 {
    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 a
    784      * 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 on
    788      * for the current thread and the turn-on counter is increased by one. In
    789      * multi-error mode, a call to #setError() or #setWarning() does not
    790      * overwrite the current error or warning info object possibly set on the
    791      * current thread by other method calls, but instead it stores this old
    792      * object in the IVirtualBoxErrorInfo::next attribute of the new error
    793      * object being set.
    794      *
    795      * This way, error/warning objects are stacked together and form a chain of
    796      * errors where the most recent error is the first one retrieved by the
    797      * calling party, the preceding error is what the
    798      * IVirtualBoxErrorInfo::next attribute of the first error points to, and so
    799      * on, up to the first error or warning occurred which is the last in the
    800      * chain. See IVirtualBoxErrorInfo documentation for more info.
    801      *
    802      * When the instance of the MultiResult class goes out of scope and gets
    803      * destroyed, it automatically decreases the turn-on counter by one. If
    804      * the counter drops to zero, multi-error mode for the current thread is
    805      * turned off and the thread switches back to single-error mode where every
    806      * 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 to
    809      * decide if the method has returned an error (negative codes) or a warning
    810      * (positive non-zero codes) and will query extended error info only in
    811      * these two cases. However, since multi-error mode implies that the method
    812      * doesn't return control return to the caller immediately after the first
    813      * error or warning but continues its execution, the functionality provided
    814      * by the base com::FWResult class becomes very useful because it allows to
    815      * preserve the error or the warning result code even if it is later assigned
    816      * 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 preserved
    828                 MultiResult rc = foo->method1();
    829 
    830                 // return on fatal error, but continue on warning or on success
    831                 if (FAILED(rc)) return rc;
    832 
    833                 rc = foo->method2();
    834                 // no matter what result, stack it and continue
    835 
    836                 // ...
    837 
    838                 // return the last worst result code (it will be preserved even if
    839                 // 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, therefore
    852      *       You cannot create them using new(). Although it is possible to copy
    853      *       instances of MultiResult or return them by value, please never do
    854      *       that as it is breaks the class semantics (and will assert).
    855      */
    856     class MultiResult : public com::FWResult
    857     {
    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 have
    868              * it in case of expressions like |MultiResult rc = E_FAIL;|. But
    869              * we assert since the optimizer should actually avoid the
    870              * 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 have
    886              * it in case of expressions like |MultiResult rc = E_FAIL;|. But
    887              * we assert since the optimizer should actually avoid the
    888              * 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 class
    947  *  and provides the #setError() method to conveniently set the error information
    948  *  from within interface methods' implementations.
    949  *
    950  *  On Windows, the template argument must define a COM interface map using
    951  *  BEGIN_COM_MAP / END_COM_MAP macros and this map must contain a
    952  *  COM_INTERFACE_ENTRY(ISupportErrorInfo) definition. All interface entries
    953  *  that follow it will be considered to support IErrorInfo, i.e. the
    954  *  InterfaceSupportsErrorInfo() implementation will return S_OK for the
    955  *  corresponding IID.
    956  *
    957  *  On all platforms, the template argument must also define the following
    958  *  method: |public static const wchar_t *C::getComponentName()|. See
    959  *  #setError(HRESULT, const char *, ...) for a description on how it is
    960  *  used.
    961  *
    962  *  @param C
    963  *      component class that implements one or more COM interfaces
    964  *  @param I
    965  *      default interface for the component. This interface's IID is used
    966  *      by the shortest form of #setError, for convenience.
    967  */
    968 /// @todo switch to com::SupportErrorInfo* and remove
    969 template<class C, class I>
    970 class ATL_NO_VTABLE VirtualBoxSupportErrorInfoImpl
    971     : protected VirtualBoxSupportErrorInfoImplBase
    972 #if !defined (VBOX_WITH_XPCOM)
    973     , public ISupportErrorInfo
    974 #else
    975 #endif
    976 {
    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 found
    995                 bISupportErrorInfoFound =
    996                     InlineIsEqualGUID(*(pEntries->piid), IID_ISupportErrorInfo);
    997             }
    998             else
    999             {
    1000                 // look for the requested interface in the rest of the com map
    1001                 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 method
    1017      *  using IErrorInfo on Windows or nsIException on Linux, or the cross-platform
    1018      *  IVirtualBoxErrorInfo interface that provides extended error info (only
    1019      *  for components from the VirtualBox COM library). Alternatively, the
    1020      *  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 returns
    1024      *  an unsuccessful result code to the caller (otherwise, there is no reason
    1025      *  for the caller to try to retrieve error info after method invocation).
    1026      *
    1027      *  Here is a table of correspondence between this method's arguments
    1028      *  and IErrorInfo/nsIException/IVirtualBoxErrorInfo attributes/methods:
    1029      *
    1030      *  argument    IErrorInfo      nsIException    IVirtualBoxErrorInfo
    1031      *  ----------------------------------------------------------------
    1032      *  resultCode  --              result          resultCode
    1033      *  iid         GetGUID         --              interfaceID
    1034      *  component   GetSource       --              component
    1035      *  text        GetDescription  message         text
    1036      *
    1037      *  This method is rarely needs to be used though. There are more convenient
    1038      *  overloaded versions, that automatically substitute some arguments
    1039      *  taking their values from the template parameters. See
    1040      *  #setError(HRESULT, const char *, ...) for an example.
    1041      *
    1042      *  @param  aResultCode result (error) code, must not be S_OK
    1043      *  @param  aIID        IID of the interface that defines the error
    1044      *  @param  aComponent  name of the component that generates the error
    1045      *  @param  aText       error message (must not be null), an RTStrPrintf-like
    1046      *                      format string in UTF-8 encoding
    1047      *  @param  ...         list of arguments for the format string
    1048      *
    1049      *  @return
    1050      *      the error argument, for convenience, If an error occurs while
    1051      *      creating error info itself, that error is returned instead of the
    1052      *      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 @a
    1072      *  aResultCode doesn't have the error severity bit (31) set when passed
    1073      *  down to the created IVirtualBoxErrorInfo object.
    1074      *
    1075      *  The error severity bit is always cleared by this call, thereof you can
    1076      *  use ordinary E_XXX result code constants, for convenience. However, this
    1077      *  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 interface
    1094      *  ID (taken from the I template argument) and the component name
    1095      *  (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 error
    1101      *  information from within interface methods. A typical pattern of usage
    1102      *  is looks like this:
    1103      *
    1104      *  <code>
    1105      *      return setError(E_FAIL, "Terrible Error");
    1106      *  </code>
    1107      *  or
    1108      *  <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 @a
    1130      *  aResultCode doesn't have the error severity bit (31) set when passed
    1131      *  down to the created IVirtualBoxErrorInfo object.
    1132      *
    1133      *  The error severity bit is always cleared by this call, thereof you can
    1134      *  use ordinary E_XXX result code constants, for convenience. However, this
    1135      *  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 interface
    1153      *  ID (taken from the I template argument) and the component name
    1154      *  (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 @a
    1173      *  aResultCode doesn't have the error severity bit (31) set when passed
    1174      *  down to the created IVirtualBoxErrorInfo object.
    1175      *
    1176      *  The error severity bit is always cleared by this call, thereof you can
    1177      *  use ordinary E_XXX result code constants, for convenience. However, this
    1178      *  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 name
    1194      *  (a value of C::getComponentName()), but allows to specify the interface
    1195      *  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 @a
    1217      *  aResultCode doesn't have the error severity bit (31) set when passed
    1218      *  down to the created IVirtualBoxErrorInfo object.
    1219      *
    1220      *  The error severity bit is always cleared by this call, thereof you can
    1221      *  use ordinary E_XXX result code constants, for convenience. However, this
    1222      *  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 put
    1240      *  anything in the release log. This is very useful for avoiding
    1241      *  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 
    1263782
    1264783/**
     
    1441960
    1442961
    1443 /// @todo (dmik) remove after we switch to VirtualBoxBaseNEXT completely
    1444962/**
    1445963 *  Simple template that manages data structure allocation/deallocation
  • trunk/src/VBox/Main/include/VirtualBoxCallbackImpl.h

    r30381 r30714  
    2121class ATL_NO_VTABLE CallbackWrapper :
    2222    public VirtualBoxBase,
    23     public VirtualBoxSupportErrorInfoImpl<CallbackWrapper, IVirtualBoxCallback>,
    2423    public VirtualBoxSupportTranslation<CallbackWrapper>,
    2524    VBOX_SCRIPTABLE_IMPL(ILocalOwner),
     
    3130{
    3231public:
     32
     33    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(CallbackWrapper, IVirtualBoxCallback)
    3334
    3435    DECLARE_CLASSFACTORY()
     
    9596    STDMETHOD(OnShowWindow)(ULONG64 *winId);
    9697
    97     // for VirtualBoxSupportErrorInfoImpl
    98     static const wchar_t *getComponentName() { return L"CallbackWrapper"; }
    99 
    10098private:
    10199    ComPtr<IVirtualBoxCallback> mVBoxCallback;
  • trunk/src/VBox/Main/include/VirtualBoxErrorInfoImpl.h

    r30013 r30714  
    8383#endif
    8484
    85     VirtualBoxErrorInfo() : mResultCode(S_OK) {}
     85    VirtualBoxErrorInfo()
     86        : m_resultCode(S_OK)
     87    {}
    8688
    8789    // 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,
    9094                 IVirtualBoxErrorInfo *aNext = NULL);
    9195
     
    106110                            void *       /* c */) { return rc; }
    107111
    108     HRESULT mResultCode;
    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;
    112116    ComPtr<IVirtualBoxErrorInfo> mNext;
    113117};
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r30380 r30714  
    5858class ATL_NO_VTABLE VirtualBox :
    5959    public VirtualBoxBase,
    60     public VirtualBoxSupportErrorInfoImpl<VirtualBox, IVirtualBox>,
    6160    public VirtualBoxSupportTranslation<VirtualBox>,
    6261    VBOX_SCRIPTABLE_IMPL(IVirtualBox)
     
    7675    friend class CallbackEvent;
    7776
    78     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualBox)
     77    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualBox, IVirtualBox)
    7978
    8079    DECLARE_CLASSFACTORY_SINGLETON(VirtualBox)
     
    191190
    192191    /**
    193      * Simple run-time type identification without having to enable C++ RTTI.
    194      * The class IDs are defined in VirtualBoxBase.h.
    195      * @return
    196      */
    197     virtual VBoxClsID getClassID() const
    198     {
    199         return clsidVirtualBox;
    200     }
    201 
    202     /**
    203192     * Override of the default locking class to be used for validating lock
    204193     * order with the standard member lock handle.
     
    303292    RWLockHandle& getMediaTreeLockHandle();
    304293
    305     /* for VirtualBoxSupportErrorInfoImpl */
    306     static const wchar_t *getComponentName() { return L"VirtualBox"; }
    307 
    308294private:
     295
     296    static HRESULT setErrorStatic(HRESULT aResultCode,
     297                                  const Utf8Str &aText)
     298    {
     299        return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
     300    }
    309301
    310302    HRESULT checkMediaForConflicts2(const Guid &aId, const Utf8Str &aLocation,
  • trunk/src/VBox/Main/testcase/tstUSBLinux.h

    r30269 r30714  
    3939{
    4040public:
    41     USBProxyServiceLinux() : mLastError(VINF_SUCCESS) {}
     41    USBProxyServiceLinux()
     42        : mLastError(VINF_SUCCESS)
     43    {}
     44
    4245    HRESULT initSysfs(void);
    4346    PUSBDEVICE getDevicesFromSysfs(void);
    44     int getLastError(void) { return mLastError; }
     47    int getLastError(void)
     48    {
     49        return mLastError;
     50    }
    4551
    4652private:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette