Changeset 33300 in vbox
- Timestamp:
- Oct 21, 2010 11:28:06 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/SDKRef.xml
r33294 r33300 3429 3429 aforementioned changes, IVirtualBox::getMachine() has been merged 3430 3430 with <xref linkend="IVirtualBox__findMachine" 3431 xreflabel="IVirtualBox::findMachine()" />.</para> 3431 xreflabel="IVirtualBox::findMachine()" />, and 3432 IMachine::getSnapshot() has been merged with <xref 3433 linkend="IMachine__findSnapshot" 3434 xreflabel="IMachine::findSnapshot()" />.</para> 3432 3435 </listitem> 3433 3436 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r33294 r33300 2030 2030 */ 2031 2031 ComPtr<ISnapshot> snapshot; 2032 rc = machine-> GetSnapshot(Bstr().raw(), snapshot.asOutParam());2032 rc = machine->FindSnapshot(Bstr().raw(), snapshot.asOutParam()); 2033 2033 if (SUCCEEDED(rc) && snapshot) 2034 2034 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r33294 r33300 150 150 { 151 151 ComPtr<ISnapshot> snapshot; 152 machine-> GetSnapshot(snapshotIds[k], snapshot.asOutParam());152 machine->FindSnapshot(snapshotIds[k], snapshot.asOutParam()); 153 153 if (snapshot) 154 154 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r33294 r33300 172 172 // get root snapshot 173 173 ComPtr<ISnapshot> pSnapshot; 174 CHECK_ERROR_BREAK(pMachine, GetSnapshot(Bstr("").raw(), pSnapshot.asOutParam()));174 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr("").raw(), pSnapshot.asOutParam())); 175 175 176 176 // get current snapshot … … 363 363 { 364 364 // restore or delete snapshot: then resolve cmd line argument to snapshot instance 365 // assume it's a UUID 366 bstrSnapGuid = a->argv[2]; 367 if (FAILED(pMachine->GetSnapshot(bstrSnapGuid.raw(), 368 pSnapshot.asOutParam()))) 369 { 370 // then it must be a name 371 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 372 pSnapshot.asOutParam())); 373 CHECK_ERROR_BREAK(pSnapshot, COMGETTER(Id)(bstrSnapGuid.asOutParam())); 374 } 365 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 366 pSnapshot.asOutParam())); 367 Bstr bstrSnapGuid; 368 CHECK_ERROR_BREAK(pSnapshot, COMGETTER(Id)(bstrSnapGuid.asOutParam())); 375 369 } 376 370 … … 415 409 else 416 410 { 417 /* assume it's a UUID */ 418 rc = pMachine->GetSnapshot(Bstr(a->argv[2]).raw(), 419 snapshot.asOutParam()); 420 if (FAILED(rc) || !snapshot) 421 { 422 /* then it must be a name */ 423 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 424 snapshot.asOutParam())); 425 } 411 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 412 snapshot.asOutParam())); 426 413 } 427 414 … … 476 463 ComPtr<ISnapshot> snapshot; 477 464 478 /* assume it's a UUID */ 479 rc = pMachine->GetSnapshot(Bstr(a->argv[2]).raw(), 480 snapshot.asOutParam()); 481 if (FAILED(rc) || !snapshot) 482 { 483 /* then it must be a name */ 484 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 485 snapshot.asOutParam())); 486 } 465 CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 466 snapshot.asOutParam())); 487 467 488 468 /* get the machine of the given snapshot */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.cpp
r33294 r33300 208 208 } 209 209 210 CSnapshot snapshot = machine. GetSnapshot(*jt);210 CSnapshot snapshot = machine.FindSnapshot(*jt); 211 211 if (!snapshot.isNull()) // can be NULL while takeSnaphot is in progress 212 212 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r33140 r33300 994 994 /* Search for the max available filter index. */ 995 995 QString strNameTemplate = QApplication::translate("UIMachineLogic", "Snapshot %1"); 996 int iMaxSnapshotIndex = searchMaxSnapshotIndex(machine, machine. GetSnapshot(QString()), strNameTemplate);996 int iMaxSnapshotIndex = searchMaxSnapshotIndex(machine, machine.FindSnapshot(QString()), strNameTemplate); 997 997 dlg.mLeName->setText(strNameTemplate.arg(++ iMaxSnapshotIndex)); 998 998 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
r32760 r33300 507 507 if (item) 508 508 { 509 CSnapshot snap = item->snapshotId().isNull() ? CSnapshot() : mMachine.GetSnapshot(item->snapshotId());509 CSnapshot snap = item->snapshotId().isNull() ? CSnapshot() : mMachine.FindSnapshot(item->snapshotId()); 510 510 if (!snap.isNull() && snap.isOk() && snap.GetName() != item->text (0)) 511 511 snap.SetName (item->text (0)); … … 521 521 QString snapId = item->snapshotId(); 522 522 AssertReturn (!snapId.isNull(), (void) 0); 523 CSnapshot snapshot = mMachine. GetSnapshot(snapId);523 CSnapshot snapshot = mMachine.FindSnapshot(snapId); 524 524 525 525 if (!vboxProblem().askAboutSnapshotRestoring (snapshot.GetName())) … … 556 556 QString snapId = item->snapshotId(); 557 557 AssertReturn (!snapId.isNull(), (void) 0); 558 CSnapshot snapshot = mMachine. GetSnapshot(snapId);558 CSnapshot snapshot = mMachine.FindSnapshot(snapId); 559 559 560 560 if (!vboxProblem().askAboutSnapshotDeleting (snapshot.GetName())) … … 779 779 if (mMachine.GetSnapshotCount() > 0) 780 780 { 781 CSnapshot snapshot = mMachine. GetSnapshot(QString::null);781 CSnapshot snapshot = mMachine.FindSnapshot(QString::null); 782 782 783 783 populateSnapshots (snapshot, 0); -
trunk/src/VBox/Main/MachineImpl.cpp
r33232 r33300 4557 4557 } 4558 4558 4559 STDMETHODIMP Machine:: GetSnapshot(IN_BSTR aId, ISnapshot **aSnapshot)4559 STDMETHODIMP Machine::FindSnapshot(IN_BSTR aNameOrId, ISnapshot **aSnapshot) 4560 4560 { 4561 4561 CheckComArgOutPointerValid(aSnapshot); … … 4566 4566 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 4567 4567 4568 Guid uuid(aId); 4569 /* Todo: fix this properly by perhaps introducing an isValid method for the Guid class */ 4570 if ( (aId) 4571 && (*aId != '\0') // an empty Bstr means "get root snapshot", so don't fail on that 4572 && (uuid.isEmpty())) 4573 { 4574 RTUUID uuidTemp; 4575 /* Either it's a null UUID or the conversion failed. (null uuid has a special meaning in findSnapshot) */ 4576 if (RT_FAILURE(RTUuidFromUtf16(&uuidTemp, aId))) 4577 return setError(E_FAIL, 4578 tr("Could not find a snapshot with UUID {%ls}"), 4579 aId); 4580 } 4581 4582 ComObjPtr<Snapshot> snapshot; 4583 4584 HRESULT rc = findSnapshot(uuid, snapshot, true /* aSetError */); 4585 snapshot.queryInterfaceTo(aSnapshot); 4568 ComObjPtr<Snapshot> pSnapshot; 4569 HRESULT rc; 4570 4571 if (!aNameOrId || !*aNameOrId) 4572 // null case (caller wants root snapshot): findSnapshotById() handles this 4573 rc = findSnapshotById(Guid(), pSnapshot, true /* aSetError */); 4574 else 4575 { 4576 Guid uuid(aNameOrId); 4577 if (!uuid.isEmpty()) 4578 rc = findSnapshotById(uuid, pSnapshot, true /* aSetError */); 4579 else 4580 rc = findSnapshotByName(Utf8Str(aNameOrId), pSnapshot, true /* aSetError */); 4581 } 4582 pSnapshot.queryInterfaceTo(aSnapshot); 4586 4583 4587 4584 return rc; 4588 }4589 4590 STDMETHODIMP Machine::FindSnapshot(IN_BSTR aName, ISnapshot **aSnapshot)4591 {4592 CheckComArgStrNotEmptyOrNull(aName);4593 CheckComArgOutPointerValid(aSnapshot);4594 4595 AutoCaller autoCaller(this);4596 if (FAILED(autoCaller.rc())) return autoCaller.rc();4597 4598 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);4599 4600 ComObjPtr<Snapshot> snapshot;4601 4602 HRESULT rc = findSnapshot(aName, snapshot, true /* aSetError */);4603 snapshot.queryInterfaceTo(aSnapshot);4604 4605 return rc;4606 }4607 4608 STDMETHODIMP Machine::SetCurrentSnapshot(IN_BSTR /* aId */)4609 {4610 /// @todo (dmik) don't forget to set4611 // mData->mCurrentStateModified to FALSE4612 4613 return setError(E_NOTIMPL, "Not implemented");4614 4585 } 4615 4586 … … 7533 7504 * @param aSetError true to set extended error info on failure 7534 7505 */ 7535 HRESULT Machine::findSnapshot (const Guid &aId,7536 ComObjPtr<Snapshot> &aSnapshot,7537 bool aSetError /* = false */)7506 HRESULT Machine::findSnapshotById(const Guid &aId, 7507 ComObjPtr<Snapshot> &aSnapshot, 7508 bool aSetError /* = false */) 7538 7509 { 7539 7510 AutoReadLock chlock(this COMMA_LOCKVAL_SRC_POS); … … 7542 7513 { 7543 7514 if (aSetError) 7544 return setError(E_FAIL, 7545 tr("This machine does not have any snapshots")); 7515 return setError(E_FAIL, tr("This machine does not have any snapshots")); 7546 7516 return E_FAIL; 7547 7517 } … … 7571 7541 * @param aSetError true to set extended error info on failure 7572 7542 */ 7573 HRESULT Machine::findSnapshot (IN_BSTR aName,7574 ComObjPtr<Snapshot> &aSnapshot,7575 bool aSetError /* = false */)7576 { 7577 AssertReturn( aName, E_INVALIDARG);7543 HRESULT Machine::findSnapshotByName(const Utf8Str &strName, 7544 ComObjPtr<Snapshot> &aSnapshot, 7545 bool aSetError /* = false */) 7546 { 7547 AssertReturn(!strName.isEmpty(), E_INVALIDARG); 7578 7548 7579 7549 AutoReadLock chlock(this COMMA_LOCKVAL_SRC_POS); … … 7587 7557 } 7588 7558 7589 aSnapshot = mData->mFirstSnapshot->findChildOrSelf( aName);7559 aSnapshot = mData->mFirstSnapshot->findChildOrSelf(strName); 7590 7560 7591 7561 if (!aSnapshot) … … 7593 7563 if (aSetError) 7594 7564 return setError(VBOX_E_OBJECT_NOT_FOUND, 7595 tr("Could not find a snapshot named '% ls'"), aName);7565 tr("Could not find a snapshot named '%s'"), strName.c_str()); 7596 7566 return VBOX_E_OBJECT_NOT_FOUND; 7597 7567 } -
trunk/src/VBox/Main/SnapshotImpl.cpp
r33259 r33300 2088 2088 2089 2089 ComObjPtr<Snapshot> pSnapshot; 2090 HRESULT rc = findSnapshot (id, pSnapshot, true /* aSetError */);2090 HRESULT rc = findSnapshotById(id, pSnapshot, true /* aSetError */); 2091 2091 if (FAILED(rc)) return rc; 2092 2092 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r33298 r33300 3346 3346 <interface 3347 3347 name="IMachine" extends="$unknown" 3348 uuid=" 5c91359b-5bdb-4518-9bd1-5f2c50a3c129"3348 uuid="14136b33-438a-45de-884c-550e9eb34f23" 3349 3349 wsmap="managed" 3350 3350 > … … 3797 3797 <link to="#settingsModified"/> returns @c false) 3798 3798 </li> 3799 <li><link to="IMachine::setCurrentSnapshot"/>3800 </li>3801 3799 </ul> 3802 3800 … … 5068 5066 </method > 5069 5067 5070 <method name="getSnapshot"> 5071 <desc> 5068 <method name="findSnapshot"> 5069 <desc> 5070 Returns a snapshot of this machine with the given name or UUID. 5071 5072 5072 Returns a snapshot of this machine with the given UUID. 5073 A @c null UUIDcan be used to obtain the first snapshot5073 A @c null argument can be used to obtain the first snapshot 5074 5074 taken on this machine. This is useful if you want to traverse 5075 5075 the whole tree of snapshots starting from the root. … … 5080 5080 5081 5081 </desc> 5082 <param name="id" type="uuid" mod="string" dir="in"> 5083 <desc>UUID of the snapshot to get</desc> 5084 </param> 5085 <param name="snapshot" type="ISnapshot" dir="return"> 5086 <desc>Snapshot object with the given UUID.</desc> 5087 </param> 5088 </method> 5089 5090 <method name="findSnapshot"> 5091 <desc> 5092 Returns a snapshot of this machine with the given name. 5093 5094 <result name="VBOX_E_OBJECT_NOT_FOUND"> 5095 Virtual machine has no snapshots or snapshot not found. 5096 </result> 5097 5098 </desc> 5099 <param name="name" type="wstring" dir="in"> 5100 <desc>Name of the snapshot to find</desc> 5082 <param name="nameOrId" type="wstring" dir="in"> 5083 <desc>What to search for. Name or UUID of the snapshot to find</desc> 5101 5084 </param> 5102 5085 <param name="snapshot" type="ISnapshot" dir="return"> 5103 5086 <desc>Snapshot object with the given name.</desc> 5104 </param>5105 </method>5106 5107 <method name="setCurrentSnapshot">5108 <desc>5109 Sets the current snapshot of this machine.5110 <note>5111 In the current implementation, this operation is not5112 implemented.5113 </note>5114 </desc>5115 <param name="id" type="uuid" mod="string" dir="in">5116 <desc>UUID of the snapshot to set as the current snapshot.</desc>5117 5087 </param> 5118 5088 </method> -
trunk/src/VBox/Main/include/MachineImpl.h
r33237 r33300 491 491 STDMETHOD(Delete)(ComSafeArrayIn(IMedium*, aMedia), IProgress **aProgress); 492 492 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription); 493 STDMETHOD(GetSnapshot)(IN_BSTR aId, ISnapshot **aSnapshot); 494 STDMETHOD(FindSnapshot)(IN_BSTR aName, ISnapshot **aSnapshot); 495 STDMETHOD(SetCurrentSnapshot)(IN_BSTR aId); 493 STDMETHOD(FindSnapshot)(IN_BSTR aNameOrId, ISnapshot **aSnapshot); 496 494 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount); 497 495 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName); … … 735 733 const Guid *puuidSnapshot); 736 734 737 HRESULT findSnapshot(const Guid &aId, ComObjPtr<Snapshot> &aSnapshot, 738 bool aSetError = false); 739 HRESULT findSnapshot(IN_BSTR aName, ComObjPtr<Snapshot> &aSnapshot, 740 bool aSetError = false); 735 HRESULT findSnapshotById(const Guid &aId, 736 ComObjPtr<Snapshot> &aSnapshot, 737 bool aSetError = false); 738 HRESULT findSnapshotByName(const Utf8Str &strName, 739 ComObjPtr<Snapshot> &aSnapshot, 740 bool aSetError = false); 741 741 742 742 HRESULT getStorageControllerByName(const Utf8Str &aName,
Note:
See TracChangeset
for help on using the changeset viewer.