bool UIWizardExportApp::exportVMs(CAppliance &appliance) { /* Write the appliance: */ const QString strVersion = field("OVF09Selected").toBool() ? "ovf-0.9" : "ovf-1.0"; CProgress progress = appliance.Write(strVersion, field("manifestSelected").toBool() /* fManifest */, uri()); bool fResult = appliance.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), ":/progress_export_90px.png", this, true); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotExportAppliance(progress, &appliance, this); return false; } else return true; } if (!fResult) msgCenter().cannotExportAppliance(&appliance, this); return false; }
void UIWizardImportAppPageBasic2::initializePage() { /* Acquire appliance and certificate: */ CAppliance *pAppliance = m_pApplianceWidget->appliance(); CCertificate certificate = pAppliance->GetCertificate(); if (certificate.isNull()) m_enmCertText = kCertText_Unsigned; else { /* Pick a 'signed-by' name. */ m_strSignedBy = certificate.GetFriendlyName(); /* If trusted, just select the right message: */ if (certificate.GetTrusted()) { if (certificate.GetSelfSigned()) m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired; else m_enmCertText = !certificate.GetExpired() ? kCertText_IssuedTrusted : kCertText_IssuedExpired; } else { /* Not trusted! Must ask the user whether to continue in this case: */ m_enmCertText = certificate.GetSelfSigned() ? kCertText_SelfSignedUnverified : kCertText_IssuedUnverified; /* Translate page early: */ retranslateUi(); /* Instantiate the dialog: */ QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, certificate); AssertPtrReturnVoid(pDialog.data()); /* Show viewer in modal mode: */ const int iResultCode = pDialog->exec(); /* Leave if viewer destroyed prematurely: */ if (!pDialog) return; /* Delete viewer finally: */ delete pDialog; pDialog = 0; /* Dismiss the entire import-appliance wizard if user rejects certificate: */ if (iResultCode == QDialog::Rejected) wizard()->reject(); } } /* Translate page: */ retranslateUi(); }
bool UIWizardExportApp::exportVMs(CAppliance &appliance) { /* Write the appliance: */ CProgress progress = appliance.Write(field("format").toString(), field("manifestSelected").toBool() /* fManifest */, uri()); bool fResult = appliance.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), ":/progress_export_90px.png", this); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotExportAppliance(progress, appliance.GetPath(), this); return false; } else return true; } if (!fResult) msgCenter().cannotExportAppliance(appliance, this); return false; }
bool UIWizardExportApp::exportAppliance() { /* Get export appliance widget: */ UIApplianceExportEditorWidget *pExportApplianceWidget = field("applianceWidget").value<ExportAppliancePointer>(); /* Fetch all settings from the appliance editor. */ pExportApplianceWidget->prepareExport(); /* Get the appliance. */ CAppliance *pAppliance = pExportApplianceWidget->appliance(); /* We need to know every filename which will be created, so that we can * ask the user for confirmation of overwriting. For that we iterating * over all virtual systems & fetch all descriptions of the type * HardDiskImage. Also add the manifest file to the check. In the ova * case only the target file itself get checked. */ QFileInfo fi(field("path").toString()); QVector<QString> files; files << fi.fileName(); if (fi.suffix().toLower() == "ovf") { if (field("manifestSelected").toBool()) files << fi.baseName() + ".mf"; CVirtualSystemDescriptionVector vsds = pAppliance->GetVirtualSystemDescriptions(); for (int i = 0; i < vsds.size(); ++ i) { QVector<KVirtualSystemDescriptionType> types; QVector<QString> refs, origValues, configValues, extraConfigValues; vsds[i].GetDescriptionByType(KVirtualSystemDescriptionType_HardDiskImage, types, refs, origValues, configValues, extraConfigValues); foreach (const QString &s, origValues) files << QString("%2").arg(s); } } CVFSExplorer explorer = pAppliance->CreateVFSExplorer(uri(false /* fWithFile */)); CProgress progress = explorer.Update(); bool fResult = explorer.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress, QApplication::translate("UIWizardExportApp", "Checking files ..."), ":/refresh_32px.png", this); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotCheckFiles(progress, this); return false; } } QVector<QString> exists = explorer.Exists(files); /* Check if the file exists already, if yes get confirmation for overwriting from the user. */ if (!msgCenter().confirmOverridingFiles(exists, this)) return false; /* Ok all is confirmed so delete all the files which exists: */ if (!exists.isEmpty()) { CProgress progress1 = explorer.Remove(exists); fResult = explorer.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress1, QApplication::translate("UIWizardExportApp", "Removing files ..."), ":/vm_delete_32px.png", this); if (progress1.GetCanceled()) return false; if (!progress1.isOk() || progress1.GetResultCode() != 0) { msgCenter().cannotRemoveFiles(progress1, this); return false; } } } /* Export the VMs, on success we are finished: */ if (exportVMs(*pAppliance)) { #if 0 /* Save attributes to GUI extra data: */ StorageType storageType = field("storageType").value<StorageType>(); vboxGlobal().virtualBox().SetExtraData(GUI_Export_StorageType, QString::number(storageType)); vboxGlobal().virtualBox().SetExtraData(GUI_Export_Username, m_pLeUsername->text()); vboxGlobal().virtualBox().SetExtraData(GUI_Export_Hostname, m_pLeHostname->text()); vboxGlobal().virtualBox().SetExtraData(GUI_Export_Bucket, m_pLeBucket->text()); #endif return true; } return false; }
bool UIWizardExportApp::exportVMs(CAppliance &appliance) { /* Get the map of the password IDs: */ EncryptedMediumMap encryptedMediums; foreach (const QString &strPasswordId, appliance.GetPasswordIds()) foreach (const QString &strMediumId, appliance.GetMediumIdsForPasswordId(strPasswordId)) encryptedMediums.insert(strPasswordId, strMediumId); /* Ask for the disk encryption passwords if necessary: */ if (!encryptedMediums.isEmpty()) { /* Create corresponding dialog: */ QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = new UIAddDiskEncryptionPasswordDialog(this, window()->windowTitle(), encryptedMediums); /* Execute the dialog: */ if (pDlg->exec() == QDialog::Accepted) { /* Acquire the passwords provided: */ const EncryptionPasswordMap encryptionPasswords = pDlg->encryptionPasswords(); /* Delete the dialog: */ delete pDlg; /* Make sure the passwords were really provided: */ AssertReturn(!encryptionPasswords.isEmpty(), false); /* Provide appliance with passwords if possible: */ appliance.AddPasswords(encryptionPasswords.keys().toVector(), encryptionPasswords.values().toVector()); if (!appliance.isOk()) { /* Warn the user about failure: */ msgCenter().cannotAddDiskEncryptionPassword(appliance); return false; } } else { /* Any modal dialog can be destroyed in own event-loop * as a part of application termination procedure.. * We have to check if the dialog still valid. */ if (pDlg) { /* Delete the dialog: */ delete pDlg; } return false; } } /* Write the appliance: */ QVector<KExportOptions> options; if (field("manifestSelected").toBool()) options.append(KExportOptions_CreateManifest); CProgress progress = appliance.Write(field("format").toString(), options, uri()); bool fResult = appliance.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), ":/progress_export_90px.png", this); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotExportAppliance(progress, appliance.GetPath(), this); return false; } else return true; } if (!fResult) msgCenter().cannotExportAppliance(appliance, this); return false; }
void UIWizardImportAppPageBasic2::initializePage() { /* Update widget visibility: */ updatePageAppearance(); /* Check whether there was cloud source selected: */ const bool fIsSourceCloudOne = field("isSourceCloudOne").toBool(); if (fIsSourceCloudOne) populateFormPropertiesTable(); else { /* Acquire appliance: */ CAppliance *pAppliance = m_pApplianceWidget->appliance(); /* Check if pAppliance is alive. If not just return here. * This prevents crashes when an invalid ova file is supllied: */ if (!pAppliance) { if (wizard()) wizard()->reject(); return; } /* Acquire certificate: */ CCertificate comCertificate = pAppliance->GetCertificate(); if (comCertificate.isNull()) m_enmCertText = kCertText_Unsigned; else { /* Pick a 'signed-by' name: */ m_strSignedBy = comCertificate.GetFriendlyName(); /* If trusted, just select the right message: */ if (comCertificate.GetTrusted()) { if (comCertificate.GetSelfSigned()) m_enmCertText = !comCertificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired; else m_enmCertText = !comCertificate.GetExpired() ? kCertText_IssuedTrusted : kCertText_IssuedExpired; } else { /* Not trusted! Must ask the user whether to continue in this case: */ m_enmCertText = comCertificate.GetSelfSigned() ? kCertText_SelfSignedUnverified : kCertText_IssuedUnverified; /* Translate page early: */ retranslateUi(); /* Instantiate the dialog: */ QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, comCertificate); AssertPtrReturnVoid(pDialog.data()); /* Show viewer in modal mode: */ const int iResultCode = pDialog->exec(); /* Leave if viewer destroyed prematurely: */ if (!pDialog) return; /* Delete viewer finally: */ delete pDialog; /* Dismiss the entire import-appliance wizard if user rejects certificate: */ if (iResultCode == QDialog::Rejected) wizard()->reject(); } } } /* Translate page: */ retranslateUi(); }