Changeset 79697 in vbox
- Timestamp:
- Jul 11, 2019 1:31:12 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp
r79657 r79697 251 251 bool UIWizardExportApp::exportVMs(CAppliance &comAppliance) 252 252 { 253 /* Get the map of the password IDs: */ 254 EncryptedMediumMap encryptedMedia; 255 foreach (const QString &strPasswordId, comAppliance.GetPasswordIds()) 256 foreach (const QUuid &uMediumId, comAppliance.GetMediumIdsForPasswordId(strPasswordId)) 257 encryptedMedia.insert(strPasswordId, uMediumId); 258 259 /* Ask for the disk encryption passwords if necessary: */ 260 if (!encryptedMedia.isEmpty()) 261 { 262 /* Modal dialog can be destroyed in own event-loop as a part of application 263 * termination procedure. We have to make sure that the dialog pointer is 264 * always up to date. So we are wrapping created dialog with QPointer. */ 265 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = 266 new UIAddDiskEncryptionPasswordDialog(this, 267 window()->windowTitle(), 268 encryptedMedia); 269 270 /* Execute the dialog: */ 271 if (pDlg->exec() == QDialog::Accepted) 272 { 253 /* Prepare result: */ 254 bool fResult = false; 255 256 /* New Cloud VM wizard can be created 257 * in certain cases and should be cleaned up 258 * afterwards, thus this is a global variable: */ 259 UISafePointerWizardNewCloudVM pNewCloudVMWizard; 260 261 /* Main API request sequence, can be interrupted after any step: */ 262 do 263 { 264 /* Get the map of the password IDs: */ 265 EncryptedMediumMap encryptedMedia; 266 foreach (const QString &strPasswordId, comAppliance.GetPasswordIds()) 267 foreach (const QUuid &uMediumId, comAppliance.GetMediumIdsForPasswordId(strPasswordId)) 268 encryptedMedia.insert(strPasswordId, uMediumId); 269 270 /* Ask for the disk encryption passwords if necessary: */ 271 if (!encryptedMedia.isEmpty()) 272 { 273 /* Modal dialog can be destroyed in own event-loop as a part of application 274 * termination procedure. We have to make sure that the dialog pointer is 275 * always up to date. So we are wrapping created dialog with QPointer. */ 276 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = 277 new UIAddDiskEncryptionPasswordDialog(this, 278 window()->windowTitle(), 279 encryptedMedia); 280 281 /* Execute the dialog: */ 282 if (pDlg->exec() != QDialog::Accepted) 283 { 284 /* Delete the dialog: */ 285 delete pDlg; 286 break; 287 } 288 273 289 /* Acquire the passwords provided: */ 274 290 const EncryptionPasswordMap encryptionPasswords = pDlg->encryptionPasswords(); … … 276 292 /* Delete the dialog: */ 277 293 delete pDlg; 278 279 /* Make sure the passwords were really provided: */280 AssertReturn(!encryptionPasswords.isEmpty(), false);281 294 282 295 /* Provide appliance with passwords if possible: */ … … 284 297 encryptionPasswords.values().toVector()); 285 298 if (!comAppliance.isOk()) 286 return msgCenter().cannotAddDiskEncryptionPassword(comAppliance); 287 } 288 else 289 { 290 /* Delete the dialog: */ 291 delete pDlg; 292 return false; 293 } 294 } 295 296 /* Write the appliance: */ 297 QVector<KExportOptions> options; 298 switch (field("macAddressPolicy").value<MACAddressPolicy>()) 299 { 300 case MACAddressPolicy_StripAllNonNATMACs: 301 options.append(KExportOptions_StripAllNonNATMACs); 302 break; 303 case MACAddressPolicy_StripAllMACs: 304 options.append(KExportOptions_StripAllMACs); 305 break; 306 default: 307 break; 308 } 309 if (field("manifestSelected").toBool()) 310 options.append(KExportOptions_CreateManifest); 311 if (field("includeISOsSelected").toBool()) 312 options.append(KExportOptions_ExportDVDImages); 313 CProgress comProgress = comAppliance.Write(field("format").toString(), options, uri()); 314 if (comAppliance.isOk() && comProgress.isNotNull()) 315 { 299 { 300 msgCenter().cannotAddDiskEncryptionPassword(comAppliance); 301 break; 302 } 303 } 304 305 /* Prepare export options: */ 306 QVector<KExportOptions> options; 307 switch (field("macAddressPolicy").value<MACAddressPolicy>()) 308 { 309 case MACAddressPolicy_StripAllNonNATMACs: options.append(KExportOptions_StripAllNonNATMACs); break; 310 case MACAddressPolicy_StripAllMACs: options.append(KExportOptions_StripAllMACs); break; 311 default: break; 312 } 313 if (field("manifestSelected").toBool()) 314 options.append(KExportOptions_CreateManifest); 315 if (field("includeISOsSelected").toBool()) 316 options.append(KExportOptions_ExportDVDImages); 317 318 /* Prepare Export VM progress: */ 319 CProgress comProgress = comAppliance.Write(field("format").toString(), options, uri()); 320 if (!comAppliance.isOk()) 321 { 322 msgCenter().cannotExportAppliance(comAppliance, this); 323 break; 324 } 325 326 /* Show Export VM progress: */ 316 327 msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), 317 328 ":/progress_export_90px.png", this); 318 329 if (comProgress.GetCanceled()) 319 return false;330 break; 320 331 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 321 return msgCenter().cannotExportAppliance(comProgress, comAppliance.GetPath(), this); 332 { 333 msgCenter().cannotExportAppliance(comProgress, comAppliance.GetPath(), this); 334 break; 335 } 322 336 323 337 /* Is this VM being exported to cloud? */ 324 338 if (field("isFormatCloudOne").toBool()) 325 339 { 340 /* We can have wizard and it's result 341 * should be distinguishable: */ 342 int iWizardResult = -1; 343 326 344 switch (field("cloudExportMode").value<CloudExportMode>()) 327 345 { … … 333 351 /* Create and run short wizard mode as modal dialog: */ 334 352 QWidget *pWizardParent = windowManager().realParentWindow(this); 335 UISafePointerWizardNewCloudVM pWizard = new UIWizardNewCloudVM(pWizardParent, comClient, comDescription); 336 windowManager().registerNewParent(pWizard, pWizardParent); 337 pWizard->prepare(); 338 pWizard->exec(); 339 delete pWizard; 353 pNewCloudVMWizard = new UIWizardNewCloudVM(pWizardParent, comClient, comDescription); 354 windowManager().registerNewParent(pNewCloudVMWizard, pWizardParent); 355 pNewCloudVMWizard->prepare(); 356 iWizardResult = pNewCloudVMWizard->exec(); 340 357 break; 341 358 } … … 343 360 break; 344 361 } 345 } 346 } 347 else 348 return msgCenter().cannotExportAppliance(comAppliance, this); 349 350 /* True finally: */ 351 return true; 352 } 362 363 /* We should stop everything only if 364 * there was wizard and it was rejected: */ 365 if (iWizardResult == QDialog::Rejected) 366 break; 367 } 368 369 /* Success finally: */ 370 fResult = true; 371 } 372 while (0); 373 374 /* Cleanup New Cloud VM wizard if any: */ 375 delete pNewCloudVMWizard; 376 377 /* Return result: */ 378 return fResult; 379 }
Note:
See TracChangeset
for help on using the changeset viewer.

