VirtualBox

Changeset 98805 in vbox


Ignore:
Timestamp:
Mar 1, 2023 3:36:26 PM (21 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Storage stuff related to boot dialog.

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  
    5353#include "CStorageController.h"
    5454
    55 UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent, const CMachine &comMachine)
    56     :QIWithRetranslateUI<QIMainDialog>(pParent)
     55UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent)
     56    : QIWithRetranslateUI<QIMainDialog>(pParent)
    5757    , m_pParent(pParent)
    5858    , m_pCentralWidget(0)
     
    6666    , m_pIconLabel(0)
    6767    , m_pSuppressDialogCheckBox(0)
    68     , m_comMachine(comMachine)
    6968{
    7069    configure();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h

    r98103 r98805  
    4747class UIFilePathSelector;
    4848
    49 /* COM includes: */
    50 #include "COMEnums.h"
    51 #include "CMachine.h"
    52 
    5349/** QIDialog extension providing GUI with a dialog to select an existing medium. */
    5450class UIBootFailureDialog : public QIWithRetranslateUI<QIMainDialog>
     
    6864    };
    6965
    70     UIBootFailureDialog(QWidget *pParent, const CMachine &comMachine);
     66    UIBootFailureDialog(QWidget *pParent);
    7167    ~UIBootFailureDialog();
    7268    QString bootMediumPath() const;
     
    115111    QLabel               *m_pIconLabel;
    116112    QCheckBox            *m_pSuppressDialogCheckBox;
    117     CMachine              m_comMachine;
    118113};
    119114
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98787 r98805  
    30323032void UIMachineLogic::showBootFailureDialog()
    30333033{
    3034     UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow(), machine());
     3034    UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow());
    30353035    AssertPtrReturnVoid(pBootFailureDialog);
    30363036
     
    30423042    QFileInfo bootMediumFileInfo(strISOPath);
    30433043    if (bootMediumFileInfo.exists() && bootMediumFileInfo.isReadable())
    3044         mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));
     3044        uimachine()->mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));
    30453045
    30463046    if (iResult == static_cast<int>(UIBootFailureDialog::ReturnCode_Reset))
    30473047        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() == enmRecommendedDvdBus
    3069             && comCurrentController.GetControllerType() == enmRecommendedDvdType
    3070             && 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     else
    3091         fSuccess = uimachine()->saveSettings();
    3092     return fSuccess;
    30933048}
    30943049
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r98749 r98805  
    376376    /* Shows the boot failure dialog through which user can mount a boot DVD and reset the vm. */
    377377    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);
    380378    /** Resets the machine. If @p fShowConfirmation is true then a confirmation messag box is shown first. */
    381379    void reset(bool fShowConfirmation);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98801 r98805  
    5050#include "UIMedium.h"
    5151#include "UIMessageCenter.h"
     52#include "UIModalWindowManager.h"
    5253#include "UIMousePointerShapeData.h"
    5354#include "UINotificationCenter.h"
     
    709710}
    710711
     712bool 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
    711846bool UISession::usbDevices(QList<USBDeviceInfo> &guiUSBDevices)
    712847{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98801 r98805  
    334334        /** Calculates @a cAmount of immutable images. */
    335335        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);
    336340    /** @} */
    337341
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette