Changeset 67601 in vbox
- Timestamp:
- Jun 26, 2017 11:54:00 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.cpp
r63567 r67601 50 50 bool UIWizardFirstRun::insertMedium() 51 51 { 52 /* Get 'vbox' global object: */ 53 CVirtualBox vbox = vboxGlobal().virtualBox(); 54 /* Determine machine 'OS type': */ 55 const CGuestOSType &osType = vbox.GetGuestOSType(m_machine.GetOSTypeId()); 56 /* Determine recommended controller's 'bus' & 'type': */ 57 KStorageBus dvdCtrBus = osType.GetRecommendedDVDStorageBus(); 58 KStorageControllerType dvdCtrType = osType.GetRecommendedDVDStorageController(); 59 /* Declare null 'dvd' attachment: */ 60 CMediumAttachment cda; 61 /* Enumerate attachments vector: */ 62 const CMediumAttachmentVector &attachments = m_machine.GetMediumAttachments(); 63 for (int i = 0; i < attachments.size(); ++i) 52 /* Prepare result: */ 53 bool fSuccess = true; 54 55 /* Get global VBox object: */ 56 CVirtualBox comVbox = vboxGlobal().virtualBox(); 57 /* Get machine OS type: */ 58 const CGuestOSType &comOsType = comVbox.GetGuestOSType(m_machine.GetOSTypeId()); 59 /* Get recommended controller bus & type: */ 60 const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus(); 61 const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController(); 62 63 /* Prepare null medium attachment: */ 64 CMediumAttachment comAttachment; 65 /* Search for an attachment of required bus & type: */ 66 foreach (const CMediumAttachment &comCurrentAttachment, m_machine.GetMediumAttachments()) 64 67 { 65 /* Get current attachment: */ 66 const CMediumAttachment &attachment = attachments[i]; 67 /* Determine attachment's controller: */ 68 const CStorageController &controller = m_machine.GetStorageControllerByName(attachment.GetController()); 69 /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'dvd': */ 70 if (controller.GetBus() == dvdCtrBus && 71 controller.GetControllerType() == dvdCtrType && 72 attachment.GetType() == KDeviceType_DVD) 68 /* Determine current attachment's controller: */ 69 const CStorageController &comCurrentController = m_machine.GetStorageControllerByName(comCurrentAttachment.GetController()); 70 /* If current controller bus & type are recommended and attachment type is 'dvd': */ 71 if ( comCurrentController.GetBus() == enmRecommendedDvdBus 72 && comCurrentController.GetControllerType() == enmRecommendedDvdType 73 && comCurrentAttachment.GetType() == KDeviceType_DVD) 73 74 { 74 75 /* Remember attachment: */ 75 c da = attachment;76 comAttachment = comCurrentAttachment; 76 77 break; 77 78 } 78 79 } 79 AssertMsg(!cda.isNull(), ("Storage Controller is NOT properly configured!\n")); 80 AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false); 81 82 // In place where the UIWizardFirstRun is currently being opened 83 // we doesn't have to open direct or shared session because it's 84 // already opened for the VM which being cached in this wizard. 85 80 86 /* Get chosen 'dvd' medium to mount: */ 81 QString mediumId = field("id").toString(); 82 UIMedium vmedium = vboxGlobal().medium(mediumId); 83 CMedium medium = vmedium.medium(); /// @todo r=dj can this be cached somewhere? 87 const QString strMediumId = field("id").toString(); 88 const UIMedium guiMedium = vboxGlobal().medium(strMediumId); 89 const CMedium comMedium = guiMedium.medium(); 90 84 91 /* Mount medium to the predefined port/device: */ 85 m_machine.MountMedium(cda.GetController(), cda.GetPort(), cda.GetDevice(), medium, false /* force */); 86 if (m_machine.isOk()) 87 return true; 92 m_machine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */); 93 fSuccess = m_machine.isOk(); 94 95 /* Show error message if necessary: */ 96 if (!fSuccess) 97 msgCenter().cannotRemountMedium(m_machine, guiMedium, true /* mount? */, false /* retry? */, this); 88 98 else 89 99 { 90 msgCenter().cannotRemountMedium(m_machine, vmedium, true /* mount? */, false /* retry? */, this); 91 return false; 100 /* Save machine settings: */ 101 m_machine.SaveSettings(); 102 fSuccess = m_machine.isOk(); 103 104 /* Show error message if necessary: */ 105 if (!fSuccess) 106 msgCenter().cannotSaveMachineSettings(m_machine, this); 92 107 } 108 109 /* Return result: */ 110 return fSuccess; 93 111 } 94 112
Note:
See TracChangeset
for help on using the changeset viewer.