Changeset 93638 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 7, 2022 1:02:17 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r93545 r93638 971 971 || pItem->itemType() == UIVirtualMachineItemType_Local) 972 972 { 973 CUnattended comUnattendedInstaller = uiCommon().virtualBox().CreateUnattendedInstaller(); 974 AssertMsg(!comUnattendedInstaller.isNull(), ("Could not create unattended installer!\n")); 975 973 976 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 974 977 QWidget *pWizardParent = windowManager().realParentWindow(this); 975 978 UISafePointerWizardNewVM pWizard = new UIWizardNewVM(pWizardParent, actionPool(), 976 m_pWidget->fullGroupName(), "gui-createvm" );979 m_pWidget->fullGroupName(), "gui-createvm", comUnattendedInstaller); 977 980 windowManager().registerNewParent(pWizard, pWizardParent); 978 979 CUnattended comUnattendedInstaller = uiCommon().virtualBox().CreateUnattendedInstaller();980 AssertMsg(!comUnattendedInstaller.isNull(), ("Could not create unattended installer!\n"));981 982 UIUnattendedInstallData unattendedInstallData;983 unattendedInstallData.m_strUserName = comUnattendedInstaller.GetUser();984 unattendedInstallData.m_strPassword = comUnattendedInstaller.GetPassword();985 unattendedInstallData.m_fInstallGuestAdditions = comUnattendedInstaller.GetInstallGuestAdditions();986 unattendedInstallData.m_strGuestAdditionsISOPath = comUnattendedInstaller.GetAdditionsIsoPath();987 unattendedInstallData.m_uSelectedWindowsImageIndex = comUnattendedInstaller.GetImageIndex();988 pWizard->setDefaultUnattendedInstallData(unattendedInstallData);989 981 990 982 /* Execute wizard: */ 991 983 pWizard->exec(); 992 984 993 /* Cache unattended install related info and delete the wizard before handling the unattended install stuff: */994 unattendedInstallData = pWizard->unattendedInstallData();995 985 bool fStartHeadless = pWizard->startHeadless(); 986 bool fUnattendedEnabled = pWizard->isUnattendedEnabled(); 987 QString strMachineId = pWizard->createdMachineId().toString(); 996 988 delete pWizard; 997 989 /* Handle unattended install stuff: */ 998 if ( unattendedInstallData.m_fUnattendedEnabled)999 startUnattendedInstall(comUnattendedInstaller, unattendedInstallData);990 if (fUnattendedEnabled) 991 startUnattendedInstall(comUnattendedInstaller, fStartHeadless, strMachineId); 1000 992 } 1001 993 /* For cloud machine: */ … … 2528 2520 } 2529 2521 2530 void UIVirtualBoxManager::startUnattendedInstall(CUnattended &comUnattendedInstaller, const UIUnattendedInstallData &unattendedData) 2522 void UIVirtualBoxManager::startUnattendedInstall(CUnattended &comUnattendedInstaller, 2523 bool fStartHeadless, const QString &strMachineId) 2531 2524 { 2532 2525 CVirtualBox comVBox = uiCommon().virtualBox(); 2533 CMachine comMachine = comVBox.FindMachine( unattendedData.m_uMachineUid.toString());2526 CMachine comMachine = comVBox.FindMachine(strMachineId); 2534 2527 if (comMachine.isNull()) 2535 2528 return; 2536 2537 if (!QFileInfo(unattendedData.m_strISOPath).exists())2538 {2539 /// @todo Show a relavant error message here2540 return;2541 }2542 2543 comUnattendedInstaller.SetIsoPath(unattendedData.m_strISOPath);2544 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2545 comUnattendedInstaller.SetMachine(comMachine);2546 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2547 comUnattendedInstaller.SetUser(unattendedData.m_strUserName);2548 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2549 comUnattendedInstaller.SetPassword(unattendedData.m_strPassword);2550 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2551 comUnattendedInstaller.SetHostname(unattendedData.m_strHostnameDomainName);2552 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2553 comUnattendedInstaller.SetProductKey(unattendedData.m_strProductKey);2554 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2555 comUnattendedInstaller.SetInstallGuestAdditions(unattendedData.m_fInstallGuestAdditions);2556 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2557 comUnattendedInstaller.SetAdditionsIsoPath(unattendedData.m_strGuestAdditionsISOPath);2558 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2559 if (unattendedData.m_uSelectedWindowsImageIndex != 0)2560 {2561 comUnattendedInstaller.SetImageIndex(unattendedData.m_uSelectedWindowsImageIndex);2562 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller));2563 }2564 2529 2565 2530 comUnattendedInstaller.Prepare(); … … 2570 2535 AssertReturnVoid(checkUnattendedInstallError(comUnattendedInstaller)); 2571 2536 2572 UICommon::LaunchMode enmLaunchMode = UICommon::LaunchMode_Default; 2573 if (unattendedData.m_fStartHeadless) 2574 enmLaunchMode = UICommon::LaunchMode_Headless; 2575 launchMachine(comMachine, enmLaunchMode); 2537 launchMachine(comMachine, fStartHeadless ? UICommon::LaunchMode_Headless : UICommon::LaunchMode_Default); 2576 2538 } 2577 2539 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r93115 r93638 371 371 372 372 /** Creates an unattended installer and uses it to install guest os to newly created vm. */ 373 void startUnattendedInstall(CUnattended &comUnattendedInstaller, const UIUnattendedInstallData &unattendedData);373 void startUnattendedInstall(CUnattended &comUnattendedInstaller, bool fStartHeadless, const QString &strMachineId); 374 374 375 375 /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.cpp
r93546 r93638 322 322 bool UIAdditionalUnattendedOptions::isComplete() const 323 323 { 324 return isHostnameComplete(); 325 } 326 327 bool UIAdditionalUnattendedOptions::isHostnameComplete() const 328 { 324 329 if (m_pHostnameDomainNameEditor) 325 330 return m_pHostnameDomainNameEditor->isComplete(); 326 331 return false; 327 332 } 333 328 334 329 335 void UIAdditionalUnattendedOptions::mark() -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.h
r93541 r93638 130 130 QString hostnameDomainName() const; 131 131 bool isComplete() const; 132 bool isHostnameComplete() const; 132 133 void mark(); 133 134 void disableEnableProductKeyWidgets(bool fEnabled); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r93568 r93638 36 36 #include "CBIOSSettings.h" 37 37 #include "CGraphicsAdapter.h" 38 #include "CExtPackManager.h" 38 39 #include "CMediumFormat.h" 40 #include "CStorageController.h" 39 41 #include "CUSBController.h" 40 42 #include "CUSBDeviceFilters.h" 41 #include "CExtPackManager.h" 42 #include "CStorageController.h" 43 #include "CUnattended.h" 43 44 44 45 /* Namespaces: */ … … 46 47 47 48 48 UIUnattendedInstallData::UIUnattendedInstallData()49 : m_fUnattendedEnabled(false)50 , m_fStartHeadless(false)51 {52 }53 54 49 UIWizardNewVM::UIWizardNewVM(QWidget *pParent, UIActionPool *pActionPool, 55 const QString &strMachineGroup /* = QString() */,56 const QString &strHelpHashtag /* = QString() */)50 const QString &strMachineGroup, const QString &strHelpHashtag, 51 CUnattended &comUnattended) 57 52 : UINativeWizard(pParent, WizardType_NewVM, WizardMode_Auto, strHelpHashtag) 58 53 , m_strMachineGroup(strMachineGroup) … … 74 69 , m_fEmptyDiskRecommended(false) 75 70 , m_pActionPool(pActionPool) 71 , m_comUnattended(comUnattended) 72 , m_fStartHeadless(false) 76 73 { 77 74 #ifndef VBOX_WS_MAC … … 177 174 return false; 178 175 } 179 return attachDefaultDevices(); 176 177 if (!attachDefaultDevices()) 178 { 179 cleanWizard(); 180 return false; 181 } 182 183 if (isUnattendedEnabled()) 184 { 185 m_comUnattended.SetMachine(m_machine); 186 if (!checkUnattendedInstallError(m_comUnattended)) 187 { 188 cleanWizard(); 189 return false; 190 } 191 } 192 return true; 180 193 } 181 194 … … 547 560 } 548 561 549 void UIWizardNewVM::setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData)550 {551 m_unattendedInstallData = unattendedInstallData;552 }562 // void UIWizardNewVM::setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData) 563 // { 564 // m_unattendedInstallData = unattendedInstallData; 565 // } 553 566 554 567 CMedium &UIWizardNewVM::virtualDisk() … … 653 666 bool UIWizardNewVM::installGuestAdditions() const 654 667 { 655 return m_unattendedInstallData.m_fInstallGuestAdditions; 668 AssertReturn(!m_comUnattended.isNull(), false); 669 return m_comUnattended.GetInstallGuestAdditions(); 656 670 } 657 671 658 672 void UIWizardNewVM::setInstallGuestAdditions(bool fInstallGA) 659 673 { 660 m_unattendedInstallData.m_fInstallGuestAdditions = fInstallGA; 674 AssertReturnVoid(!m_comUnattended.isNull()); 675 m_comUnattended.SetInstallGuestAdditions(fInstallGA); 676 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 661 677 } 662 678 663 679 bool UIWizardNewVM::startHeadless() const 664 680 { 665 return m_ unattendedInstallData.m_fStartHeadless;681 return m_fStartHeadless; 666 682 } 667 683 668 684 void UIWizardNewVM::setStartHeadless(bool fStartHeadless) 669 685 { 670 m_ unattendedInstallData.m_fStartHeadless = fStartHeadless;686 m_fStartHeadless = fStartHeadless; 671 687 } 672 688 … … 693 709 } 694 710 695 const QString &UIWizardNewVM::ISOFilePath() const 696 { 697 return m_strISOFilePath; 711 QString UIWizardNewVM::ISOFilePath() const 712 { 713 AssertReturn(!m_comUnattended.isNull(), QString()); 714 return m_comUnattended.GetIsoPath(); 698 715 } 699 716 700 717 void UIWizardNewVM::setISOFilePath(const QString &strISOFilePath) 701 718 { 702 m_strISOFilePath = strISOFilePath; 719 AssertReturnVoid(!m_comUnattended.isNull()); 720 m_comUnattended.SetIsoPath(strISOFilePath); 703 721 /* We hide/show unattended install page depending on the value of isUnattendedEnabled: */ 704 722 setUnattendedPageVisible(isUnattendedEnabled()); 705 } 706 707 const QString &UIWizardNewVM::userName() const 708 { 709 return m_unattendedInstallData.m_strUserName; 723 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 724 } 725 726 QString UIWizardNewVM::userName() const 727 { 728 AssertReturn(!m_comUnattended.isNull(), QString()); 729 return m_comUnattended.GetUser(); 710 730 } 711 731 712 732 void UIWizardNewVM::setUserName(const QString &strUserName) 713 733 { 714 m_unattendedInstallData.m_strUserName = strUserName; 715 } 716 717 const QString &UIWizardNewVM::password() const 718 { 719 return m_unattendedInstallData.m_strPassword; 734 AssertReturnVoid(!m_comUnattended.isNull()); 735 m_comUnattended.SetUser(strUserName); 736 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 737 } 738 739 QString UIWizardNewVM::password() const 740 { 741 AssertReturn(!m_comUnattended.isNull(), QString()); 742 return m_comUnattended.GetPassword(); 720 743 } 721 744 722 745 void UIWizardNewVM::setPassword(const QString &strPassword) 723 746 { 724 m_unattendedInstallData.m_strPassword = strPassword; 725 } 726 727 const QString &UIWizardNewVM::guestAdditionsISOPath() const 728 { 729 return m_unattendedInstallData.m_strGuestAdditionsISOPath; 747 AssertReturnVoid(!m_comUnattended.isNull()); 748 m_comUnattended.SetPassword(strPassword); 749 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 750 } 751 752 QString UIWizardNewVM::guestAdditionsISOPath() const 753 { 754 AssertReturn(!m_comUnattended.isNull(), QString()); 755 return m_comUnattended.GetAdditionsIsoPath(); 730 756 } 731 757 732 758 void UIWizardNewVM::setGuestAdditionsISOPath(const QString &strGAISOPath) 733 759 { 734 m_unattendedInstallData.m_strGuestAdditionsISOPath = strGAISOPath; 735 } 736 737 const QString &UIWizardNewVM::hostnameDomainName() const 738 { 739 return m_unattendedInstallData.m_strHostnameDomainName; 760 AssertReturnVoid(!m_comUnattended.isNull()); 761 m_comUnattended.SetAdditionsIsoPath(strGAISOPath); 762 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 763 } 764 765 QString UIWizardNewVM::hostnameDomainName() const 766 { 767 AssertReturn(!m_comUnattended.isNull(), QString()); 768 return m_comUnattended.GetHostname(); 740 769 } 741 770 742 771 void UIWizardNewVM::setHostnameDomainName(const QString &strHostnameDomain) 743 772 { 744 m_unattendedInstallData.m_strHostnameDomainName = strHostnameDomain; 745 } 746 747 const QString &UIWizardNewVM::productKey() const 748 { 749 return m_unattendedInstallData.m_strProductKey; 773 AssertReturnVoid(!m_comUnattended.isNull()); 774 m_comUnattended.SetHostname(strHostnameDomain); 775 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 776 } 777 778 QString UIWizardNewVM::productKey() const 779 { 780 AssertReturn(!m_comUnattended.isNull(), QString()); 781 return m_comUnattended.GetProductKey(); 750 782 } 751 783 752 784 void UIWizardNewVM::setProductKey(const QString &productKey) 753 785 { 754 m_unattendedInstallData.m_strProductKey = productKey; 786 AssertReturnVoid(!m_comUnattended.isNull()); 787 m_comUnattended.SetProductKey(productKey); 788 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 755 789 } 756 790 … … 856 890 void UIWizardNewVM::setSelectedWindowImageIndex(ulong uIndex) 857 891 { 858 m_unattendedInstallData.m_uSelectedWindowsImageIndex = uIndex; 892 AssertReturnVoid(!m_comUnattended.isNull()); 893 m_comUnattended.SetImageIndex(uIndex); 894 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended)); 859 895 } 860 896 861 897 ulong UIWizardNewVM::selectedWindowImageIndex() const 862 898 { 863 return m_unattendedInstallData.m_uSelectedWindowsImageIndex; 899 AssertReturn(!m_comUnattended.isNull(), 0); 900 return m_comUnattended.GetImageIndex(); 864 901 } 865 902 … … 877 914 } 878 915 879 const UIUnattendedInstallData &UIWizardNewVM::unattendedInstallData() const880 {881 m_unattendedInstallData.m_strISOPath = m_strISOFilePath;882 m_unattendedInstallData.m_fUnattendedEnabled = isUnattendedEnabled();883 m_unattendedInstallData.m_uMachineUid = createdMachineId();884 885 return m_unattendedInstallData;886 }887 888 916 bool UIWizardNewVM::isUnattendedEnabled() const 889 917 { 890 if (m_strISOFilePath.isEmpty() || m_strISOFilePath.isNull()) 918 if (m_comUnattended.isNull()) 919 return false; 920 if (m_comUnattended.GetIsoPath().isEmpty()) 891 921 return false; 892 922 if (m_fSkipUnattendedInstall) … … 916 946 setPageVisible(m_iUnattendedInstallPageIndex, fVisible); 917 947 } 948 949 bool UIWizardNewVM::checkUnattendedInstallError(const CUnattended &comUnattended) const 950 { 951 if (!comUnattended.isOk()) 952 { 953 UINotificationMessage::cannotRunUnattendedGuestInstall(comUnattended); 954 return false; 955 } 956 return true; 957 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r93545 r93638 43 43 }; 44 44 45 /** Container for unattended install related data. */46 struct UIUnattendedInstallData47 {48 UIUnattendedInstallData();49 QUuid m_uMachineUid;50 QString m_strISOPath;51 52 bool m_fUnattendedEnabled;53 bool m_fStartHeadless;54 QString m_strUserName;55 QString m_strPassword;56 QString m_strHostnameDomainName;57 QString m_strProductKey;58 bool m_fInstallGuestAdditions;59 QString m_strGuestAdditionsISOPath;60 /* 0 is for no selection. */61 ulong m_uSelectedWindowsImageIndex;62 #if 063 QString m_strDetectedOSVersion;64 QString m_strDetectedOSFlavor;65 QString m_strDetectedOSLanguages;66 QString m_strDetectedOSHints;67 #endif68 };69 70 71 45 /** New Virtual Machine wizard: */ 72 46 class UIWizardNewVM : public UINativeWizard … … 77 51 78 52 UIWizardNewVM(QWidget *pParent, UIActionPool *pActionPool, 79 const QString &strMachineGroup = QString(), const QString &strHelpHashtag = QString());53 const QString &strMachineGroup, const QString &strHelpHashtag, CUnattended &comUnattended); 80 54 bool isUnattendedEnabled() const; 81 55 bool isOSTypeDetectionOK() const; 82 void setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData);83 const UIUnattendedInstallData &unattendedInstallData() const;84 56 bool isGuestOSTypeWindows() const; 85 57 … … 92 64 93 65 const QString &machineGroup() const; 66 QUuid createdMachineId() const; 94 67 95 68 /** @name Setter/getters for vm parameters … … 131 104 void setEFIEnabled(bool fEnabled); 132 105 133 const QString &ISOFilePath() const;106 QString ISOFilePath() const; 134 107 void setISOFilePath(const QString &strISOFilePath); 135 108 136 const QString &userName() const;109 QString userName() const; 137 110 void setUserName(const QString &strUserName); 138 111 139 const QString &password() const;112 QString password() const; 140 113 void setPassword(const QString &strPassword); 141 114 142 const QString &guestAdditionsISOPath() const;115 QString guestAdditionsISOPath() const; 143 116 void setGuestAdditionsISOPath(const QString &strGAISOPath); 144 117 145 const QString &hostnameDomainName() const;118 QString hostnameDomainName() const; 146 119 void setHostnameDomainName(const QString &strHostnameDomainName); 147 120 148 const QString &productKey() const;121 QString productKey() const; 149 122 void setProductKey(const QString &productKey); 150 123 … … 200 173 QString getNextControllerName(KStorageBus type); 201 174 void setUnattendedPageVisible(bool fVisible); 202 /** Returns the Id of newly created VM. */203 QUuid createdMachineId() const;204 175 void deleteVirtualDisk(); 205 176 bool checkUnattendedInstallError(const CUnattended &comUnattended) const; 206 177 /** @name Variables 207 178 * @{ */ … … 215 186 int m_iSASCount; 216 187 int m_iUSBCount; 217 mutable UIUnattendedInstallData m_unattendedInstallData;218 219 /** Path of the ISO file attached to the new vm. Possibly used for the unattended install. */220 QString m_strISOFilePath;221 188 222 189 /** Path of the folder created by this wizard page. Used to remove previously created … … 259 226 QVector<KMediumVariant> m_mediumVariants; 260 227 UIActionPool *m_pActionPool; 228 CUnattended &m_comUnattended; 229 bool m_fStartHeadless; 261 230 /** @} */ 262 231 }; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp
r93607 r93638 959 959 m_pAdditionalOptionsContainer->setDomainName("myguest.virtualbox.org"); 960 960 /* Initialize unattended hostname here since we cannot get the default value from CUnattended this early (unlike username etc): */ 961 pWizard->setHostnameDomainName(m_pAdditionalOptionsContainer->hostnameDomainName()); 961 if (m_pAdditionalOptionsContainer->isHostnameComplete()) 962 pWizard->setHostnameDomainName(m_pAdditionalOptionsContainer->hostnameDomainName()); 962 963 963 964 m_pAdditionalOptionsContainer->blockSignals(false);
Note:
See TracChangeset
for help on using the changeset viewer.