UIExportApplianceWzd.cpp revision 194a8ad893b721dfc22ac5f955671f09db015a3f
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* UIExportApplianceWzd class implementation
*/
/*
* Copyright (C) 2009-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* Global includes */
#include <QDir>
/* Local includes */
#include "UIExportApplianceWzd.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
class VMListWidgetItems : public QListWidgetItem
{
public:
{
}
/* Sort like in the VM selector of the main window */
bool operator<(const QListWidgetItem &other) const
{
}
};
UIExportApplianceWzd::UIExportApplianceWzd(QWidget *pParent, const QString &strSelectName) : QIWizard(pParent)
{
/* Create & add pages */
/* Set 'selectedVMName' field for wizard page 1 */
/* Initial translate */
/* Initial translate all pages */
/* Resize to 'golden ratio' */
#ifdef Q_WS_MAC
/* Assign background image */
assignBackground(":/vmw_ovf_export_bg.png");
#else /* Q_WS_MAC */
/* Assign watermark */
assignWatermark(":/vmw_ovf_export.png");
#endif /* Q_WS_MAC */
/* Setup connections */
("Appliance Widget Pointer is not set!\n"));
}
void UIExportApplianceWzd::retranslateUi()
{
/* Wizard title */
/* Extra buttons */
}
{
}
{
/* Decorate page */
/* Register 'selectedVMName', 'machineNames', 'machineIDs' fields! */
/* Configure 'VM Selector' settings */
m_pVMSelector->setAlternatingRowColors(true);
/* Configure 'VM Selector' connections */
/* Fill 'VM Selector' */
}
{
/* Translate uic generated strings */
/* Wizard page 1 title */
"exporting an appliance.</p><p>%1</p><p>Please select "
"the virtual machines that should be added to the "
"appliance. You can select more than one. Please note "
"that these machines have to be turned off before they "
"can be exported.</p>")
.arg(standardHelpText()));
}
{
/* Fill and translate */
/* Choose initially selected item (if passed) */
}
void UIExportApplianceWzdPage1::cleanupPage()
{
/* Do NOT call superclass method, it will clean defailt (initially set) field - 'selectedVMName'! */
}
bool UIExportApplianceWzdPage1::isComplete() const
{
/* There should be at least one vm selected! */
}
{
/* Clear lists initially */
/* Iterate over all the selected items */
{
}
/* Revalidate page */
}
{
/* Add all VM items into 'VM Selector' */
{
bool bEnabled;
if (m.GetAccessible())
{
pixIcon = vboxGlobal().vmGuestOSTypeIcon(m.GetOSTypeId()).scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
else
{
pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
bEnabled = false;
}
if (!bEnabled)
}
}
{
/* Decorate page */
/* Register ExportAppliancePointer class */
/* Register 'applianceWidget' field! */
}
{
/* Translate uic generated strings */
/* Wizard page 2 title */
}
{
/* Fill and translate */
/* We propose a filename the first time the second page is displayed */
}
void UIExportApplianceWzdPage2::cleanupPage()
{
/* Do NOT call superclass method, it will clean defailt (initially set) field - 'applianceWidget'! */
}
int UIExportApplianceWzdPage2::nextId() const
{
/* Skip next (3rd, storage-type) page for now! */
}
{
if (fResult)
{
/* Iterate over all the selected machine ids */
{
/* Get the machine with the uuid */
if (fResult)
{
/* Add the export description to our appliance object */
if (!fResult)
{
return false;
}
/* Now add some new fields the user may change */
}
else
break;
}
/* Make sure the settings widget get the new descriptions */
}
if (!fResult)
return fResult;
}
{
/* Decorate page */
/* Register StorageType class */
/* Register 'storageType' field! */
/* Setup connections */
#if 0
/* Load storage-type from GUI extra data */
bool ok;
if (ok)
{
switch (storageType)
{
case Filesystem:
m_pTypeLocalFilesystem->setChecked(true);
break;
case SunCloud:
m_pTypeSunCloud->setChecked(true);
break;
case S3:
m_pTypeSimpleStorageSystem->setChecked(true);
break;
}
}
#else
/* Just select first of types */
#endif
}
{
/* Translate uic generated strings */
/* Wizard page 3 title */
}
{
/* Fill and translate */
/* Revert to initial choice */
}
{
/* Update selected storage-type */
if (m_pTypeLocalFilesystem->isChecked())
else if (m_pTypeSunCloud->isChecked())
else if (m_pTypeSimpleStorageSystem->isChecked())
m_StorageType = S3;
else
/* Revalidate page */
}
{
/* Decorate page */
/* Configure the file selector */
m_pFileSelector->setEditable(true);
/* Complete validators for the file selector page */
#if 0
/* Load default attributes from GUI extra data */
#endif
}
{
/* Translate uic generated strings */
/* Wizard page 4 title */
/* Setup defaults */
/* Translate the file selector */
}
{
/* Fill and translate */
/* Setup components for chosen storage-type */
switch (storageType)
{
case Filesystem:
m_pTxUsername->setVisible(false);
m_pLeUsername->setVisible(false);
m_pTxPassword->setVisible(false);
m_pLePassword->setVisible(false);
m_pTxHostname->setVisible(false);
m_pLeHostname->setVisible(false);
m_pTxBucket->setVisible(false);
m_pLeBucket->setVisible(false);
m_pSelectOVF09->setVisible(true);
m_pFileSelector->setChooserVisible(true);
break;
case SunCloud:
"and the bucket, and provide a filename for the OVF target."));
m_pTxUsername->setVisible(true);
m_pLeUsername->setVisible(true);
m_pTxPassword->setVisible(true);
m_pLePassword->setVisible(true);
m_pTxHostname->setVisible(false);
m_pLeHostname->setVisible(false);
m_pTxBucket->setVisible(true);
m_pLeBucket->setVisible(true);
m_pSelectOVF09->setVisible(false);
m_pSelectOVF09->setChecked(false);
m_pFileSelector->setChooserVisible(false);
break;
case S3:
"hostname and the bucket, and provide a filename for the OVF target."));
m_pTxUsername->setVisible(true);
m_pLeUsername->setVisible(true);
m_pTxPassword->setVisible(true);
m_pLePassword->setVisible(true);
m_pTxHostname->setVisible(true);
m_pLeHostname->setVisible(true);
m_pTxBucket->setVisible(true);
m_pLeBucket->setVisible(true);
m_pSelectOVF09->setVisible(true);
m_pFileSelector->setChooserVisible(false);
break;
}
{
if (storageType == Filesystem)
strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName));
}
{
/* Set the default filename */
/* If it is one VM only, we use the VM name as file name */
strName += ".ovf";
if (storageType == Filesystem)
strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName));
}
("Appliance Widget Pointer is not set!\n"));
}
bool UIExportApplianceWzdPage4::isComplete() const
{
switch (storageType)
{
case Filesystem:
break;
case SunCloud:
break;
case S3:
break;
}
return bComplete;
}
{
return exportAppliance();
}
{
("Appliance Widget Pointer is not set!\n"));
/* 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. */
{
}
if (fResult)
{
/* Show some progress, so the user know whats going on */
if (progress.GetCanceled())
return false;
{
return false;
}
}
/* Check if the file exists already, if yes get confirmation for overwriting from the user. */
return false;
/* Ok all is confirmed so delete all the files which exists */
{
if (fResult)
{
/* Show some progress, so the user know whats going on */
if (progress1.GetCanceled())
return false;
{
return false;
}
}
}
/* Export the VMs, on success we are finished */
{
#if 0
/* Save attributes to GUI extra data */
vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_Export_StorageType, QString::number(storageType));
#endif
return true;
}
return false;
}
{
/* Write the appliance */
if (fResult)
{
/* Show some progress, so the user know whats going on */
if (progress.GetCanceled())
return false;
{
return false;
}
else
return true;
}
if (!fResult)
return false;
}
{
switch (type)
{
case Filesystem:
{
return m_pFileSelector->path();
}
case SunCloud:
{
uri = QString("%1%2/%3/%4").arg(uri).arg("object.storage.network.com").arg(m_pLeBucket->text()).arg(m_pFileSelector->path());
return uri;
}
case S3:
{
uri = QString("%1%2/%3/%4").arg(uri).arg(m_pLeHostname->text()).arg(m_pLeBucket->text()).arg(m_pFileSelector->path());
return uri;
}
}
return QString();
}