Changeset 98805 in vbox
- Timestamp:
- Mar 1, 2023 3:36:26 PM (21 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp
r98103 r98805 53 53 #include "CStorageController.h" 54 54 55 UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent , const CMachine &comMachine)56 : QIWithRetranslateUI<QIMainDialog>(pParent)55 UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent) 56 : QIWithRetranslateUI<QIMainDialog>(pParent) 57 57 , m_pParent(pParent) 58 58 , m_pCentralWidget(0) … … 66 66 , m_pIconLabel(0) 67 67 , m_pSuppressDialogCheckBox(0) 68 , m_comMachine(comMachine)69 68 { 70 69 configure(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h
r98103 r98805 47 47 class UIFilePathSelector; 48 48 49 /* COM includes: */50 #include "COMEnums.h"51 #include "CMachine.h"52 53 49 /** QIDialog extension providing GUI with a dialog to select an existing medium. */ 54 50 class UIBootFailureDialog : public QIWithRetranslateUI<QIMainDialog> … … 68 64 }; 69 65 70 UIBootFailureDialog(QWidget *pParent , const CMachine &comMachine);66 UIBootFailureDialog(QWidget *pParent); 71 67 ~UIBootFailureDialog(); 72 68 QString bootMediumPath() const; … … 115 111 QLabel *m_pIconLabel; 116 112 QCheckBox *m_pSuppressDialogCheckBox; 117 CMachine m_comMachine;118 113 }; 119 114 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98787 r98805 3032 3032 void UIMachineLogic::showBootFailureDialog() 3033 3033 { 3034 UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow() , machine());3034 UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow()); 3035 3035 AssertPtrReturnVoid(pBootFailureDialog); 3036 3036 … … 3042 3042 QFileInfo bootMediumFileInfo(strISOPath); 3043 3043 if (bootMediumFileInfo.exists() && bootMediumFileInfo.isReadable()) 3044 mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));3044 uimachine()->mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath)); 3045 3045 3046 3046 if (iResult == static_cast<int>(UIBootFailureDialog::ReturnCode_Reset)) 3047 3047 reset(false); 3048 }3049 3050 bool UIMachineLogic::mountBootMedium(const QUuid &uMediumId)3051 {3052 AssertReturn(!uMediumId.isNull(), false);3053 3054 CVirtualBox comVBox = uiCommon().virtualBox();3055 CMachine &comMachine = machine();3056 const CGuestOSType &comOsType = comVBox.GetGuestOSType(comMachine.GetOSTypeId());3057 /* Get recommended controller bus & type: */3058 const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();3059 const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();3060 3061 CMediumAttachment comAttachment;3062 /* Search for an attachment of required bus & type: */3063 foreach (const CMediumAttachment &comCurrentAttachment, comMachine.GetMediumAttachments())3064 {3065 /* Determine current attachment's controller: */3066 const CStorageController &comCurrentController = comMachine.GetStorageControllerByName(comCurrentAttachment.GetController());3067 3068 if ( comCurrentController.GetBus() == enmRecommendedDvdBus3069 && comCurrentController.GetControllerType() == enmRecommendedDvdType3070 && comCurrentAttachment.GetType() == KDeviceType_DVD)3071 {3072 comAttachment = comCurrentAttachment;3073 break;3074 }3075 }3076 AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);3077 3078 const UIMedium guiMedium = uiCommon().medium(uMediumId);3079 const CMedium comMedium = guiMedium.medium();3080 3081 /* Mount medium to the predefined port/device: */3082 comMachine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */);3083 bool fSuccess = comMachine.isOk();3084 3085 QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());3086 3087 /* Show error message if necessary: */3088 if (!fSuccess)3089 msgCenter().cannotRemountMedium(comMachine, guiMedium, true /* mount? */, false /* retry? */, pParent);3090 else3091 fSuccess = uimachine()->saveSettings();3092 return fSuccess;3093 3048 } 3094 3049 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r98749 r98805 376 376 /* Shows the boot failure dialog through which user can mount a boot DVD and reset the vm. */ 377 377 void showBootFailureDialog(); 378 /** Attempts to mount medium with @p uMediumId to the machine if it can find an appropriate controller and port. */379 bool mountBootMedium(const QUuid &uMediumId);380 378 /** Resets the machine. If @p fShowConfirmation is true then a confirmation messag box is shown first. */ 381 379 void reset(bool fShowConfirmation); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98801 r98805 50 50 #include "UIMedium.h" 51 51 #include "UIMessageCenter.h" 52 #include "UIModalWindowManager.h" 52 53 #include "UIMousePointerShapeData.h" 53 54 #include "UINotificationCenter.h" … … 709 710 } 710 711 712 bool UISession::mountBootMedium(const QUuid &uMediumId) 713 { 714 AssertReturn(!uMediumId.isNull(), false); 715 716 /* Get recommended controller bus & type: */ 717 CVirtualBox comVBox = uiCommon().virtualBox(); 718 const CGuestOSType comOsType = comVBox.GetGuestOSType(osTypeId()); 719 if (!comVBox.isOk()) 720 { 721 UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox); 722 return false; 723 } 724 const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus(); 725 if (!comOsType.isOk()) 726 { 727 UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType); 728 return false; 729 } 730 const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController(); 731 if (!comOsType.isOk()) 732 { 733 UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType); 734 return false; 735 } 736 737 /* Search for an attachment of required bus & type: */ 738 CMachine comMachine = machine(); 739 CMediumAttachmentVector comMediumAttachments = comMachine.GetMediumAttachments(); 740 bool fSuccess = comMachine.isOk(); 741 if (!fSuccess) 742 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 743 else 744 { 745 CMediumAttachment comChosenAttachment; 746 QString strChosenControllerName; 747 LONG iChosenAttachmentPort = 0; 748 LONG iChosenAttachmentDevice = 0; 749 foreach (const CMediumAttachment &comAttachment, comMediumAttachments) 750 { 751 /* Get attachment type: */ 752 const KDeviceType enmCurrentDeviceType = comAttachment.GetType(); 753 fSuccess = comAttachment.isOk(); 754 if (!fSuccess) 755 { 756 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment); 757 break; 758 } 759 /* And make sure it's DVD: */ 760 if (enmCurrentDeviceType != KDeviceType_DVD) 761 continue; 762 763 /* Get controller name: */ 764 const QString strControllerName = comAttachment.GetController(); 765 fSuccess = comAttachment.isOk(); 766 if (!fSuccess) 767 { 768 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment); 769 break; 770 } 771 /* And look for corresponding controller: */ 772 const CStorageController comCurrentController = comMachine.GetStorageControllerByName(strControllerName); 773 fSuccess = comMachine.isOk(); 774 if (!fSuccess) 775 { 776 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 777 break; 778 } 779 780 /* Get current controller bus: */ 781 const KStorageBus enmCurrentBus = comCurrentController.GetBus(); 782 fSuccess = comCurrentController.isOk(); 783 if (!fSuccess) 784 { 785 UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController); 786 break; 787 } 788 /* Get current controller type: */ 789 const KStorageControllerType enmCurrentType = comCurrentController.GetControllerType(); 790 fSuccess = comCurrentController.isOk(); 791 if (!fSuccess) 792 { 793 UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController); 794 break; 795 } 796 /* And check if they are suitable: */ 797 if ( enmCurrentBus != enmRecommendedDvdBus 798 || enmCurrentType != enmRecommendedDvdType) 799 continue; 800 801 /* Get current attachment port: */ 802 iChosenAttachmentPort = comAttachment.GetPort(); 803 fSuccess = comAttachment.isOk(); 804 if (!fSuccess) 805 { 806 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment); 807 break; 808 } 809 /* Get current attachment device: */ 810 iChosenAttachmentDevice = comAttachment.GetDevice(); 811 fSuccess = comAttachment.isOk(); 812 if (!fSuccess) 813 { 814 UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment); 815 break; 816 } 817 818 /* Everything is nice it seems: */ 819 comChosenAttachment = comAttachment; 820 strChosenControllerName = strControllerName; 821 break; 822 } 823 AssertMsgReturn(!comChosenAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false); 824 825 /* Get medium to mount: */ 826 const UIMedium guiMedium = uiCommon().medium(uMediumId); 827 const CMedium comMedium = guiMedium.medium(); 828 829 /* Mount medium to the predefined port/device: */ 830 comMachine.MountMedium(strChosenControllerName, 831 iChosenAttachmentPort, iChosenAttachmentDevice, 832 comMedium, false /* force */); 833 fSuccess = comMachine.isOk(); 834 if (!fSuccess) 835 { 836 QWidget *pParent = windowManager().realParentWindow(activeMachineWindow()); 837 msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, pParent); 838 } 839 else 840 fSuccess = saveSettings(); 841 } 842 843 return fSuccess; 844 } 845 711 846 bool UISession::usbDevices(QList<USBDeviceInfo> &guiUSBDevices) 712 847 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98801 r98805 334 334 /** Calculates @a cAmount of immutable images. */ 335 335 bool acquireAmountOfImmutableImages(ulong &cAmount); 336 337 /** Attempts to mount medium with @p uMediumId to the machine 338 * if it can find an appropriate controller and port. */ 339 bool mountBootMedium(const QUuid &uMediumId); 336 340 /** @} */ 337 341
Note:
See TracChangeset
for help on using the changeset viewer.