- Timestamp:
- Sep 29, 2021 5:57:13 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 147151
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp ¶
r91459 r91467 26 26 #include "UIModalWindowManager.h" 27 27 #include "UINotificationCenter.h" 28 #include "UIProgressObject.h" 28 29 #include "UIWizardExportApp.h" 29 30 #include "UIWizardExportAppPageBasic1.h" … … 31 32 #include "UIWizardExportAppPageBasic3.h" 32 33 #include "UIWizardExportAppPageExpert.h" 33 #include "UIWizardNewCloudVM.h"34 34 35 35 /* COM includes: */ … … 200 200 } 201 201 202 CVirtualSystemDescriptionForm UIWizardExportApp::vsdLaunchForm() 203 { 204 return m_comVsdLaunchForm; 205 } 206 207 void UIWizardExportApp::setVsdLaunchForm(const CVirtualSystemDescriptionForm &comForm) 208 { 209 m_comVsdLaunchForm = comForm; 210 } 211 202 212 CloudExportMode UIWizardExportApp::cloudExportMode() const 203 213 { … … 213 223 { 214 224 wizardButton(WizardButtonType_Next)->click(); 225 } 226 227 void UIWizardExportApp::disableButtons() 228 { 229 wizardButton(WizardButtonType_Expert)->setEnabled(false); 230 wizardButton(WizardButtonType_Back)->setEnabled(false); 231 wizardButton(WizardButtonType_Next)->setEnabled(false); 215 232 } 216 233 … … 332 349 } 333 350 351 bool UIWizardExportApp::createVsdLaunchForm() 352 { 353 /* Prepare result: */ 354 bool fResult = false; 355 356 /* Acquire prepared client and description: */ 357 CCloudClient comClient = cloudClient(); 358 CVirtualSystemDescription comVSD = vsd(); 359 AssertReturn(comClient.isNotNull() && comVSD.isNotNull(), false); 360 361 /* Get Launch description form: */ 362 CVirtualSystemDescriptionForm comForm; 363 CProgress comProgress = comClient.GetLaunchDescriptionForm(comVSD, comForm); 364 /* Check for immediate errors: */ 365 if (!comClient.isOk()) 366 msgCenter().cannotAcquireCloudClientParameter(comClient); 367 else 368 { 369 /* Make sure progress initially valid: */ 370 if (!comProgress.isNull() && !comProgress.GetCompleted()) 371 { 372 /* Create take snapshot progress object: */ 373 QPointer<UIProgressObject> pObject = new UIProgressObject(comProgress, this); 374 if (pObject) 375 { 376 connect(pObject.data(), &UIProgressObject::sigProgressChange, 377 this, &UIWizardExportApp::sltHandleProgressChange); 378 connect(pObject.data(), &UIProgressObject::sigProgressComplete, 379 this, &UIWizardExportApp::sltHandleProgressFinished); 380 sltHandleProgressStarted(); 381 pObject->exec(); 382 if (pObject) 383 delete pObject; 384 else 385 { 386 // Premature application shutdown, 387 // exit immediately: 388 return fResult; 389 } 390 } 391 } 392 393 /* Check for progress errors: */ 394 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 395 msgCenter().cannotAcquireCloudClientParameter(comProgress); 396 else 397 { 398 /* Check whether form really read: */ 399 if (comForm.isNotNull()) 400 { 401 /* Remember Virtual System Description Form: */ 402 setVsdLaunchForm(comForm); 403 404 /* Finally, success: */ 405 fResult = true; 406 } 407 } 408 } 409 410 /* Return result: */ 411 return fResult; 412 } 413 414 bool UIWizardExportApp::createCloudVM() 415 { 416 /* Acquire prepared client and description: */ 417 CCloudClient comClient = cloudClient(); 418 CVirtualSystemDescription comVSD = vsd(); 419 AssertReturn(comClient.isNotNull() && comVSD.isNotNull(), false); 420 421 /* Initiate cloud VM creation procedure: */ 422 CCloudMachine comMachine; 423 424 /* Create cloud VM: */ 425 UINotificationProgressCloudMachineCreate *pNotification = new UINotificationProgressCloudMachineCreate(comClient, 426 comMachine, 427 comVSD, 428 format(), 429 profileName()); 430 connect(pNotification, &UINotificationProgressCloudMachineCreate::sigCloudMachineCreated, 431 &uiCommon(), &UICommon::sltHandleCloudMachineAdded); 432 gpNotificationCenter->append(pNotification); 433 434 /* Return result: */ 435 return true; 436 } 437 334 438 void UIWizardExportApp::populatePages() 335 439 { … … 370 474 bool UIWizardExportApp::exportVMs(CAppliance &comAppliance) 371 475 { 372 /* Prepare result: */ 373 bool fResult = false; 374 375 /* New Cloud VM wizard can be created 376 * in certain cases and should be cleaned up 377 * afterwards, thus this is a global variable: */ 378 UISafePointerWizardNewCloudVM pNewCloudVMWizard; 379 380 /* Main API request sequence, can be interrupted after any step: */ 381 do 382 { 383 /* Get the map of the password IDs: */ 384 EncryptedMediumMap encryptedMedia; 385 foreach (const QString &strPasswordId, comAppliance.GetPasswordIds()) 386 foreach (const QUuid &uMediumId, comAppliance.GetMediumIdsForPasswordId(strPasswordId)) 387 encryptedMedia.insert(strPasswordId, uMediumId); 388 389 /* Ask for the disk encryption passwords if necessary: */ 390 if (!encryptedMedia.isEmpty()) 391 { 392 /* Modal dialog can be destroyed in own event-loop as a part of application 393 * termination procedure. We have to make sure that the dialog pointer is 394 * always up to date. So we are wrapping created dialog with QPointer. */ 395 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = 396 new UIAddDiskEncryptionPasswordDialog(this, 397 window()->windowTitle(), 398 encryptedMedia); 399 400 /* Execute the dialog: */ 401 if (pDlg->exec() != QDialog::Accepted) 402 { 403 /* Delete the dialog: */ 404 delete pDlg; 405 break; 406 } 407 408 /* Acquire the passwords provided: */ 409 const EncryptionPasswordMap encryptionPasswords = pDlg->encryptionPasswords(); 410 476 /* Get the map of the password IDs: */ 477 EncryptedMediumMap encryptedMedia; 478 foreach (const QString &strPasswordId, comAppliance.GetPasswordIds()) 479 foreach (const QUuid &uMediumId, comAppliance.GetMediumIdsForPasswordId(strPasswordId)) 480 encryptedMedia.insert(strPasswordId, uMediumId); 481 482 /* Ask for the disk encryption passwords if necessary: */ 483 if (!encryptedMedia.isEmpty()) 484 { 485 /* Modal dialog can be destroyed in own event-loop as a part of application 486 * termination procedure. We have to make sure that the dialog pointer is 487 * always up to date. So we are wrapping created dialog with QPointer. */ 488 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = 489 new UIAddDiskEncryptionPasswordDialog(this, 490 window()->windowTitle(), 491 encryptedMedia); 492 493 /* Execute the dialog: */ 494 if (pDlg->exec() != QDialog::Accepted) 495 { 411 496 /* Delete the dialog: */ 412 497 delete pDlg; 413 414 /* Provide appliance with passwords if possible: */ 415 comAppliance.AddPasswords(encryptionPasswords.keys().toVector(), 416 encryptionPasswords.values().toVector()); 417 if (!comAppliance.isOk()) 418 { 419 msgCenter().cannotAddDiskEncryptionPassword(comAppliance); 420 break; 421 } 422 } 423 424 /* Prepare export options: */ 425 QVector<KExportOptions> options; 426 switch (macAddressExportPolicy()) 427 { 428 case MACAddressExportPolicy_StripAllNonNATMACs: options.append(KExportOptions_StripAllNonNATMACs); break; 429 case MACAddressExportPolicy_StripAllMACs: options.append(KExportOptions_StripAllMACs); break; 430 default: break; 431 } 432 if (isManifestSelected()) 433 options.append(KExportOptions_CreateManifest); 434 if (isIncludeISOsSelected()) 435 options.append(KExportOptions_ExportDVDImages); 436 437 /* Is this VM being exported to cloud? */ 438 if (isFormatCloudOne()) 439 { 440 /* We can have wizard and it's result 441 * should be distinguishable: */ 442 int iWizardResult = -1; 443 444 switch (cloudExportMode()) 445 { 446 case CloudExportMode_AskThenExport: 447 { 448 /* Get the required parameters to init short wizard mode: */ 449 CCloudClient comClient = cloudClient(); 450 CVirtualSystemDescription comDescription = vsd(); 451 /* Create and run wizard as modal dialog, but prevent final step: */ 452 QWidget *pWizardParent = windowManager().realParentWindow(this); 453 const QString strGroupName = QString("/%1/%2").arg(format(), profileName()); 454 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, strGroupName, comClient, comDescription, mode()); 455 windowManager().registerNewParent(pNewCloudVMWizard, pWizardParent); 456 pNewCloudVMWizard->setFinalStepPrevented(true); 457 iWizardResult = pNewCloudVMWizard->exec(); 458 break; 459 } 460 default: 461 break; 462 } 463 464 /* We should stop everything only if 465 * there was wizard and it was rejected: */ 466 if (iWizardResult == QDialog::Rejected) 467 break; 468 469 /* Prepare Export VM progress: */ 470 CProgress comProgress = comAppliance.Write(format(), options, uri()); 471 if (!comAppliance.isOk()) 472 { 473 msgCenter().cannotExportAppliance(comAppliance, this); 474 break; 475 } 476 477 /* Show Export VM progress: */ 478 msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), 479 ":/progress_export_90px.png", this); 480 if (comProgress.GetCanceled()) 481 break; 482 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 483 { 484 msgCenter().cannotExportAppliance(comProgress, comAppliance.GetPath(), this); 485 break; 486 } 487 488 /* We can have wizard and it's result 489 * should be distinguishable: */ 490 iWizardResult = -1; 491 492 switch (cloudExportMode()) 493 { 494 case CloudExportMode_AskThenExport: 495 { 496 /* Run the wizard as modal dialog again, 497 * moreover in auto-finish mode and 498 * do not prevent final step. */ 499 pNewCloudVMWizard->setFinalStepPrevented(false); 500 pNewCloudVMWizard->scheduleAutoFinish(); 501 iWizardResult = pNewCloudVMWizard->exec(); 502 break; 503 } 504 case CloudExportMode_ExportThenAsk: 505 { 506 /* Get the required parameters to init short wizard mode: */ 507 CCloudClient comClient = cloudClient(); 508 CVirtualSystemDescription comDescription = vsd(); 509 /* Create and run short wizard mode as modal dialog: */ 510 QWidget *pWizardParent = windowManager().realParentWindow(this); 511 const QString strGroupName = QString("/%1/%2").arg(format(), profileName()); 512 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, strGroupName, comClient, comDescription, mode()); 513 windowManager().registerNewParent(pNewCloudVMWizard, pWizardParent); 514 iWizardResult = pNewCloudVMWizard->exec(); 515 break; 516 } 517 default: 518 break; 519 } 520 521 /* We should stop everything only if 522 * there was wizard and it was rejected: */ 523 if (iWizardResult == QDialog::Rejected) 524 break; 525 } 526 /* Is this VM being exported locally? */ 527 else 528 { 529 /* Export appliance: */ 530 UINotificationProgressApplianceExport *pNotification = new UINotificationProgressApplianceExport(comAppliance, 531 format(), 532 options, 533 uri()); 534 gpNotificationCenter->append(pNotification); 535 } 536 537 /* Success finally: */ 538 fResult = true; 539 } 540 while (0); 541 542 /* Cleanup New Cloud VM wizard if any: */ 543 delete pNewCloudVMWizard; 544 545 /* Return result: */ 546 return fResult; 547 } 498 return false; 499 } 500 501 /* Acquire the passwords provided: */ 502 const EncryptionPasswordMap encryptionPasswords = pDlg->encryptionPasswords(); 503 504 /* Delete the dialog: */ 505 delete pDlg; 506 507 /* Provide appliance with passwords if possible: */ 508 comAppliance.AddPasswords(encryptionPasswords.keys().toVector(), 509 encryptionPasswords.values().toVector()); 510 if (!comAppliance.isOk()) 511 { 512 msgCenter().cannotAddDiskEncryptionPassword(comAppliance); 513 return false; 514 } 515 } 516 517 /* Prepare export options: */ 518 QVector<KExportOptions> options; 519 switch (macAddressExportPolicy()) 520 { 521 case MACAddressExportPolicy_StripAllNonNATMACs: options.append(KExportOptions_StripAllNonNATMACs); break; 522 case MACAddressExportPolicy_StripAllMACs: options.append(KExportOptions_StripAllMACs); break; 523 default: break; 524 } 525 if (isManifestSelected()) 526 options.append(KExportOptions_CreateManifest); 527 if (isIncludeISOsSelected()) 528 options.append(KExportOptions_ExportDVDImages); 529 530 /* Is this VM being exported to cloud? */ 531 if (isFormatCloudOne()) 532 { 533 /* Prepare Export VM progress: */ 534 CProgress comProgress = comAppliance.Write(format(), options, uri()); 535 if (!comAppliance.isOk()) 536 { 537 msgCenter().cannotExportAppliance(comAppliance, this); 538 return false; 539 } 540 541 /* Show Export VM progress: */ 542 msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), 543 ":/progress_export_90px.png", this); 544 if (comProgress.GetCanceled()) 545 return false; 546 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 547 { 548 msgCenter().cannotExportAppliance(comProgress, comAppliance.GetPath(), this); 549 return false; 550 } 551 } 552 /* Is this VM being exported locally? */ 553 else 554 { 555 /* Export appliance: */ 556 UINotificationProgressApplianceExport *pNotification = new UINotificationProgressApplianceExport(comAppliance, 557 format(), 558 options, 559 uri()); 560 gpNotificationCenter->append(pNotification); 561 } 562 563 /* Success finally: */ 564 return true; 565 } -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.h ¶
r91368 r91467 143 143 void setVsdExportForm(const CVirtualSystemDescriptionForm &comForm); 144 144 145 /** Returns virtual system description launch form object. */ 146 CVirtualSystemDescriptionForm vsdLaunchForm(); 147 /** Defines virtual system description launch @a comForm object. */ 148 void setVsdLaunchForm(const CVirtualSystemDescriptionForm &comForm); 149 145 150 /** Returns cloud export mode. */ 146 151 CloudExportMode cloudExportMode() const; … … 154 159 void goForward(); 155 160 161 /** Disables basic/expert and next/back buttons. */ 162 void disableButtons(); 163 156 164 /** Composes universal resource identifier. 157 165 * @param fWithFile Brings whether uri should include file name as well. */ … … 160 168 /** Exports Appliance. */ 161 169 bool exportAppliance(); 170 171 /** Creates VSD Form. */ 172 bool createVsdLaunchForm(); 173 174 /** Creates New Cloud VM. */ 175 bool createCloudVM(); 162 176 /** @} */ 163 177 … … 228 242 /** Returns virtual system description export form object. */ 229 243 CVirtualSystemDescriptionForm m_comVsdExportForm; 244 /** Returns virtual system description launch form object. */ 245 CVirtualSystemDescriptionForm m_comVsdLaunchForm; 230 246 /** Returns cloud export mode. */ 231 247 CloudExportMode m_enmCloudExportMode; -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp ¶
r91462 r91467 116 116 , m_pApplianceWidget(0) 117 117 , m_pFormEditor(0) 118 , m_fLaunching(false) 118 119 { 119 120 /* Create main layout: */ … … 228 229 m_pFormEditor->makeSureEditorDataCommitted(); 229 230 231 /* Init VSD form: */ 232 CVirtualSystemDescriptionForm comForm; 230 233 /* Check whether we have proper VSD form: */ 231 CVirtualSystemDescriptionForm comForm = wizard()->vsdExportForm(); 232 fResult = comForm.isNotNull(); 233 Assert(fResult); 234 235 /* Give changed VSD back to appliance: */ 234 if (!m_fLaunching) 235 { 236 /* We are going to upload image: */ 237 comForm = wizard()->vsdExportForm(); 238 fResult = comForm.isNotNull(); 239 } 240 else 241 { 242 /* We are going to launch VM: */ 243 comForm = wizard()->vsdLaunchForm(); 244 fResult = comForm.isNotNull(); 245 } 246 /* Give changed VSD back: */ 236 247 if (fResult) 237 248 { … … 240 251 if (!fResult) 241 252 msgCenter().cannotAcquireVirtualSystemDescriptionFormProperty(comForm); 253 } 254 255 /* Final stage? */ 256 if (fResult) 257 { 258 if (!m_fLaunching) 259 { 260 /* For modes other than AskThenExport, try to export appliance first: */ 261 if (wizard()->cloudExportMode() != CloudExportMode_AskThenExport) 262 fResult = wizard()->exportAppliance(); 263 264 /* For modes other than DoNotAsk, switch from uploading image to launching VM: */ 265 if ( fResult 266 && wizard()->cloudExportMode() != CloudExportMode_DoNotAsk) 267 { 268 /* Invert flags: */ 269 fResult = false; 270 m_fLaunching = true; 271 272 /* Disable wizard buttons: */ 273 wizard()->disableButtons(); 274 275 /* Refresh corresponding widgets: */ 276 wizard()->createVsdLaunchForm(); 277 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdLaunchForm(), wizard()->isFormatCloudOne()); 278 } 279 } 280 else 281 { 282 /* For AskThenExport mode, try to export appliance in the end: */ 283 if (wizard()->cloudExportMode() == CloudExportMode_AskThenExport) 284 fResult = wizard()->exportAppliance(); 285 286 /* Try to create cloud VM: */ 287 if (fResult) 288 fResult = wizard()->createCloudVM(); 289 } 242 290 } 243 291 } … … 248 296 m_pApplianceWidget->prepareExport(); 249 297 wizard()->setLocalAppliance(*m_pApplianceWidget->appliance()); 298 299 /* Try to export appliance: */ 300 if (fResult) 301 fResult = wizard()->exportAppliance(); 250 302 } 251 252 /* Try to export appliance: */253 if (fResult)254 fResult = wizard()->exportAppliance();255 303 256 304 /* Return result: */ -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h ¶
r91462 r91467 94 94 /** Holds the Form Editor widget instance. */ 95 95 UIFormEditorWidget *m_pFormEditor; 96 97 /** Holds whether cloud exporting is at launching stage. */ 98 bool m_fLaunching; 96 99 }; 97 100 -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp ¶
r91465 r91467 85 85 , m_pApplianceWidget(0) 86 86 , m_pFormEditor(0) 87 , m_fLaunching(0) 87 88 { 88 89 /* Create widgets: */ … … 582 583 m_pFormEditor->makeSureEditorDataCommitted(); 583 584 585 /* Init VSD form: */ 586 CVirtualSystemDescriptionForm comForm; 584 587 /* Check whether we have proper VSD form: */ 585 CVirtualSystemDescriptionForm comForm = wizard()->vsdExportForm(); 586 fResult = comForm.isNotNull(); 587 Assert(fResult); 588 589 /* Give changed VSD back to appliance: */ 588 if (!m_fLaunching) 589 { 590 /* We are going to upload image: */ 591 comForm = wizard()->vsdExportForm(); 592 fResult = comForm.isNotNull(); 593 } 594 else 595 { 596 /* We are going to launch VM: */ 597 comForm = wizard()->vsdLaunchForm(); 598 fResult = comForm.isNotNull(); 599 } 600 /* Give changed VSD back: */ 590 601 if (fResult) 591 602 { … … 594 605 if (!fResult) 595 606 msgCenter().cannotAcquireVirtualSystemDescriptionFormProperty(comForm); 607 } 608 609 /* Final stage? */ 610 if (fResult) 611 { 612 if (!m_fLaunching) 613 { 614 /* For modes other than AskThenExport, try to export appliance first: */ 615 if (wizard()->cloudExportMode() != CloudExportMode_AskThenExport) 616 fResult = wizard()->exportAppliance(); 617 618 /* For modes other than DoNotAsk, switch from uploading image to launching VM: */ 619 if ( fResult 620 && wizard()->cloudExportMode() != CloudExportMode_DoNotAsk) 621 { 622 /* Invert flags: */ 623 fResult = false; 624 m_fLaunching = true; 625 626 /* Disable wizard buttons: */ 627 wizard()->disableButtons(); 628 629 /* Disable unrelated widgets: */ 630 m_pToolBox->setCurrentPage(2); 631 m_pToolBox->setPageEnabled(0, false); 632 m_pToolBox->setPageEnabled(1, false); 633 634 /* Refresh corresponding widgets: */ 635 wizard()->createVsdLaunchForm(); 636 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdLaunchForm(), wizard()->isFormatCloudOne()); 637 } 638 } 639 else 640 { 641 /* For AskThenExport mode, try to export appliance in the end: */ 642 if (wizard()->cloudExportMode() == CloudExportMode_AskThenExport) 643 fResult = wizard()->exportAppliance(); 644 645 /* Try to create cloud VM: */ 646 if (fResult) 647 fResult = wizard()->createCloudVM(); 648 } 596 649 } 597 650 } … … 611 664 wizard()->setLocalAppliance(*m_pApplianceWidget->appliance()); 612 665 } 666 667 /* Try to export appliance: */ 668 if (fResult) 669 fResult = wizard()->exportAppliance(); 613 670 } 614 615 /* Try to export appliance: */616 if (fResult)617 fResult = wizard()->exportAppliance();618 671 619 672 /* Return result: */ -
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h ¶
r91465 r91467 194 194 /** Holds the Form Editor widget instance. */ 195 195 UIFormEditorWidget *m_pFormEditor; 196 197 /** Holds whether cloud exporting is at launching stage. */ 198 bool m_fLaunching; 196 199 }; 197 200
Note:
See TracChangeset
for help on using the changeset viewer.