VirtualBox

Ignore:
Timestamp:
May 9, 2007 4:38:24 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21034
Message:

Main & All Frontends: replaced the IGuestOSType IMachine::OSType property with the wstring IMachine::OSTypeId property (+ converted IGuest and IGuestOSType to VirtualBoxBaseNEXT semantics).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/DVDImageImpl.cpp

    r2110 r2567  
    3232/////////////////////////////////////////////////////////////////////////////
    3333
     34DEFINE_EMPTY_CTOR_DTOR (DVDImage)
     35
    3436HRESULT DVDImage::FinalConstruct()
    3537{
     
    4951 *  Initializes the DVD image object.
    5052 *
    51  *  @param parent
     53 *  @param aParent
    5254 *      parent object
    53  *  @param filePath
     55 *  @param aFilePath
    5456 *      local file system path to the image file
    5557 *      (can be relative to the VirtualBox config dir)
    56  *  @param isRegistered
     58 *  @param aRegistered
    5759 *      whether this object is being initialized by the VirtualBox init code
    5860 *      because it is present in the registry
    59  *  @param id
     61 *  @param aId
    6062 *      ID of the DVD image to assign
    6163 *
    6264 *  @return          COM result indicator
    6365 */
    64 HRESULT DVDImage::init (VirtualBox *parent, const BSTR filePath,
    65                         BOOL isRegistered, const Guid &id)
    66 {
    67     LogFlowMember (("DVDImage::init(): filePath={%ls}, id={%s}\n",
    68                     filePath, id.toString().raw()));
    69 
    70     ComAssertRet (parent && filePath && !!id, E_INVALIDARG);
    71 
    72     AutoLock alock (this);
    73     ComAssertRet (!isReady(), E_UNEXPECTED);
     66HRESULT DVDImage::init (VirtualBox *aParent, const BSTR aFilePath,
     67                        BOOL aRegistered, const Guid &aId)
     68{
     69    LogFlowThisFunc (("aFilePath={%ls}, aId={%s}\n",
     70                      aFilePath, aId.toString().raw()));
     71
     72    ComAssertRet (aParent && aFilePath && !!aId, E_INVALIDARG);
     73
     74    /* Enclose the state transition NotReady->InInit->Ready */
     75    AutoInitSpan autoInitSpan (this);
     76    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
    7477
    7578    HRESULT rc = S_OK;
    7679
    77     mParent = parent;
    78 
    79     unconst (mImageFile) = filePath;
    80     unconst (mUuid) = id;
     80    /* share the parent weakly */
     81    unconst (mParent) = aParent;
     82
     83    /* register with parent early, since uninit() will unconditionally
     84     * unregister on failure */
     85    mParent->addDependentChild (this);
     86
     87    unconst (mImageFile) = aFilePath;
     88    unconst (mUuid) = aId;
    8189
    8290    /* get the full file name */
    8391    char filePathFull [RTPATH_MAX];
    84     int vrc = RTPathAbsEx (mParent->homeDir(), Utf8Str (filePath),
     92    int vrc = RTPathAbsEx (mParent->homeDir(), Utf8Str (aFilePath),
    8593                           filePathFull, sizeof (filePathFull));
    8694    if (VBOX_FAILURE (vrc))
    87         return setError (E_FAIL, tr ("Invalid image file path: '%ls' (%Vrc)"),
    88                                  filePath, vrc);
     95        return setError (E_FAIL,
     96            tr ("Invalid image file path: '%ls' (%Vrc)"),
     97                aFilePath, vrc);
    8998
    9099    unconst (mImageFileFull) = filePathFull;
    91     LogFlowMember (("              filePathFull={%ls}\n", mImageFileFull.raw()));
    92 
    93     if (!isRegistered)
     100    LogFlowThisFunc (("...filePathFull={%ls}\n", mImageFileFull.raw()));
     101
     102    if (!aRegistered)
    94103    {
    95104        /* check whether the given file exists or not */
     
    109118    }
    110119
     120    /* Confirm a successful initialization when it's the case */
    111121    if (SUCCEEDED (rc))
    112     {
    113         mParent->addDependentChild (this);
    114     }
    115 
    116     setReady (SUCCEEDED (rc));
     122        autoInitSpan.setSucceeded();
    117123
    118124    return rc;
     
    125131void DVDImage::uninit()
    126132{
    127     LogFlowMember (("DVDImage::uninit()\n"));
    128 
    129     AutoLock alock (this);
    130 
    131     LogFlowMember (("DVDImage::uninit(): isReady=%d\n", isReady()));
    132 
    133     if (!isReady())
     133    LogFlowThisFunc (("\n"));
     134
     135    /* Enclose the state transition Ready->InUninit->NotReady */
     136    AutoUninitSpan autoUninitSpan (this);
     137    if (autoUninitSpan.uninitDone())
    134138        return;
    135139
    136     setReady (false);
    137 
    138     alock.leave();
     140    LogFlowThisFunc (("initFailed()=%RTbool\n", autoUninitSpan.initFailed()));
     141
    139142    mParent->removeDependentChild (this);
    140     alock.enter();
    141 
    142     mParent.setNull();
     143
     144    unconst (mParent).setNull();
    143145}
    144146
     
    146148/////////////////////////////////////////////////////////////////////////////
    147149
    148 STDMETHODIMP DVDImage::COMGETTER(Id) (GUIDPARAMOUT id)
    149 {
    150     if (!id)
    151         return E_POINTER;
     150STDMETHODIMP DVDImage::COMGETTER(Id) (GUIDPARAMOUT aId)
     151{
     152    if (!aId)
     153        return E_POINTER;
     154
     155    AutoCaller autoCaller (this);
     156    CheckComRCReturnRC (autoCaller.rc());
     157
     158    /* mUuid is constant during life time, no need to lock */
     159    mUuid.cloneTo (aId);
     160
     161    return S_OK;
     162}
     163
     164STDMETHODIMP DVDImage::COMGETTER(FilePath) (BSTR *aFilePath)
     165{
     166    if (!aFilePath)
     167        return E_POINTER;
     168
     169    AutoCaller autoCaller (this);
     170    CheckComRCReturnRC (autoCaller.rc());
     171
     172    AutoReaderLock alock (this);
     173
     174    mImageFileFull.cloneTo (aFilePath);
     175
     176    return S_OK;
     177}
     178
     179STDMETHODIMP DVDImage::COMGETTER(Accessible) (BOOL *aAccessible)
     180{
     181    if (!aAccessible)
     182        return E_POINTER;
     183
     184    AutoCaller autoCaller (this);
     185    CheckComRCReturnRC (autoCaller.rc());
    152186
    153187    AutoLock alock (this);
    154     CHECK_READY();
    155 
    156     mUuid.cloneTo (id);
    157     return S_OK;
    158 }
    159 
    160 STDMETHODIMP DVDImage::COMGETTER(FilePath) (BSTR *filePath)
    161 {
    162     if (!filePath)
    163         return E_POINTER;
    164 
    165     AutoLock alock (this);
    166     CHECK_READY();
    167 
    168     mImageFileFull.cloneTo (filePath);
    169     return S_OK;
    170 }
    171 
    172 STDMETHODIMP DVDImage::COMGETTER(Accessible) (BOOL *accessible)
    173 {
    174     if (!accessible)
    175         return E_POINTER;
    176 
    177     AutoLock alock (this);
    178     CHECK_READY();
    179188
    180189    HRESULT rc = S_OK;
     
    196205    }
    197206
    198     *accessible = mAccessible;
     207    *aAccessible = mAccessible;
    199208
    200209    return rc;
    201210}
    202211
    203 STDMETHODIMP DVDImage::COMGETTER(Size) (ULONG64 *size)
    204 {
    205     if (!size)
     212STDMETHODIMP DVDImage::COMGETTER(Size) (ULONG64 *aSize)
     213{
     214    if (!aSize)
    206215        return E_POINTER;
    207216
    208217    HRESULT rc = S_OK;
    209218
    210     AutoLock alock (this);
    211     CHECK_READY();
     219    AutoCaller autoCaller (this);
     220    CheckComRCReturnRC (autoCaller.rc());
     221
     222    AutoReaderLock alock (this);
    212223
    213224    RTFILE file;
     
    227238
    228239        if (VBOX_SUCCESS (vrc))
    229             *size = u64Size;
     240            *aSize = u64Size;
    230241        else
    231242            rc = setError (E_FAIL,
     
    258269    AssertReturnVoid (aNewPath);
    259270
     271    AutoCaller autoCaller (this);
     272    AssertComRCReturnVoid (autoCaller.rc());
     273
    260274    AutoLock alock (this);
    261     AssertReturnVoid (isReady());
    262275
    263276    unconst (mImageFileFull) = aNewFullPath;
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