Changeset 90405 in vbox
- Timestamp:
- Jul 29, 2021 1:02:54 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145993
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r90394 r90405 1707 1707 continue; 1708 1708 1709 /* Open a session to modify VM state: */ 1710 CSession comSession = uiCommon().openExistingSession(pItem->id()); 1711 if (comSession.isNull()) 1712 return; 1713 1714 /* Get session console: */ 1715 CConsole comConsole = comSession.GetConsole(); 1716 /* Get session machine: */ 1717 CMachine comMachine = comSession.GetMachine(); 1718 1719 /* Get local machine item state: */ 1720 UIVirtualMachineItemLocal *pLocalItem = pItem->toLocal(); 1721 AssertPtrReturnVoid(pLocalItem); 1722 const KMachineState enmState = pLocalItem->machineState(); 1723 1724 /* Pause VM first if necessary: */ 1725 if (enmState != KMachineState_Paused) 1726 comConsole.Pause(); 1727 if (comConsole.isOk()) 1728 { 1729 /* Prepare machine state saving progress: */ 1730 CProgress comProgress = comMachine.SaveState(); 1731 if (comMachine.isOk()) 1732 { 1733 /* Show machine state saving progress: */ 1734 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_state_save_90px.png"); 1735 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1736 msgCenter().cannotSaveMachineState(comProgress, comMachine.GetName()); 1737 } 1738 else 1739 msgCenter().cannotSaveMachineState(comMachine); 1740 } 1741 else 1742 msgCenter().cannotPauseMachine(comConsole); 1743 1744 /* Unlock machine finally: */ 1745 comSession.UnlockMachine(); 1709 /* Saving VM state: */ 1710 UINotificationProgressMachineSaveState *pNotification = new UINotificationProgressMachineSaveState(pItem->id()); 1711 notificationCenter().append(pNotification); 1746 1712 } 1747 1713 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90394 r90405 24 24 #include "UINotificationObjects.h" 25 25 26 /* COM includes: */ 27 #include "CConsole.h" 28 26 29 27 30 /********************************************************************************************************************************* … … 295 298 296 299 void UINotificationProgressMachineMove::sltHandleProgressFinished() 300 { 301 /* Unlock session finally: */ 302 m_comSession.UnlockMachine(); 303 } 304 305 306 /********************************************************************************************************************************* 307 * Class UINotificationProgressMachineSaveState implementation. * 308 *********************************************************************************************************************************/ 309 310 UINotificationProgressMachineSaveState::UINotificationProgressMachineSaveState(const QUuid &uId) 311 : m_uId(uId) 312 { 313 connect(this, &UINotificationProgress::sigProgressFinished, 314 this, &UINotificationProgressMachineSaveState::sltHandleProgressFinished); 315 } 316 317 QString UINotificationProgressMachineSaveState::name() const 318 { 319 return UINotificationProgress::tr("Saving VM state ..."); 320 } 321 322 QString UINotificationProgressMachineSaveState::details() const 323 { 324 return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName); 325 } 326 327 CProgress UINotificationProgressMachineSaveState::createProgress(COMResult &comResult) 328 { 329 /* Open a session thru which we will modify the machine: */ 330 m_comSession = uiCommon().openExistingSession(m_uId); 331 if (m_comSession.isNull()) 332 return CProgress(); 333 334 /* Get session machine: */ 335 CMachine comMachine = m_comSession.GetMachine(); 336 if (!m_comSession.isOk()) 337 { 338 comResult = m_comSession; 339 m_comSession.UnlockMachine(); 340 return CProgress(); 341 } 342 343 /* Acquire VM name: */ 344 m_strName = comMachine.GetName(); 345 if (!comMachine.isOk()) 346 { 347 comResult = comMachine; 348 m_comSession.UnlockMachine(); 349 return CProgress(); 350 } 351 352 /* Get machine state: */ 353 const KMachineState enmState = comMachine.GetState(); 354 if (!comMachine.isOk()) 355 { 356 comResult = comMachine; 357 m_comSession.UnlockMachine(); 358 return CProgress(); 359 } 360 361 /* If VM isn't yet paused: */ 362 if (enmState != KMachineState_Paused) 363 { 364 /* Get session console: */ 365 CConsole comConsole = m_comSession.GetConsole(); 366 if (!m_comSession.isOk()) 367 { 368 comResult = m_comSession; 369 m_comSession.UnlockMachine(); 370 return CProgress(); 371 } 372 373 /* Pause VM first: */ 374 comConsole.Pause(); 375 if (!comConsole.isOk()) 376 { 377 comResult = comConsole; 378 m_comSession.UnlockMachine(); 379 return CProgress(); 380 } 381 } 382 383 /* Initialize progress-wrapper: */ 384 CProgress comProgress = comMachine.SaveState(); 385 /* Store COM result: */ 386 comResult = comMachine; 387 /* Return progress-wrapper: */ 388 return comProgress; 389 } 390 391 void UINotificationProgressMachineSaveState::sltHandleProgressFinished() 297 392 { 298 393 /* Unlock session finally: */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90394 r90405 180 180 public: 181 181 182 /** Constructs m edium movenotification-progress.182 /** Constructs machine copy notification-progress. 183 183 * @param comSource Brings the machine being copied. 184 184 * @param comTarget Brings the machine being the target. … … 263 263 }; 264 264 265 /** UINotificationProgress extension for machine save-state functionality. */ 266 class SHARED_LIBRARY_STUFF UINotificationProgressMachineSaveState : public UINotificationProgress 267 { 268 Q_OBJECT; 269 270 public: 271 272 /** Constructs machine save-state notification-progress. 273 * @param comMachine Brings the machine being saved. */ 274 UINotificationProgressMachineSaveState(const QUuid &uId); 275 276 protected: 277 278 /** Returns object name. */ 279 virtual QString name() const /* override final */; 280 /** Returns object details. */ 281 virtual QString details() const /* override final */; 282 /** Creates and returns started progress-wrapper. */ 283 virtual CProgress createProgress(COMResult &comResult) /* override final */; 284 285 private slots: 286 287 /** Handles signal about progress being finished. */ 288 void sltHandleProgressFinished(); 289 290 private: 291 292 /** Holds the machine id. */ 293 QUuid m_uId; 294 /** Holds the session being opened. */ 295 CSession m_comSession; 296 /** Holds the machine name. */ 297 QString m_strName; 298 }; 299 265 300 /** UINotificationProgress extension for machine media remove functionality. */ 266 301 class SHARED_LIBRARY_STUFF UINotificationProgressMachineMediaRemove : public UINotificationProgress
Note:
See TracChangeset
for help on using the changeset viewer.