Changeset 2567 in vbox for trunk/src/VBox/Main/DVDImageImpl.cpp
- Timestamp:
- May 9, 2007 4:38:24 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 21034
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DVDImageImpl.cpp
r2110 r2567 32 32 ///////////////////////////////////////////////////////////////////////////// 33 33 34 DEFINE_EMPTY_CTOR_DTOR (DVDImage) 35 34 36 HRESULT DVDImage::FinalConstruct() 35 37 { … … 49 51 * Initializes the DVD image object. 50 52 * 51 * @param parent53 * @param aParent 52 54 * parent object 53 * @param filePath55 * @param aFilePath 54 56 * local file system path to the image file 55 57 * (can be relative to the VirtualBox config dir) 56 * @param isRegistered58 * @param aRegistered 57 59 * whether this object is being initialized by the VirtualBox init code 58 60 * because it is present in the registry 59 * @param id61 * @param aId 60 62 * ID of the DVD image to assign 61 63 * 62 64 * @return COM result indicator 63 65 */ 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); 66 HRESULT 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); 74 77 75 78 HRESULT rc = S_OK; 76 79 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; 81 89 82 90 /* get the full file name */ 83 91 char filePathFull [RTPATH_MAX]; 84 int vrc = RTPathAbsEx (mParent->homeDir(), Utf8Str ( filePath),92 int vrc = RTPathAbsEx (mParent->homeDir(), Utf8Str (aFilePath), 85 93 filePathFull, sizeof (filePathFull)); 86 94 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); 89 98 90 99 unconst (mImageFileFull) = filePathFull; 91 LogFlow Member (("filePathFull={%ls}\n", mImageFileFull.raw()));92 93 if (! isRegistered)100 LogFlowThisFunc (("...filePathFull={%ls}\n", mImageFileFull.raw())); 101 102 if (!aRegistered) 94 103 { 95 104 /* check whether the given file exists or not */ … … 109 118 } 110 119 120 /* Confirm a successful initialization when it's the case */ 111 121 if (SUCCEEDED (rc)) 112 { 113 mParent->addDependentChild (this); 114 } 115 116 setReady (SUCCEEDED (rc)); 122 autoInitSpan.setSucceeded(); 117 123 118 124 return rc; … … 125 131 void DVDImage::uninit() 126 132 { 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()) 134 138 return; 135 139 136 setReady (false); 137 138 alock.leave(); 140 LogFlowThisFunc (("initFailed()=%RTbool\n", autoUninitSpan.initFailed())); 141 139 142 mParent->removeDependentChild (this); 140 alock.enter(); 141 142 mParent.setNull(); 143 144 unconst (mParent).setNull(); 143 145 } 144 146 … … 146 148 ///////////////////////////////////////////////////////////////////////////// 147 149 148 STDMETHODIMP DVDImage::COMGETTER(Id) (GUIDPARAMOUT id) 149 { 150 if (!id) 151 return E_POINTER; 150 STDMETHODIMP 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 164 STDMETHODIMP 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 179 STDMETHODIMP DVDImage::COMGETTER(Accessible) (BOOL *aAccessible) 180 { 181 if (!aAccessible) 182 return E_POINTER; 183 184 AutoCaller autoCaller (this); 185 CheckComRCReturnRC (autoCaller.rc()); 152 186 153 187 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();179 188 180 189 HRESULT rc = S_OK; … … 196 205 } 197 206 198 *a ccessible = mAccessible;207 *aAccessible = mAccessible; 199 208 200 209 return rc; 201 210 } 202 211 203 STDMETHODIMP DVDImage::COMGETTER(Size) (ULONG64 * size)204 { 205 if (! size)212 STDMETHODIMP DVDImage::COMGETTER(Size) (ULONG64 *aSize) 213 { 214 if (!aSize) 206 215 return E_POINTER; 207 216 208 217 HRESULT rc = S_OK; 209 218 210 AutoLock alock (this); 211 CHECK_READY(); 219 AutoCaller autoCaller (this); 220 CheckComRCReturnRC (autoCaller.rc()); 221 222 AutoReaderLock alock (this); 212 223 213 224 RTFILE file; … … 227 238 228 239 if (VBOX_SUCCESS (vrc)) 229 * size = u64Size;240 *aSize = u64Size; 230 241 else 231 242 rc = setError (E_FAIL, … … 258 269 AssertReturnVoid (aNewPath); 259 270 271 AutoCaller autoCaller (this); 272 AssertComRCReturnVoid (autoCaller.rc()); 273 260 274 AutoLock alock (this); 261 AssertReturnVoid (isReady());262 275 263 276 unconst (mImageFileFull) = aNewFullPath;
Note:
See TracChangeset
for help on using the changeset viewer.