1 | /* $Id: UIWizardImportAppPageSettings.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardImportAppPageSettings class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #include <QCheckBox>
|
---|
30 | #include <QLabel>
|
---|
31 | #include <QStackedWidget>
|
---|
32 | #include <QVBoxLayout>
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "QIComboBox.h"
|
---|
36 | #include "QIRichTextLabel.h"
|
---|
37 | #include "UIApplianceImportEditorWidget.h"
|
---|
38 | #include "UIApplianceUnverifiedCertificateViewer.h"
|
---|
39 | #include "UIFilePathSelector.h"
|
---|
40 | #include "UIFormEditorWidget.h"
|
---|
41 | #include "UIGlobalSession.h"
|
---|
42 | #include "UINotificationCenter.h"
|
---|
43 | #include "UIWizardImportApp.h"
|
---|
44 | #include "UIWizardImportAppPageSettings.h"
|
---|
45 |
|
---|
46 | /* COM includes: */
|
---|
47 | #include "CAppliance.h"
|
---|
48 | #include "CCertificate.h"
|
---|
49 | #include "CSystemProperties.h"
|
---|
50 | #include "CVirtualSystemDescriptionForm.h"
|
---|
51 |
|
---|
52 | /* Namespaces: */
|
---|
53 | using namespace UIWizardImportAppSettings;
|
---|
54 |
|
---|
55 |
|
---|
56 | /*********************************************************************************************************************************
|
---|
57 | * Class UIWizardImportAppSettings implementation. *
|
---|
58 | *********************************************************************************************************************************/
|
---|
59 |
|
---|
60 | void UIWizardImportAppSettings::refreshStackedWidget(QStackedWidget *pStackedWidget,
|
---|
61 | bool fIsSourceCloudOne)
|
---|
62 | {
|
---|
63 | /* Sanity check: */
|
---|
64 | AssertPtrReturnVoid(pStackedWidget);
|
---|
65 |
|
---|
66 | /* Update stack appearance according to chosen source: */
|
---|
67 | pStackedWidget->setCurrentIndex((int)fIsSourceCloudOne);
|
---|
68 | }
|
---|
69 |
|
---|
70 | void UIWizardImportAppSettings::refreshApplianceWidget(UIApplianceImportEditorWidget *pApplianceWidget,
|
---|
71 | const CAppliance &comAppliance,
|
---|
72 | bool fIsSourceCloudOne)
|
---|
73 | {
|
---|
74 | /* Sanity check: */
|
---|
75 | AssertPtrReturnVoid(pApplianceWidget);
|
---|
76 |
|
---|
77 | /* If source is cloud one: */
|
---|
78 | if (fIsSourceCloudOne)
|
---|
79 | {
|
---|
80 | /* Clear form: */
|
---|
81 | pApplianceWidget->clear();
|
---|
82 | }
|
---|
83 | /* If source is local one: */
|
---|
84 | else
|
---|
85 | {
|
---|
86 | /* Make sure appliance widget get new appliance: */
|
---|
87 | if (comAppliance.isNotNull())
|
---|
88 | pApplianceWidget->setAppliance(comAppliance);
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | void UIWizardImportAppSettings::refreshMACAddressImportPolicies(QIComboBox *pCombo,
|
---|
93 | bool fIsSourceCloudOne)
|
---|
94 | {
|
---|
95 | /* Sanity check: */
|
---|
96 | AssertPtrReturnVoid(pCombo);
|
---|
97 |
|
---|
98 | /* If source is cloud one: */
|
---|
99 | if (fIsSourceCloudOne)
|
---|
100 | {
|
---|
101 | /* Block signals while updating: */
|
---|
102 | pCombo->blockSignals(true);
|
---|
103 |
|
---|
104 | /* Clear combo: */
|
---|
105 | pCombo->clear();
|
---|
106 |
|
---|
107 | /* Unblock signals after update: */
|
---|
108 | pCombo->blockSignals(false);
|
---|
109 | }
|
---|
110 | /* If source is local one: */
|
---|
111 | else
|
---|
112 | {
|
---|
113 | /* We need top-level parent as well: */
|
---|
114 | QWidget *pParent = pCombo->window();
|
---|
115 | AssertPtrReturnVoid(pParent);
|
---|
116 |
|
---|
117 | /* Map known import options to known MAC address import policies: */
|
---|
118 | QMap<KImportOptions, MACAddressImportPolicy> knownOptions;
|
---|
119 | knownOptions[KImportOptions_KeepAllMACs] = MACAddressImportPolicy_KeepAllMACs;
|
---|
120 | knownOptions[KImportOptions_KeepNATMACs] = MACAddressImportPolicy_KeepNATMACs;
|
---|
121 | /* Load currently supported import options: */
|
---|
122 | const QVector<KImportOptions> supportedOptions =
|
---|
123 | gpGlobalSession->virtualBox().GetSystemProperties().GetSupportedImportOptions();
|
---|
124 | /* Check which of supported options/policies are known: */
|
---|
125 | QList<MACAddressImportPolicy> supportedPolicies;
|
---|
126 | foreach (const KImportOptions &enmOption, supportedOptions)
|
---|
127 | if (knownOptions.contains(enmOption))
|
---|
128 | supportedPolicies << knownOptions.value(enmOption);
|
---|
129 | /* Remember current item data to be able to restore it: */
|
---|
130 | MACAddressImportPolicy enmOldData = MACAddressImportPolicy_MAX;
|
---|
131 | if (pCombo->currentIndex() != -1)
|
---|
132 | enmOldData = pCombo->currentData().value<MACAddressImportPolicy>();
|
---|
133 | else
|
---|
134 | {
|
---|
135 | if (supportedPolicies.contains(MACAddressImportPolicy_KeepNATMACs))
|
---|
136 | enmOldData = MACAddressImportPolicy_KeepNATMACs;
|
---|
137 | else
|
---|
138 | enmOldData = MACAddressImportPolicy_StripAllMACs;
|
---|
139 | }
|
---|
140 |
|
---|
141 | /* Block signals while updating: */
|
---|
142 | pCombo->blockSignals(true);
|
---|
143 |
|
---|
144 | /* Cleanup combo: */
|
---|
145 | pCombo->clear();
|
---|
146 |
|
---|
147 | /* Add supported policies first: */
|
---|
148 | foreach (const MACAddressImportPolicy &enmPolicy, supportedPolicies)
|
---|
149 | pCombo->addItem(QString(), QVariant::fromValue(enmPolicy));
|
---|
150 |
|
---|
151 | /* Add hardcoded policy finally: */
|
---|
152 | pCombo->addItem(QString(), QVariant::fromValue(MACAddressImportPolicy_StripAllMACs));
|
---|
153 |
|
---|
154 | /* Set previous/default item if possible: */
|
---|
155 | int iNewIndex = -1;
|
---|
156 | if ( iNewIndex == -1
|
---|
157 | && enmOldData != MACAddressImportPolicy_MAX)
|
---|
158 | iNewIndex = pCombo->findData(QVariant::fromValue(enmOldData));
|
---|
159 | if ( iNewIndex == -1
|
---|
160 | && pCombo->count() > 0)
|
---|
161 | iNewIndex = 0;
|
---|
162 | if (iNewIndex != -1)
|
---|
163 | pCombo->setCurrentIndex(iNewIndex);
|
---|
164 |
|
---|
165 | /* Unblock signals after update: */
|
---|
166 | pCombo->blockSignals(false);
|
---|
167 |
|
---|
168 | /* Translate finally: */
|
---|
169 | retranslateMACImportPolicyCombo(pCombo);
|
---|
170 | }
|
---|
171 | }
|
---|
172 |
|
---|
173 | void UIWizardImportAppSettings::refreshFormPropertiesTable(UIFormEditorWidget *pFormEditor,
|
---|
174 | const CVirtualSystemDescriptionForm &comForm,
|
---|
175 | bool fIsSourceCloudOne)
|
---|
176 | {
|
---|
177 | /* Sanity check: */
|
---|
178 | AssertPtrReturnVoid(pFormEditor);
|
---|
179 |
|
---|
180 | /* If source is cloud one: */
|
---|
181 | if (fIsSourceCloudOne)
|
---|
182 | {
|
---|
183 | /* Make sure properties table get new description form: */
|
---|
184 | if (comForm.isNotNull())
|
---|
185 | pFormEditor->setVirtualSystemDescriptionForm(comForm);
|
---|
186 | }
|
---|
187 | /* If source is local one: */
|
---|
188 | else
|
---|
189 | {
|
---|
190 | /* Clear form: */
|
---|
191 | pFormEditor->clearForm();
|
---|
192 | }
|
---|
193 | }
|
---|
194 |
|
---|
195 | MACAddressImportPolicy UIWizardImportAppSettings::macAddressImportPolicy(QIComboBox *pCombo)
|
---|
196 | {
|
---|
197 | /* Sanity check: */
|
---|
198 | AssertPtrReturn(pCombo, MACAddressImportPolicy_MAX);
|
---|
199 |
|
---|
200 | /* Give the actual result: */
|
---|
201 | return pCombo->currentData().value<MACAddressImportPolicy>();
|
---|
202 | }
|
---|
203 |
|
---|
204 | bool UIWizardImportAppSettings::isImportHDsAsVDI(QCheckBox *pCheckBox)
|
---|
205 | {
|
---|
206 | /* Sanity check: */
|
---|
207 | AssertPtrReturn(pCheckBox, false);
|
---|
208 |
|
---|
209 | /* Give the actual result: */
|
---|
210 | return pCheckBox->isChecked();
|
---|
211 | }
|
---|
212 |
|
---|
213 | void UIWizardImportAppSettings::retranslateMACImportPolicyCombo(QIComboBox *pCombo)
|
---|
214 | {
|
---|
215 | /* Sanity check: */
|
---|
216 | AssertPtrReturnVoid(pCombo);
|
---|
217 |
|
---|
218 | /* Enumerate combo items: */
|
---|
219 | for (int i = 0; i < pCombo->count(); ++i)
|
---|
220 | {
|
---|
221 | const MACAddressImportPolicy enmPolicy = pCombo->itemData(i).value<MACAddressImportPolicy>();
|
---|
222 | switch (enmPolicy)
|
---|
223 | {
|
---|
224 | case MACAddressImportPolicy_KeepAllMACs:
|
---|
225 | {
|
---|
226 | pCombo->setItemText(i, UIWizardImportApp::tr("Include all network adapter MAC addresses"));
|
---|
227 | pCombo->setItemData(i, UIWizardImportApp::tr("Include all network adapter MAC addresses "
|
---|
228 | "during importing."), Qt::ToolTipRole);
|
---|
229 | break;
|
---|
230 | }
|
---|
231 | case MACAddressImportPolicy_KeepNATMACs:
|
---|
232 | {
|
---|
233 | pCombo->setItemText(i, UIWizardImportApp::tr("Include only NAT network adapter MAC addresses"));
|
---|
234 | pCombo->setItemData(i, UIWizardImportApp::tr("Include only NAT network adapter MAC addresses "
|
---|
235 | "during importing."), Qt::ToolTipRole);
|
---|
236 | break;
|
---|
237 | }
|
---|
238 | case MACAddressImportPolicy_StripAllMACs:
|
---|
239 | {
|
---|
240 | pCombo->setItemText(i, UIWizardImportApp::tr("Generate new MAC addresses for all network adapters"));
|
---|
241 | pCombo->setItemData(i, UIWizardImportApp::tr("Generate new MAC addresses for all network adapters "
|
---|
242 | "during importing."), Qt::ToolTipRole);
|
---|
243 | break;
|
---|
244 | }
|
---|
245 | default:
|
---|
246 | break;
|
---|
247 | }
|
---|
248 | }
|
---|
249 | }
|
---|
250 |
|
---|
251 | void UIWizardImportAppSettings::retranslateCertificateLabel(QLabel *pLabel, const kCertText &enmType, const QString &strSignedBy)
|
---|
252 | {
|
---|
253 | /* Sanity check: */
|
---|
254 | AssertPtrReturnVoid(pLabel);
|
---|
255 |
|
---|
256 | /* Handle known types: */
|
---|
257 | switch (enmType)
|
---|
258 | {
|
---|
259 | case kCertText_Unsigned:
|
---|
260 | pLabel->setText(UIWizardImportApp::tr("Appliance is not signed"));
|
---|
261 | break;
|
---|
262 | case kCertText_IssuedTrusted:
|
---|
263 | pLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(strSignedBy));
|
---|
264 | break;
|
---|
265 | case kCertText_IssuedExpired:
|
---|
266 | pLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(strSignedBy));
|
---|
267 | break;
|
---|
268 | case kCertText_IssuedUnverified:
|
---|
269 | pLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(strSignedBy));
|
---|
270 | break;
|
---|
271 | case kCertText_SelfSignedTrusted:
|
---|
272 | pLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(strSignedBy));
|
---|
273 | break;
|
---|
274 | case kCertText_SelfSignedExpired:
|
---|
275 | pLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(strSignedBy));
|
---|
276 | break;
|
---|
277 | case kCertText_SelfSignedUnverified:
|
---|
278 | pLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(strSignedBy));
|
---|
279 | break;
|
---|
280 | default:
|
---|
281 | AssertFailed();
|
---|
282 | RT_FALL_THRU();
|
---|
283 | case kCertText_Uninitialized:
|
---|
284 | pLabel->setText("<uninitialized page>");
|
---|
285 | break;
|
---|
286 | }
|
---|
287 | }
|
---|
288 |
|
---|
289 | void UIWizardImportAppSettings::updateMACImportPolicyComboToolTip(QIComboBox *pCombo)
|
---|
290 | {
|
---|
291 | /* Sanity check: */
|
---|
292 | AssertPtrReturnVoid(pCombo);
|
---|
293 |
|
---|
294 | /* Update tool-tip: */
|
---|
295 | const QString strCurrentToolTip = pCombo->currentData(Qt::ToolTipRole).toString();
|
---|
296 | pCombo->setToolTip(strCurrentToolTip);
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | /*********************************************************************************************************************************
|
---|
301 | * Class UIWizardImportAppPageSettings implementation. *
|
---|
302 | *********************************************************************************************************************************/
|
---|
303 |
|
---|
304 | UIWizardImportAppPageSettings::UIWizardImportAppPageSettings(const QString &strFileName)
|
---|
305 | : m_strFileName(strFileName)
|
---|
306 | , m_pLabelDescription(0)
|
---|
307 | , m_pSettingsWidget2(0)
|
---|
308 | , m_pApplianceWidget(0)
|
---|
309 | , m_pLabelImportFilePath(0)
|
---|
310 | , m_pEditorImportFilePath(0)
|
---|
311 | , m_pLabelMACImportPolicy(0)
|
---|
312 | , m_pComboMACImportPolicy(0)
|
---|
313 | , m_pLabelAdditionalOptions(0)
|
---|
314 | , m_pCheckboxImportHDsAsVDI(0)
|
---|
315 | , m_pCertLabel(0)
|
---|
316 | , m_enmCertText(kCertText_Uninitialized)
|
---|
317 | , m_pFormEditor(0)
|
---|
318 | {
|
---|
319 | /* Create main layout: */
|
---|
320 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
321 | if (pMainLayout)
|
---|
322 | {
|
---|
323 | /* Prepare label: */
|
---|
324 | m_pLabelDescription = new QIRichTextLabel(this);
|
---|
325 | if (m_pLabelDescription)
|
---|
326 | pMainLayout->addWidget(m_pLabelDescription);
|
---|
327 |
|
---|
328 | /* Prepare settings widget 2: */
|
---|
329 | m_pSettingsWidget2 = new QStackedWidget(this);
|
---|
330 | if (m_pSettingsWidget2)
|
---|
331 | {
|
---|
332 | /* Prepare appliance container: */
|
---|
333 | QWidget *pContainerAppliance = new QWidget(m_pSettingsWidget2);
|
---|
334 | if (pContainerAppliance)
|
---|
335 | {
|
---|
336 | /* Prepare appliance layout: */
|
---|
337 | QGridLayout *pLayoutAppliance = new QGridLayout(pContainerAppliance);
|
---|
338 | if (pLayoutAppliance)
|
---|
339 | {
|
---|
340 | pLayoutAppliance->setContentsMargins(0, 0, 0, 0);
|
---|
341 | pLayoutAppliance->setColumnStretch(0, 0);
|
---|
342 | pLayoutAppliance->setColumnStretch(1, 1);
|
---|
343 |
|
---|
344 | /* Prepare appliance widget: */
|
---|
345 | m_pApplianceWidget = new UIApplianceImportEditorWidget(pContainerAppliance);
|
---|
346 | if (m_pApplianceWidget)
|
---|
347 | {
|
---|
348 | m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
---|
349 | pLayoutAppliance->addWidget(m_pApplianceWidget, 0, 0, 1, 3);
|
---|
350 | }
|
---|
351 |
|
---|
352 | /* Prepare path selector label: */
|
---|
353 | m_pLabelImportFilePath = new QLabel(pContainerAppliance);
|
---|
354 | if (m_pLabelImportFilePath)
|
---|
355 | {
|
---|
356 | m_pLabelImportFilePath->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
357 | pLayoutAppliance->addWidget(m_pLabelImportFilePath, 1, 0);
|
---|
358 | }
|
---|
359 | /* Prepare path selector editor: */
|
---|
360 | m_pEditorImportFilePath = new UIFilePathSelector(pContainerAppliance);
|
---|
361 | if (m_pEditorImportFilePath)
|
---|
362 | {
|
---|
363 | m_pEditorImportFilePath->setResetEnabled(true);
|
---|
364 | m_pEditorImportFilePath->setDefaultPath(gpGlobalSession->virtualBox().GetSystemProperties().GetDefaultMachineFolder());
|
---|
365 | m_pEditorImportFilePath->setPath(gpGlobalSession->virtualBox().GetSystemProperties().GetDefaultMachineFolder());
|
---|
366 | m_pLabelImportFilePath->setBuddy(m_pEditorImportFilePath);
|
---|
367 | pLayoutAppliance->addWidget(m_pEditorImportFilePath, 1, 1, 1, 2);
|
---|
368 | }
|
---|
369 |
|
---|
370 | /* Prepare MAC address policy label: */
|
---|
371 | m_pLabelMACImportPolicy = new QLabel(pContainerAppliance);
|
---|
372 | if (m_pLabelMACImportPolicy)
|
---|
373 | {
|
---|
374 | m_pLabelMACImportPolicy->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
375 | pLayoutAppliance->addWidget(m_pLabelMACImportPolicy, 2, 0);
|
---|
376 | }
|
---|
377 | /* Prepare MAC address policy combo: */
|
---|
378 | m_pComboMACImportPolicy = new QIComboBox(pContainerAppliance);
|
---|
379 | if (m_pComboMACImportPolicy)
|
---|
380 | {
|
---|
381 | m_pComboMACImportPolicy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
---|
382 | m_pLabelMACImportPolicy->setBuddy(m_pComboMACImportPolicy);
|
---|
383 | pLayoutAppliance->addWidget(m_pComboMACImportPolicy, 2, 1, 1, 2);
|
---|
384 | }
|
---|
385 |
|
---|
386 | /* Prepare additional options label: */
|
---|
387 | m_pLabelAdditionalOptions = new QLabel(pContainerAppliance);
|
---|
388 | if (m_pLabelAdditionalOptions)
|
---|
389 | {
|
---|
390 | m_pLabelAdditionalOptions->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
391 | pLayoutAppliance->addWidget(m_pLabelAdditionalOptions, 3, 0);
|
---|
392 | }
|
---|
393 | /* Prepare import HDs as VDIs checkbox: */
|
---|
394 | m_pCheckboxImportHDsAsVDI = new QCheckBox(pContainerAppliance);
|
---|
395 | {
|
---|
396 | m_pCheckboxImportHDsAsVDI->setCheckState(Qt::Checked);
|
---|
397 | pLayoutAppliance->addWidget(m_pCheckboxImportHDsAsVDI, 3, 1);
|
---|
398 | }
|
---|
399 |
|
---|
400 | /* Prepare certificate label: */
|
---|
401 | m_pCertLabel = new QLabel(pContainerAppliance);
|
---|
402 | if (m_pCertLabel)
|
---|
403 | pLayoutAppliance->addWidget(m_pCertLabel, 4, 0, 1, 3);
|
---|
404 | }
|
---|
405 |
|
---|
406 | /* Add into widget: */
|
---|
407 | m_pSettingsWidget2->addWidget(pContainerAppliance);
|
---|
408 | }
|
---|
409 |
|
---|
410 | /* Prepare form editor container: */
|
---|
411 | QWidget *pContainerFormEditor = new QWidget(m_pSettingsWidget2);
|
---|
412 | if (pContainerFormEditor)
|
---|
413 | {
|
---|
414 | /* Prepare form editor layout: */
|
---|
415 | QVBoxLayout *pLayoutFormEditor = new QVBoxLayout(pContainerFormEditor);
|
---|
416 | if (pLayoutFormEditor)
|
---|
417 | {
|
---|
418 | pLayoutFormEditor->setContentsMargins(0, 0, 0, 0);
|
---|
419 |
|
---|
420 | /* Prepare form editor widget: */
|
---|
421 | m_pFormEditor = new UIFormEditorWidget(pContainerFormEditor);
|
---|
422 | if (m_pFormEditor)
|
---|
423 | pLayoutFormEditor->addWidget(m_pFormEditor);
|
---|
424 | }
|
---|
425 |
|
---|
426 | /* Add into widget: */
|
---|
427 | m_pSettingsWidget2->addWidget(pContainerFormEditor);
|
---|
428 | }
|
---|
429 |
|
---|
430 | /* Add into layout: */
|
---|
431 | pMainLayout->addWidget(m_pSettingsWidget2);
|
---|
432 | }
|
---|
433 | }
|
---|
434 |
|
---|
435 | /* Setup connections: */
|
---|
436 | connect(m_pEditorImportFilePath, &UIFilePathSelector::pathChanged,
|
---|
437 | this, &UIWizardImportAppPageSettings::sltHandleImportPathEditorChange);
|
---|
438 | connect(m_pComboMACImportPolicy, &QIComboBox::currentIndexChanged,
|
---|
439 | this, &UIWizardImportAppPageSettings::sltHandleMACImportPolicyComboChange);
|
---|
440 | connect(m_pCheckboxImportHDsAsVDI, &QCheckBox::stateChanged,
|
---|
441 | this, &UIWizardImportAppPageSettings::sltHandleImportHDsAsVDICheckBoxChange);
|
---|
442 | }
|
---|
443 |
|
---|
444 | UIWizardImportApp *UIWizardImportAppPageSettings::wizard() const
|
---|
445 | {
|
---|
446 | return qobject_cast<UIWizardImportApp*>(UINativeWizardPage::wizard());
|
---|
447 | }
|
---|
448 |
|
---|
449 | void UIWizardImportAppPageSettings::sltRetranslateUI()
|
---|
450 | {
|
---|
451 | /* Translate page: */
|
---|
452 | setTitle(UIWizardImportApp::tr("Appliance settings"));
|
---|
453 |
|
---|
454 | /* Translate description label: */
|
---|
455 | if (m_pLabelDescription)
|
---|
456 | {
|
---|
457 | if (wizard()->isSourceCloudOne())
|
---|
458 | m_pLabelDescription->setText(UIWizardImportApp::tr("These are the the suggested settings of the cloud VM import "
|
---|
459 | "procedure, they are influencing the resulting local VM instance. "
|
---|
460 | "You can change many of the properties shown by double-clicking "
|
---|
461 | "on the items and disable others using the check boxes below."));
|
---|
462 | else
|
---|
463 | m_pLabelDescription->setText(UIWizardImportApp::tr("These are the virtual machines contained in the appliance "
|
---|
464 | "and the suggested settings of the imported VirtualBox machines. "
|
---|
465 | "You can change many of the properties shown by double-clicking "
|
---|
466 | "on the items and disable others using the check boxes below."));
|
---|
467 | }
|
---|
468 |
|
---|
469 | /* Translate path selector label: */
|
---|
470 | if (m_pLabelImportFilePath)
|
---|
471 | m_pLabelImportFilePath->setText(UIWizardImportApp::tr("&Machine Base Folder:"));
|
---|
472 |
|
---|
473 | /* Translate MAC import policy label: */
|
---|
474 | if (m_pLabelMACImportPolicy)
|
---|
475 | m_pLabelMACImportPolicy->setText(UIWizardImportApp::tr("MAC Address &Policy:"));
|
---|
476 |
|
---|
477 | /* Translate additional options label: */
|
---|
478 | if (m_pLabelAdditionalOptions)
|
---|
479 | m_pLabelAdditionalOptions->setText(UIWizardImportApp::tr("Additional Options:"));
|
---|
480 | /* Translate additional option check-box: */
|
---|
481 | if (m_pCheckboxImportHDsAsVDI)
|
---|
482 | {
|
---|
483 | m_pCheckboxImportHDsAsVDI->setText(UIWizardImportApp::tr("&Import hard drives as VDI"));
|
---|
484 | m_pCheckboxImportHDsAsVDI->setToolTip(UIWizardImportApp::tr("When checked, all the hard drives that belong to this "
|
---|
485 | "appliance will be imported in VDI format."));
|
---|
486 | }
|
---|
487 |
|
---|
488 | /* Translate separate stuff: */
|
---|
489 | retranslateMACImportPolicyCombo(m_pComboMACImportPolicy);
|
---|
490 | retranslateCertificateLabel(m_pCertLabel, m_enmCertText, m_strSignedBy);
|
---|
491 |
|
---|
492 | /* Update tool-tips: */
|
---|
493 | updateMACImportPolicyComboToolTip(m_pComboMACImportPolicy);
|
---|
494 | }
|
---|
495 |
|
---|
496 | void UIWizardImportAppPageSettings::initializePage()
|
---|
497 | {
|
---|
498 | /* Make sure form-editor knows notification-center: */
|
---|
499 | m_pFormEditor->setNotificationCenter(wizard()->notificationCenter());
|
---|
500 | /* Translate page: */
|
---|
501 | sltRetranslateUI();
|
---|
502 |
|
---|
503 | /* Choose initially focused widget: */
|
---|
504 | if (wizard()->isSourceCloudOne())
|
---|
505 | m_pFormEditor->setFocus();
|
---|
506 | else
|
---|
507 | m_pApplianceWidget->setFocus();
|
---|
508 |
|
---|
509 | /* Fetch it, asynchronously: */
|
---|
510 | QMetaObject::invokeMethod(this, "sltAsyncInit", Qt::QueuedConnection);
|
---|
511 | }
|
---|
512 |
|
---|
513 | bool UIWizardImportAppPageSettings::validatePage()
|
---|
514 | {
|
---|
515 | /* Initial result: */
|
---|
516 | bool fResult = true;
|
---|
517 |
|
---|
518 | /* Check whether there was cloud source selected: */
|
---|
519 | if (wizard()->isSourceCloudOne())
|
---|
520 | {
|
---|
521 | /* Make sure table has own data committed: */
|
---|
522 | m_pFormEditor->makeSureEditorDataCommitted();
|
---|
523 |
|
---|
524 | /* Check whether we have proper VSD form: */
|
---|
525 | CVirtualSystemDescriptionForm comForm = wizard()->vsdImportForm();
|
---|
526 | fResult = comForm.isNotNull();
|
---|
527 |
|
---|
528 | /* Give changed VSD back to appliance: */
|
---|
529 | if (fResult)
|
---|
530 | {
|
---|
531 | comForm.GetVirtualSystemDescription();
|
---|
532 | fResult = comForm.isOk();
|
---|
533 | if (!fResult)
|
---|
534 | UINotificationMessage::cannotAcquireVirtualSystemDescriptionFormParameter(comForm, wizard()->notificationCenter());
|
---|
535 | }
|
---|
536 | }
|
---|
537 | else
|
---|
538 | {
|
---|
539 | /* Make sure widget has own data committed: */
|
---|
540 | m_pApplianceWidget->prepareImport();
|
---|
541 | }
|
---|
542 |
|
---|
543 | /* Try to import appliance: */
|
---|
544 | if (fResult)
|
---|
545 | fResult = wizard()->importAppliance();
|
---|
546 |
|
---|
547 | /* Return result: */
|
---|
548 | return fResult;
|
---|
549 | }
|
---|
550 |
|
---|
551 | void UIWizardImportAppPageSettings::sltAsyncInit()
|
---|
552 | {
|
---|
553 | /* If we have local source and file name passed,
|
---|
554 | * check if specified file contains valid appliance: */
|
---|
555 | if ( !wizard()->isSourceCloudOne()
|
---|
556 | && !m_strFileName.isEmpty()
|
---|
557 | && !wizard()->setFile(m_strFileName))
|
---|
558 | {
|
---|
559 | wizard()->reject();
|
---|
560 | return;
|
---|
561 | }
|
---|
562 |
|
---|
563 | /* Refresh page widgets: */
|
---|
564 | refreshStackedWidget(m_pSettingsWidget2,
|
---|
565 | wizard()->isSourceCloudOne());
|
---|
566 | refreshApplianceWidget(m_pApplianceWidget,
|
---|
567 | wizard()->localAppliance(),
|
---|
568 | wizard()->isSourceCloudOne());
|
---|
569 | refreshMACAddressImportPolicies(m_pComboMACImportPolicy,
|
---|
570 | wizard()->isSourceCloudOne());
|
---|
571 | refreshFormPropertiesTable(m_pFormEditor,
|
---|
572 | wizard()->vsdImportForm(),
|
---|
573 | wizard()->isSourceCloudOne());
|
---|
574 |
|
---|
575 | /* Init wizard fields: */
|
---|
576 | sltHandleImportPathEditorChange();
|
---|
577 | sltHandleMACImportPolicyComboChange();
|
---|
578 | sltHandleImportHDsAsVDICheckBoxChange();
|
---|
579 |
|
---|
580 | /* Handle appliance certificate: */
|
---|
581 | if (!wizard()->isSourceCloudOne())
|
---|
582 | handleApplianceCertificate();
|
---|
583 | }
|
---|
584 |
|
---|
585 | void UIWizardImportAppPageSettings::sltHandleImportPathEditorChange()
|
---|
586 | {
|
---|
587 | AssertPtrReturnVoid(m_pApplianceWidget);
|
---|
588 | AssertPtrReturnVoid(m_pEditorImportFilePath);
|
---|
589 | m_pApplianceWidget->setVirtualSystemBaseFolder(m_pEditorImportFilePath->path());
|
---|
590 | }
|
---|
591 |
|
---|
592 | void UIWizardImportAppPageSettings::sltHandleMACImportPolicyComboChange()
|
---|
593 | {
|
---|
594 | /* Update combo tool-tip: */
|
---|
595 | updateMACImportPolicyComboToolTip(m_pComboMACImportPolicy);
|
---|
596 |
|
---|
597 | /* Update wizard fields: */
|
---|
598 | wizard()->setMACAddressImportPolicy(macAddressImportPolicy(m_pComboMACImportPolicy));
|
---|
599 | }
|
---|
600 |
|
---|
601 | void UIWizardImportAppPageSettings::sltHandleImportHDsAsVDICheckBoxChange()
|
---|
602 | {
|
---|
603 | /* Update wizard fields: */
|
---|
604 | wizard()->setImportHDsAsVDI(isImportHDsAsVDI(m_pCheckboxImportHDsAsVDI));
|
---|
605 | }
|
---|
606 |
|
---|
607 | void UIWizardImportAppPageSettings::handleApplianceCertificate()
|
---|
608 | {
|
---|
609 | /* Handle certificate: */
|
---|
610 | CAppliance comAppliance = wizard()->localAppliance();
|
---|
611 | CCertificate comCertificate = comAppliance.GetCertificate();
|
---|
612 | if (comCertificate.isNull())
|
---|
613 | m_enmCertText = kCertText_Unsigned;
|
---|
614 | else
|
---|
615 | {
|
---|
616 | /* Pick a 'signed-by' name: */
|
---|
617 | m_strSignedBy = comCertificate.GetFriendlyName();
|
---|
618 |
|
---|
619 | /* If trusted, just select the right message: */
|
---|
620 | if (comCertificate.GetTrusted())
|
---|
621 | {
|
---|
622 | if (comCertificate.GetSelfSigned())
|
---|
623 | m_enmCertText = !comCertificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired;
|
---|
624 | else
|
---|
625 | m_enmCertText = !comCertificate.GetExpired() ? kCertText_IssuedTrusted : kCertText_IssuedExpired;
|
---|
626 | }
|
---|
627 | else
|
---|
628 | {
|
---|
629 | /* Not trusted! Must ask the user whether to continue in this case: */
|
---|
630 | m_enmCertText = comCertificate.GetSelfSigned() ? kCertText_SelfSignedUnverified : kCertText_IssuedUnverified;
|
---|
631 |
|
---|
632 | /* Translate page early: */
|
---|
633 | sltRetranslateUI();
|
---|
634 |
|
---|
635 | /* Instantiate the dialog: */
|
---|
636 | QPointer<UIApplianceUnverifiedCertificateViewer> pDialog =
|
---|
637 | new UIApplianceUnverifiedCertificateViewer(this, comCertificate);
|
---|
638 |
|
---|
639 | /* Show viewer in modal mode: */
|
---|
640 | const int iResultCode = pDialog->exec();
|
---|
641 | /* Leave if viewer destroyed prematurely: */
|
---|
642 | if (!pDialog)
|
---|
643 | return;
|
---|
644 | /* Delete viewer finally: */
|
---|
645 | delete pDialog;
|
---|
646 |
|
---|
647 | /* Dismiss the entire import-appliance wizard if user rejects certificate: */
|
---|
648 | if (iResultCode == QDialog::Rejected)
|
---|
649 | wizard()->reject();
|
---|
650 | }
|
---|
651 | }
|
---|
652 |
|
---|
653 | /* Translate certificate label: */
|
---|
654 | retranslateCertificateLabel(m_pCertLabel, m_enmCertText, m_strSignedBy);
|
---|
655 | }
|
---|