Changeset 45213 in vbox
- Timestamp:
- Mar 27, 2013 4:47:45 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84578
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r45212 r45213 312 312 delete pCloseDlg; 313 313 314 /* Was dialog accepted? */314 /* Was the dialog accepted? */ 315 315 if (dialogResult != UIVMCloseDialog::ResultCode_Cancel) 316 316 { 317 /* Process decision: */318 CConsole console = session().GetConsole();319 317 switch (dialogResult) 320 318 { 321 319 case UIVMCloseDialog::ResultCode_Save: 322 320 { 323 /* Prepare the saving progress: */ 324 CProgress progress = console.SaveState(); 325 fSuccess = console.isOk(); 326 if (fSuccess) 327 { 328 /* Show the saving progress dialog: */ 329 msgCenter().showModalProgressDialog(progress, machineCopy.GetName(), ":/progress_state_save_90px.png", this); 330 fSuccess = progress.GetResultCode() == 0; 331 if (fSuccess) 332 fShutdownSession = true; 333 else 334 msgCenter().cannotSaveMachineState(progress); 335 } 336 else 337 msgCenter().cannotSaveMachineState(console); 321 fSuccess = uisession()->saveState(); 322 fShutdownSession = fSuccess; 338 323 break; 339 324 } 340 325 case UIVMCloseDialog::ResultCode_Shutdown: 341 326 { 342 /* Unpause VM to let it grab the ACPI shutdown event: */ 343 fSuccess = uisession()->unpause(); 327 fSuccess = uisession()->shutDown(); 344 328 if (fSuccess) 345 {346 /* Prevent subsequent unpause request: */347 329 fWasPaused = true; 348 /* Signal ACPI shutdown (if there is no ACPI device, the operation will fail): */349 console.PowerButton();350 fSuccess = console.isOk();351 if (!fSuccess)352 msgCenter().cannotACPIShutdownMachine(console);353 }354 330 break; 355 331 } … … 357 333 case UIVMCloseDialog::ResultCode_PowerOff_With_Discarding: 358 334 { 359 /* Prepare the power down progress: */ 360 CProgress progress = console.PowerDown(); 361 fSuccess = console.isOk(); 362 if (fSuccess) 363 { 364 /* Show the power down progress: */ 365 msgCenter().showModalProgressDialog(progress, machineCopy.GetName(), ":/progress_poweroff_90px.png", this); 366 fSuccess = progress.GetResultCode() == 0; 367 if (fSuccess) 368 { 369 /* Discard the current state if requested: */ 370 if (dialogResult == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding) 371 { 372 /* Prepare the snapshot discard progress: */ 373 CSnapshot snapshot = machineCopy.GetCurrentSnapshot(); 374 CProgress progress = console.RestoreSnapshot(snapshot); 375 fSuccess = console.isOk(); 376 if (fSuccess) 377 { 378 /* Show the snapshot discard progress: */ 379 msgCenter().showModalProgressDialog(progress, machineCopy.GetName(), ":/progress_snapshot_discard_90px.png", this); 380 fSuccess = progress.GetResultCode() == 0; 381 if (!fSuccess) 382 msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName()); 383 } 384 else 385 msgCenter().cannotRestoreSnapshot(console, snapshot.GetName()); 386 } 387 if (fSuccess) 388 fShutdownSession = true; 389 } 390 else 391 msgCenter().cannotStopMachine(progress); 392 } 393 else 394 { 395 /* This can happen if VBoxSVC is not running: */ 396 COMResult res(console); 397 if (FAILED_DEAD_INTERFACE(res.rc())) 398 fShutdownSession = true; 399 else 400 msgCenter().cannotStopMachine(console); 401 } 335 bool fServerCrashed = false; 336 fSuccess = uisession()->powerOff(dialogResult == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding, 337 fServerCrashed); 338 fShutdownSession = fSuccess || fServerCrashed; 402 339 break; 403 340 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r45193 r45213 68 68 #include "CVRDEServer.h" 69 69 #include "CUSBController.h" 70 #include "CSnapshot.h" 70 71 71 72 UISession::UISession(UIMachine *pMachine, CSession &sessionReference) … … 313 314 } 314 315 316 bool UISession::saveState() 317 { 318 /* Prepare the saving progress: */ 319 CMachine machine = m_session.GetMachine(); 320 CConsole console = m_session.GetConsole(); 321 CProgress progress = console.SaveState(); 322 if (console.isOk()) 323 { 324 /* Show the saving progress: */ 325 msgCenter().showModalProgressDialog(progress, machine.GetName(), 326 ":/progress_state_save_90px.png", 327 machineLogic()->activeMachineWindow()); 328 if (progress.GetResultCode() != 0) 329 { 330 /* Failed in progress: */ 331 msgCenter().cannotSaveMachineState(progress); 332 return false; 333 } 334 } 335 else 336 { 337 /* Failed in console: */ 338 msgCenter().cannotSaveMachineState(console); 339 return false; 340 } 341 /* Passed: */ 342 return true; 343 } 344 345 bool UISession::shutDown() 346 { 347 /* Resume VM to let it grab the ACPI shutdown signal: */ 348 if (!unpause()) 349 { 350 /* Failed in console: */ 351 return false; 352 } 353 /* Send ACPI shutdown signal if possible: */ 354 CConsole console = m_session.GetConsole(); 355 console.PowerButton(); 356 if (!console.isOk()) 357 { 358 /* Failed in console: */ 359 msgCenter().cannotACPIShutdownMachine(console); 360 return false; 361 } 362 /* Passed: */ 363 return true; 364 } 365 366 bool UISession::powerOff(bool fIncludingDiscard, bool &fServerCrashed) 367 { 368 /* Prepare the power-off progress: */ 369 CMachine machine = m_session.GetMachine(); 370 CConsole console = m_session.GetConsole(); 371 CProgress progress = console.PowerDown(); 372 if (console.isOk()) 373 { 374 /* Show the power-off progress: */ 375 msgCenter().showModalProgressDialog(progress, machine.GetName(), 376 ":/progress_poweroff_90px.png", 377 machineLogic()->activeMachineWindow()); 378 if (progress.GetResultCode() == 0) 379 { 380 /* Discard the current state if requested: */ 381 if (fIncludingDiscard) 382 { 383 /* Prepare the snapshot-discard progress: */ 384 CSnapshot snapshot = machine.GetCurrentSnapshot(); 385 CProgress progress = console.RestoreSnapshot(snapshot); 386 if (console.isOk()) 387 { 388 /* Show the snapshot-discard progress: */ 389 msgCenter().showModalProgressDialog(progress, machine.GetName(), 390 ":/progress_snapshot_discard_90px.png", 391 machineLogic()->activeMachineWindow()); 392 if (progress.GetResultCode() != 0) 393 { 394 /* Failed in progress: */ 395 msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName()); 396 return false; 397 } 398 } 399 else 400 { 401 /* Failed in console: */ 402 msgCenter().cannotRestoreSnapshot(console, snapshot.GetName()); 403 return false; 404 } 405 } 406 } 407 else 408 { 409 /* Failed in progress: */ 410 msgCenter().cannotStopMachine(progress); 411 return false; 412 } 413 } 414 else 415 { 416 /* Failed in console: */ 417 COMResult res(console); 418 /* This can happen if VBoxSVC is not running: */ 419 if (FAILED_DEAD_INTERFACE(res.rc())) 420 fServerCrashed = true; 421 else 422 msgCenter().cannotStopMachine(console); 423 return false; 424 } 425 /* Passed: */ 426 return true; 427 } 428 315 429 UIMachineLogic* UISession::machineLogic() const 316 430 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r45050 r45213 89 89 /* Common members: */ 90 90 void powerUp(); 91 bool saveState(); 92 bool shutDown(); 93 bool powerOff(bool fIncludingDiscard, bool &fServerCrashed); 91 94 92 95 /* Common getters: */
Note:
See TracChangeset
for help on using the changeset viewer.