summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2023-03-01 15:36:26 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2023-03-01 15:36:26 +0000
commit15696d644472f5a883252660d4ec1f906637418b (patch)
tree2554a4e1831360f643ef793c9286dff8a9e5e4d8 /src/VBox/Frontends
parent506199ee74d1ae72d5701de24d425c061215642c (diff)
downloadVirtualBox-svn-15696d644472f5a883252660d4ec1f906637418b.tar.gz
FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Storage stuff related to boot dialog.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@98805 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Frontends')
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp5
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h7
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp49
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h2
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp135
-rw-r--r--src/VBox/Frontends/VirtualBox/src/runtime/UISession.h4
6 files changed, 144 insertions, 58 deletions
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp b/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp
index 4ba9e99499d..fe5323bc9fd 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp
@@ -52,8 +52,8 @@
#include "CMediumAttachment.h"
#include "CStorageController.h"
-UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent, const CMachine &comMachine)
- :QIWithRetranslateUI<QIMainDialog>(pParent)
+UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent)
+ : QIWithRetranslateUI<QIMainDialog>(pParent)
, m_pParent(pParent)
, m_pCentralWidget(0)
, m_pMainLayout(0)
@@ -65,7 +65,6 @@ UIBootFailureDialog::UIBootFailureDialog(QWidget *pParent, const CMachine &comMa
, m_pBootImageLabel(0)
, m_pIconLabel(0)
, m_pSuppressDialogCheckBox(0)
- , m_comMachine(comMachine)
{
configure();
}
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h b/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h
index 8235f229798..bb07f89c7dd 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h
@@ -46,10 +46,6 @@ class QIDialogButtonBox;
class QIRichTextLabel;
class UIFilePathSelector;
-/* COM includes: */
-#include "COMEnums.h"
-#include "CMachine.h"
-
/** QIDialog extension providing GUI with a dialog to select an existing medium. */
class UIBootFailureDialog : public QIWithRetranslateUI<QIMainDialog>
{
@@ -67,7 +63,7 @@ public:
ReturnCode_Max
};
- UIBootFailureDialog(QWidget *pParent, const CMachine &comMachine);
+ UIBootFailureDialog(QWidget *pParent);
~UIBootFailureDialog();
QString bootMediumPath() const;
@@ -114,7 +110,6 @@ private:
QLabel *m_pBootImageLabel;
QLabel *m_pIconLabel;
QCheckBox *m_pSuppressDialogCheckBox;
- CMachine m_comMachine;
};
#endif /* !FEQT_INCLUDED_SRC_runtime_UIBootFailureDialog_h */
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
index bb806ff7ddf..fa7ce31cffc 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
@@ -3031,7 +3031,7 @@ void UIMachineLogic::activateScreenSaver()
void UIMachineLogic::showBootFailureDialog()
{
- UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow(), machine());
+ UIBootFailureDialog *pBootFailureDialog = new UIBootFailureDialog(activeMachineWindow());
AssertPtrReturnVoid(pBootFailureDialog);
int iResult = pBootFailureDialog->exec(false);
@@ -3041,57 +3041,12 @@ void UIMachineLogic::showBootFailureDialog()
QFileInfo bootMediumFileInfo(strISOPath);
if (bootMediumFileInfo.exists() && bootMediumFileInfo.isReadable())
- mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));
+ uimachine()->mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));
if (iResult == static_cast<int>(UIBootFailureDialog::ReturnCode_Reset))
reset(false);
}
-bool UIMachineLogic::mountBootMedium(const QUuid &uMediumId)
-{
- AssertReturn(!uMediumId.isNull(), false);
-
- CVirtualBox comVBox = uiCommon().virtualBox();
- CMachine &comMachine = machine();
- const CGuestOSType &comOsType = comVBox.GetGuestOSType(comMachine.GetOSTypeId());
- /* Get recommended controller bus & type: */
- const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
- const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
-
- CMediumAttachment comAttachment;
- /* Search for an attachment of required bus & type: */
- foreach (const CMediumAttachment &comCurrentAttachment, comMachine.GetMediumAttachments())
- {
- /* Determine current attachment's controller: */
- const CStorageController &comCurrentController = comMachine.GetStorageControllerByName(comCurrentAttachment.GetController());
-
- if ( comCurrentController.GetBus() == enmRecommendedDvdBus
- && comCurrentController.GetControllerType() == enmRecommendedDvdType
- && comCurrentAttachment.GetType() == KDeviceType_DVD)
- {
- comAttachment = comCurrentAttachment;
- break;
- }
- }
- AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
-
- const UIMedium guiMedium = uiCommon().medium(uMediumId);
- const CMedium comMedium = guiMedium.medium();
-
- /* Mount medium to the predefined port/device: */
- comMachine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */);
- bool fSuccess = comMachine.isOk();
-
- QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());
-
- /* Show error message if necessary: */
- if (!fSuccess)
- msgCenter().cannotRemountMedium(comMachine, guiMedium, true /* mount? */, false /* retry? */, pParent);
- else
- fSuccess = uimachine()->saveSettings();
- return fSuccess;
-}
-
void UIMachineLogic::reset(bool fShowConfirmation)
{
if ( !fShowConfirmation
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
index 0c924ab0b43..15ef1defdc2 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
@@ -375,8 +375,6 @@ private:
void activateScreenSaver();
/* Shows the boot failure dialog through which user can mount a boot DVD and reset the vm. */
void showBootFailureDialog();
- /** Attempts to mount medium with @p uMediumId to the machine if it can find an appropriate controller and port. */
- bool mountBootMedium(const QUuid &uMediumId);
/** Resets the machine. If @p fShowConfirmation is true then a confirmation messag box is shown first. */
void reset(bool fShowConfirmation);
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp b/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
index 9da9df1ef59..b31bafb39c9 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
@@ -49,6 +49,7 @@
#include "UIMachineWindow.h"
#include "UIMedium.h"
#include "UIMessageCenter.h"
+#include "UIModalWindowManager.h"
#include "UIMousePointerShapeData.h"
#include "UINotificationCenter.h"
#include "UISession.h"
@@ -708,6 +709,140 @@ bool UISession::acquireAmountOfImmutableImages(ulong &cAmount)
return UICommon::acquireAmountOfImmutableImages(comMachine, cAmount);
}
+bool UISession::mountBootMedium(const QUuid &uMediumId)
+{
+ AssertReturn(!uMediumId.isNull(), false);
+
+ /* Get recommended controller bus & type: */
+ CVirtualBox comVBox = uiCommon().virtualBox();
+ const CGuestOSType comOsType = comVBox.GetGuestOSType(osTypeId());
+ if (!comVBox.isOk())
+ {
+ UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
+ return false;
+ }
+ const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
+ if (!comOsType.isOk())
+ {
+ UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType);
+ return false;
+ }
+ const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
+ if (!comOsType.isOk())
+ {
+ UINotificationMessage::cannotAcquireGuestOSTypeParameter(comOsType);
+ return false;
+ }
+
+ /* Search for an attachment of required bus & type: */
+ CMachine comMachine = machine();
+ CMediumAttachmentVector comMediumAttachments = comMachine.GetMediumAttachments();
+ bool fSuccess = comMachine.isOk();
+ if (!fSuccess)
+ UINotificationMessage::cannotAcquireMachineParameter(comMachine);
+ else
+ {
+ CMediumAttachment comChosenAttachment;
+ QString strChosenControllerName;
+ LONG iChosenAttachmentPort = 0;
+ LONG iChosenAttachmentDevice = 0;
+ foreach (const CMediumAttachment &comAttachment, comMediumAttachments)
+ {
+ /* Get attachment type: */
+ const KDeviceType enmCurrentDeviceType = comAttachment.GetType();
+ fSuccess = comAttachment.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
+ break;
+ }
+ /* And make sure it's DVD: */
+ if (enmCurrentDeviceType != KDeviceType_DVD)
+ continue;
+
+ /* Get controller name: */
+ const QString strControllerName = comAttachment.GetController();
+ fSuccess = comAttachment.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
+ break;
+ }
+ /* And look for corresponding controller: */
+ const CStorageController comCurrentController = comMachine.GetStorageControllerByName(strControllerName);
+ fSuccess = comMachine.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireMachineParameter(comMachine);
+ break;
+ }
+
+ /* Get current controller bus: */
+ const KStorageBus enmCurrentBus = comCurrentController.GetBus();
+ fSuccess = comCurrentController.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
+ break;
+ }
+ /* Get current controller type: */
+ const KStorageControllerType enmCurrentType = comCurrentController.GetControllerType();
+ fSuccess = comCurrentController.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireStorageControllerParameter(comCurrentController);
+ break;
+ }
+ /* And check if they are suitable: */
+ if ( enmCurrentBus != enmRecommendedDvdBus
+ || enmCurrentType != enmRecommendedDvdType)
+ continue;
+
+ /* Get current attachment port: */
+ iChosenAttachmentPort = comAttachment.GetPort();
+ fSuccess = comAttachment.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
+ break;
+ }
+ /* Get current attachment device: */
+ iChosenAttachmentDevice = comAttachment.GetDevice();
+ fSuccess = comAttachment.isOk();
+ if (!fSuccess)
+ {
+ UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
+ break;
+ }
+
+ /* Everything is nice it seems: */
+ comChosenAttachment = comAttachment;
+ strChosenControllerName = strControllerName;
+ break;
+ }
+ AssertMsgReturn(!comChosenAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
+
+ /* Get medium to mount: */
+ const UIMedium guiMedium = uiCommon().medium(uMediumId);
+ const CMedium comMedium = guiMedium.medium();
+
+ /* Mount medium to the predefined port/device: */
+ comMachine.MountMedium(strChosenControllerName,
+ iChosenAttachmentPort, iChosenAttachmentDevice,
+ comMedium, false /* force */);
+ fSuccess = comMachine.isOk();
+ if (!fSuccess)
+ {
+ QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());
+ msgCenter().cannotRemountMedium(machine(), guiMedium, true /* mount? */, false /* retry? */, pParent);
+ }
+ else
+ fSuccess = saveSettings();
+ }
+
+ return fSuccess;
+}
+
bool UISession::usbDevices(QList<USBDeviceInfo> &guiUSBDevices)
{
const CHost comHost = uiCommon().host();
diff --git a/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h b/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
index 99654a4dc65..082afc6eb15 100644
--- a/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
+++ b/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
@@ -333,6 +333,10 @@ public:
/** Calculates @a cAmount of immutable images. */
bool acquireAmountOfImmutableImages(ulong &cAmount);
+
+ /** Attempts to mount medium with @p uMediumId to the machine
+ * if it can find an appropriate controller and port. */
+ bool mountBootMedium(const QUuid &uMediumId);
/** @} */
/** @name USB stuff.