VirtualBox

Changeset 83752 in vbox for trunk/src


Ignore:
Timestamp:
Apr 17, 2020 1:34:45 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137273
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Implementing cloud machine power down stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r83709 r83752  
    931931             .arg(CConsole(console).GetMachine().GetName()),
    932932          UIErrorString::formatErrorInfo(console));
     933}
     934
     935void UIMessageCenter::cannotPowerDownMachine(const CCloudMachine &comMachine) const
     936{
     937    error(0, MessageType_Error,
     938          tr("Failed to stop the virtual machine <b>%1</b>.")
     939             .arg(CCloudMachine(comMachine).GetName()),
     940          UIErrorString::formatErrorInfo(comMachine));
    933941}
    934942
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r83709 r83752  
    295295    void cannotACPIShutdownMachine(const CConsole &console) const;
    296296    void cannotPowerDownMachine(const CConsole &console) const;
     297    void cannotPowerDownMachine(const CCloudMachine &comMachine) const;
    297298    void cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const;
    298299    bool confirmStartMultipleMachines(const QString &strNames) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r83751 r83752  
    847847            continue;
    848848
    849         /* For local machine: */
    850         if (pItem->itemType() == UIVirtualMachineItem::ItemType_Local)
    851         {
    852             /* Open a session to modify VM state: */
    853             CSession comSession = uiCommon().openExistingSession(pItem->id());
    854             if (comSession.isNull())
    855                 return;
    856 
    857             /* Get session console: */
    858             CConsole comConsole = comSession.GetConsole();
    859             /* Pause/resume VM: */
     849        /* Open a session to modify VM state: */
     850        CSession comSession = uiCommon().openExistingSession(pItem->id());
     851        if (comSession.isNull())
     852            return;
     853
     854        /* Get session console: */
     855        CConsole comConsole = comSession.GetConsole();
     856        /* Pause/resume VM: */
     857        if (fPause)
     858            comConsole.Pause();
     859        else
     860            comConsole.Resume();
     861        if (!comConsole.isOk())
     862        {
    860863            if (fPause)
    861                 comConsole.Pause();
     864                msgCenter().cannotPauseMachine(comConsole);
    862865            else
    863                 comConsole.Resume();
    864             if (!comConsole.isOk())
    865             {
    866                 if (fPause)
    867                     msgCenter().cannotPauseMachine(comConsole);
    868                 else
    869                     msgCenter().cannotResumeMachine(comConsole);
    870             }
    871 
    872             /* Unlock machine finally: */
    873             comSession.UnlockMachine();
    874         }
    875         /* For real cloud machine: */
    876         else if (pItem->itemType() == UIVirtualMachineItem::ItemType_CloudReal)
    877         {
    878             if (fPause)
    879                 pItem->toCloud()->pause(this);
    880             else
    881                 pItem->toCloud()->resume(this);
    882         }
     866                msgCenter().cannotResumeMachine(comConsole);
     867        }
     868
     869        /* Unlock machine finally: */
     870        comSession.UnlockMachine();
    883871    }
    884872}
     
    10591047    foreach (UIVirtualMachineItem *pItem, itemsToPowerOff)
    10601048    {
    1061         /* Open a session to modify VM state: */
    1062         CSession comSession = uiCommon().openExistingSession(pItem->id());
    1063         if (comSession.isNull())
    1064             break;
    1065 
    1066         /* Get session console: */
    1067         CConsole comConsole = comSession.GetConsole();
    1068         /* Prepare machine power down: */
    1069         CProgress comProgress = comConsole.PowerDown();
    1070         if (!comConsole.isOk())
    1071             msgCenter().cannotPowerDownMachine(comConsole);
    1072         else
    1073         {
    1074             /* Show machine power down progress: */
    1075             msgCenter().showModalProgressDialog(comProgress, pItem->name(), ":/progress_poweroff_90px.png");
    1076             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1077                 msgCenter().cannotPowerDownMachine(comProgress, pItem->name());
    1078         }
    1079 
    1080         /* Unlock machine finally: */
    1081         comSession.UnlockMachine();
     1049        /* For local machine: */
     1050        if (pItem->itemType() == UIVirtualMachineItem::ItemType_Local)
     1051        {
     1052            /* Open a session to modify VM state: */
     1053            CSession comSession = uiCommon().openExistingSession(pItem->id());
     1054            if (comSession.isNull())
     1055                break;
     1056
     1057            /* Get session console: */
     1058            CConsole comConsole = comSession.GetConsole();
     1059            /* Prepare machine power down: */
     1060            CProgress comProgress = comConsole.PowerDown();
     1061            if (!comConsole.isOk())
     1062                msgCenter().cannotPowerDownMachine(comConsole);
     1063            else
     1064            {
     1065                /* Show machine power down progress: */
     1066                msgCenter().showModalProgressDialog(comProgress, pItem->name(), ":/progress_poweroff_90px.png");
     1067                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     1068                    msgCenter().cannotPowerDownMachine(comProgress, pItem->name());
     1069            }
     1070
     1071            /* Unlock machine finally: */
     1072            comSession.UnlockMachine();
     1073        }
     1074        /* For real cloud machine: */
     1075        else if (pItem->itemType() == UIVirtualMachineItem::ItemType_CloudReal)
     1076        {
     1077            /* Acquire cloud machine: */
     1078            CCloudMachine comCloudMachine = pItem->toCloud()->machine();
     1079            /* Prepare machine power down: */
     1080            CProgress comProgress = comCloudMachine.PowerDown();
     1081            if (!comCloudMachine.isOk())
     1082                msgCenter().cannotPowerDownMachine(comCloudMachine);
     1083            else
     1084            {
     1085                /* Show machine power down progress: */
     1086                msgCenter().showModalProgressDialog(comProgress, pItem->name(), ":/progress_poweroff_90px.png");
     1087                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     1088                    msgCenter().cannotPowerDownMachine(comProgress, pItem->name());
     1089                /* Update info in any case: */
     1090                pItem->toCloud()->updateInfoAsync(false /* delayed? */);
     1091            }
     1092        }
    10821093    }
    10831094}
     
    19922003        case UIActionIndexST_M_Machine_T_Pause:
    19932004        {
    1994             return isAtLeastOneItemStarted(items);
     2005            return isItemsLocal(items) &&
     2006                   isAtLeastOneItemStarted(items);
    19952007        }
    19962008        case UIActionIndexST_M_Group_S_Reset:
     
    20242036        case UIActionIndexST_M_Machine_M_Close:
    20252037        {
    2026             return isItemsLocal(items) &&
    2027                    isAtLeastOneItemStarted(items);
     2038            return isAtLeastOneItemStarted(items);
    20282039        }
    20292040        case UIActionIndexST_M_Group_M_Close_S_Detach:
     
    20492060        case UIActionIndexST_M_Machine_M_Close_S_PowerOff:
    20502061        {
    2051             return isItemsLocal(items) &&
    2052                    isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
     2062            return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items);
    20532063        }
    20542064        default:
Note: See TracChangeset for help on using the changeset viewer.

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