VirtualBox

Changeset 98811 in vbox


Ignore:
Timestamp:
Mar 1, 2023 5:52:24 PM (21 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Network menu init stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r98806 r98811  
    7373#include "CStringFormValue.h"
    7474#include "CStorageController.h"
    75 #ifdef VBOX_WITH_UPDATE_AGENT
    76 # include "CSystemProperties.h"
    77 #endif
     75#include "CSystemProperties.h"
    7876#include "CUnattended.h"
    7977#include "CUpdateAgent.h"
     
    618616        UIErrorString::formatErrorInfo(comAppliance),
    619617        QString(), QString(), pParent);
     618}
     619
     620/* static */
     621void UINotificationMessage::cannotAcquireSystemPropertiesParameter(const CSystemProperties &comProperties)
     622{
     623    createMessage(
     624        QApplication::translate("UIMessageCenter", "System properties failure ..."),
     625        QApplication::translate("UIMessageCenter", "Failed to acquire system properties parameter.") +
     626        UIErrorString::formatErrorInfo(comProperties));
    620627}
    621628
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r98806 r98811  
    7979class CNetworkAdapter;
    8080class CStorageController;
     81class CSystemProperties;
    8182class CVirtualBox;
    8283class CVirtualBoxErrorInfo;
     
    282283        static void cannotAcquireApplianceParameter(const CAppliance &comAppliance,
    283284                                                    UINotificationCenter *pParent = 0);
     285        /** Notifies about inability to acquire ISystemProperties parameter.
     286          * @param  comProperties  Brings the object parameter get acquired from. */
     287        static void cannotAcquireSystemPropertiesParameter(const CSystemProperties &comProperties);
    284288        /** Notifies about inability to acquire IExtPackManager parameter.
    285289          * @param  comVBox  Brings the object parameter get acquired from. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98810 r98811  
    829829{
    830830    return uisession()->acquireWhetherNetworkAdapterEnabled(uSlot, fEnabled);
     831}
     832
     833bool UIMachine::acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled)
     834{
     835    return uisession()->acquireWhetherAtLeastOneNetworkAdapterEnabled(fEnabled);
    831836}
    832837
     
    18701875    {
    18711876        /* Initialize Network menu: */
    1872         bool fAtLeastOneAdapterActive = false;
    1873         const KChipsetType enmChipsetType = uisession()->machine().GetChipsetType();
    1874         ULONG uSlots = uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(enmChipsetType);
    1875         for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
    1876         {
    1877             const CNetworkAdapter &comNetworkAdapter = uisession()->machine().GetNetworkAdapter(uSlot);
    1878             if (comNetworkAdapter.GetEnabled())
    1879             {
    1880                 fAtLeastOneAdapterActive = true;
    1881                 break;
    1882             }
    1883         }
    1884         if (!fAtLeastOneAdapterActive)
     1877        bool fAtLeastOneAdapterEnabled = false;
     1878        acquireWhetherAtLeastOneNetworkAdapterEnabled(fAtLeastOneAdapterEnabled);
     1879        if (!fAtLeastOneAdapterEnabled)
    18851880            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
    18861881                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98810 r98811  
    563563        /** Acquires whether network adapter is enabled. */
    564564        bool acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled);
     565        /** Acquires whether at leasst one network adapter is enabled. */
     566        bool acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled);
    565567        /** Acquires whether network adapter cable is connected. */
    566568        bool acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98810 r98811  
    11071107        else
    11081108            fEnabled = fAdapterEnabled == TRUE;
     1109    }
     1110    return fSuccess;
     1111}
     1112
     1113bool UISession::acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled)
     1114{
     1115    /* Acquire system properties: */
     1116    CVirtualBox comVBox = uiCommon().virtualBox();
     1117    AssertReturn(comVBox.isNotNull(), false);
     1118    CSystemProperties comProperties = comVBox.GetSystemProperties();
     1119    if (!comVBox.isOk())
     1120    {
     1121        UINotificationMessage::cannotAcquireVirtualBoxParameter(comVBox);
     1122        return false;
     1123    }
     1124
     1125    /* Acquire chipset type: */
     1126    KChipsetType enmChipsetType = KChipsetType_Null;
     1127    bool fSuccess = acquireChipsetType(enmChipsetType);
     1128    if (fSuccess)
     1129    {
     1130        /* Acquire maximum network adapters count: */
     1131        const ulong uSlots = comProperties.GetMaxNetworkAdapters(enmChipsetType);
     1132        fSuccess = comProperties.isOk();
     1133        if (!fSuccess)
     1134            UINotificationMessage::cannotAcquireSystemPropertiesParameter(comProperties);
     1135        else
     1136        {
     1137            /* Search for 1st enabled adapter: */
     1138            for (ulong uSlot = 0; uSlot < uSlots; ++uSlot)
     1139            {
     1140                bool fAdapterEnabled = false;
     1141                fSuccess = acquireWhetherNetworkAdapterEnabled(uSlot, fAdapterEnabled);
     1142                if (!fSuccess)
     1143                    break;
     1144                if (!fAdapterEnabled)
     1145                    continue;
     1146                fEnabled = true;
     1147                break;
     1148            }
     1149        }
    11091150    }
    11101151    return fSuccess;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98810 r98811  
    373373        /** Acquires whether network adapter is enabled. */
    374374        bool acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled);
     375        /** Acquires whether at leasst one network adapter is enabled. */
     376        bool acquireWhetherAtLeastOneNetworkAdapterEnabled(bool &fEnabled);
    375377        /** Acquires whether network adapter cable is connected. */
    376378        bool acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected);
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