UIConverterBackendCOM.cpp revision 6fe2c7857678d9d48a4ac2798b62c702deeba133
/* $Id$ */
/** @file
* VBox Qt GUI - UIConverterBackend implementation.
*/
/*
* Copyright (C) 2012-2015 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.
*/
# include <precomp.h>
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Qt includes: */
# include <QApplication>
# include <QHash>
/* GUI includes: */
# include "UIConverterBackend.h"
# include "UIIconPool.h"
/* COM includes: */
# include "COMEnums.h"
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Determines if <Object of type X> can be converted to object of other type.
* These functions returns 'true' for all allowed conversions. */
template<> bool canConvert<KMachineState>() { return true; }
template<> bool canConvert<KSessionState>() { return true; }
template<> bool canConvert<KParavirtProvider>() { return true; }
template<> bool canConvert<KDeviceType>() { return true; }
template<> bool canConvert<KClipboardMode>() { return true; }
template<> bool canConvert<KDnDMode>() { return true; }
template<> bool canConvert<KPointingHIDType>() { return true; }
template<> bool canConvert<KMediumType>() { return true; }
template<> bool canConvert<KMediumVariant>() { return true; }
template<> bool canConvert<KNetworkAttachmentType>() { return true; }
template<> bool canConvert<KNetworkAdapterType>() { return true; }
template<> bool canConvert<KNetworkAdapterPromiscModePolicy>() { return true; }
template<> bool canConvert<KPortMode>() { return true; }
template<> bool canConvert<KUSBControllerType>() { return true; }
template<> bool canConvert<KUSBDeviceState>() { return true; }
template<> bool canConvert<KUSBDeviceFilterAction>() { return true; }
template<> bool canConvert<KAudioDriverType>() { return true; }
template<> bool canConvert<KAudioControllerType>() { return true; }
template<> bool canConvert<KAuthType>() { return true; }
template<> bool canConvert<KStorageBus>() { return true; }
template<> bool canConvert<KStorageControllerType>() { return true; }
template<> bool canConvert<KChipsetType>() { return true; }
template<> bool canConvert<KNATProtocol>() { return true; }
/* QColor <= KMachineState: */
{
switch (state)
{
// case KMachineState_FaultTolerantSyncing:
// case KMachineState_FirstOnline:
// case KMachineState_LastOnline:
// case KMachineState_FirstTransient:
// case KMachineState_LastTransient:
}
return QColor();
}
/* QIcon <= KMachineState: */
{
switch (state)
{
// case KMachineState_FaultTolerantSyncing:
case KMachineState_DeletingSnapshotOnline: return UIIconPool::iconSet(":/state_discarding_16px.png");
case KMachineState_DeletingSnapshotPaused: return UIIconPool::iconSet(":/state_discarding_16px.png");
case KMachineState_SettingUp: return UIIconPool::iconSet(":/vm_settings_16px.png"); // TODO: Change icon!
// case KMachineState_FirstOnline:
// case KMachineState_LastOnline:
// case KMachineState_FirstTransient:
// case KMachineState_LastTransient:
}
return QIcon();
}
/* QString <= KMachineState: */
{
switch (state)
{
case KMachineState_PoweredOff: return QApplication::translate("VBoxGlobal", "Powered Off", "MachineState");
case KMachineState_Aborted: return QApplication::translate("VBoxGlobal", "Aborted", "MachineState");
case KMachineState_Teleported: return QApplication::translate("VBoxGlobal", "Teleported", "MachineState");
case KMachineState_Running: return QApplication::translate("VBoxGlobal", "Running", "MachineState");
case KMachineState_Stuck: return QApplication::translate("VBoxGlobal", "Guru Meditation", "MachineState");
case KMachineState_Teleporting: return QApplication::translate("VBoxGlobal", "Teleporting", "MachineState");
case KMachineState_Snapshotting: return QApplication::translate("VBoxGlobal", "Taking Snapshot", "MachineState");
case KMachineState_OnlineSnapshotting: return QApplication::translate("VBoxGlobal", "Taking Online Snapshot", "MachineState");
case KMachineState_LiveSnapshotting: return QApplication::translate("VBoxGlobal", "Taking Live Snapshot", "MachineState");
case KMachineState_Starting: return QApplication::translate("VBoxGlobal", "Starting", "MachineState");
case KMachineState_Stopping: return QApplication::translate("VBoxGlobal", "Stopping", "MachineState");
case KMachineState_Restoring: return QApplication::translate("VBoxGlobal", "Restoring", "MachineState");
case KMachineState_TeleportingPausedVM: return QApplication::translate("VBoxGlobal", "Teleporting Paused VM", "MachineState");
case KMachineState_TeleportingIn: return QApplication::translate("VBoxGlobal", "Teleporting", "MachineState");
case KMachineState_FaultTolerantSyncing: return QApplication::translate("VBoxGlobal", "Fault Tolerant Syncing", "MachineState");
case KMachineState_DeletingSnapshotOnline: return QApplication::translate("VBoxGlobal", "Deleting Snapshot", "MachineState");
case KMachineState_DeletingSnapshotPaused: return QApplication::translate("VBoxGlobal", "Deleting Snapshot", "MachineState");
case KMachineState_RestoringSnapshot: return QApplication::translate("VBoxGlobal", "Restoring Snapshot", "MachineState");
case KMachineState_DeletingSnapshot: return QApplication::translate("VBoxGlobal", "Deleting Snapshot", "MachineState");
case KMachineState_SettingUp: return QApplication::translate("VBoxGlobal", "Setting Up", "MachineState");
// case KMachineState_FirstOnline:
// case KMachineState_LastOnline:
// case KMachineState_FirstTransient:
// case KMachineState_LastTransient:
}
return QString();
}
/* QString <= KSessionState: */
{
switch (state)
{
case KSessionState_Unlocked: return QApplication::translate("VBoxGlobal", "Unlocked", "SessionState");
case KSessionState_Spawning: return QApplication::translate("VBoxGlobal", "Spawning", "SessionState");
case KSessionState_Unlocking: return QApplication::translate("VBoxGlobal", "Unlocking", "SessionState");
}
return QString();
}
/* QString <= KParavirtProvider: */
{
switch (type)
{
case KParavirtProvider_None: return QApplication::translate("VBoxGlobal", "None", "ParavirtProvider");
case KParavirtProvider_Default: return QApplication::translate("VBoxGlobal", "Default", "ParavirtProvider");
case KParavirtProvider_Legacy: return QApplication::translate("VBoxGlobal", "Legacy", "ParavirtProvider");
case KParavirtProvider_Minimal: return QApplication::translate("VBoxGlobal", "Minimal", "ParavirtProvider");
case KParavirtProvider_HyperV: return QApplication::translate("VBoxGlobal", "Hyper-V", "ParavirtProvider");
case KParavirtProvider_KVM: return QApplication::translate("VBoxGlobal", "KVM", "ParavirtProvider");
}
return QString();
}
/* QString <= KDeviceType: */
{
switch (type)
{
case KDeviceType_SharedFolder: return QApplication::translate("VBoxGlobal", "Shared Folder", "DeviceType");
}
return QString();
}
/* QString <= KClipboardMode: */
{
switch (mode)
{
case KClipboardMode_Disabled: return QApplication::translate("VBoxGlobal", "Disabled", "ClipboardType");
case KClipboardMode_HostToGuest: return QApplication::translate("VBoxGlobal", "Host To Guest", "ClipboardType");
case KClipboardMode_GuestToHost: return QApplication::translate("VBoxGlobal", "Guest To Host", "ClipboardType");
case KClipboardMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "ClipboardType");
}
return QString();
}
/* QString <= KDnDMode: */
{
switch (mode)
{
case KDnDMode_Disabled: return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType");
case KDnDMode_HostToGuest: return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType");
case KDnDMode_GuestToHost: return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType");
case KDnDMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "DragAndDropType");
}
return QString();
}
/* QString <= KPointingHIDType: */
{
switch (type)
{
case KPointingHIDType_PS2Mouse: return QApplication::translate("VBoxGlobal", "PS/2 Mouse", "PointingHIDType");
case KPointingHIDType_USBMouse: return QApplication::translate("VBoxGlobal", "USB Mouse", "PointingHIDType");
case KPointingHIDType_USBTablet: return QApplication::translate("VBoxGlobal", "USB Tablet", "PointingHIDType");
case KPointingHIDType_ComboMouse: return QApplication::translate("VBoxGlobal", "PS/2 and USB Mouse", "PointingHIDType");
case KPointingHIDType_USBMultiTouch: return QApplication::translate("VBoxGlobal", "USB Multi-Touch Tablet", "PointingHIDType");
}
return QString();
}
/* QString <= KMediumType: */
{
switch (type)
{
case KMediumType_Immutable: return QApplication::translate("VBoxGlobal", "Immutable", "MediumType");
case KMediumType_Writethrough: return QApplication::translate("VBoxGlobal", "Writethrough", "MediumType");
case KMediumType_Shareable: return QApplication::translate("VBoxGlobal", "Shareable", "MediumType");
case KMediumType_MultiAttach: return QApplication::translate("VBoxGlobal", "Multi-attach", "MediumType");
}
return QString();
}
/* QString <= KMediumVariant: */
{
/* Note: KMediumVariant_Diff and KMediumVariant_Fixed are so far mutually exclusive: */
switch (variant)
{
case KMediumVariant_Standard:
return QApplication::translate("VBoxGlobal", "Dynamically allocated differencing storage", "MediumVariant");
return QApplication::translate("VBoxGlobal", "Dynamically allocated storage split into files of less than 2GB", "MediumVariant");
return QApplication::translate("VBoxGlobal", "Dynamically allocated differencing storage split into files of less than 2GB", "MediumVariant");
return QApplication::translate("VBoxGlobal", "Fixed size storage split into files of less than 2GB", "MediumVariant");
return QApplication::translate("VBoxGlobal", "Dynamically allocated compressed storage", "MediumVariant");
case (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_VmdkStreamOptimized | KMediumVariant_Diff):
return QApplication::translate("VBoxGlobal", "Dynamically allocated differencing compressed storage", "MediumVariant");
default:
}
return QString();
}
/* QString <= KNetworkAttachmentType: */
{
switch (type)
{
case KNetworkAttachmentType_Null: return QApplication::translate("VBoxGlobal", "Not attached", "NetworkAttachmentType");
case KNetworkAttachmentType_NAT: return QApplication::translate("VBoxGlobal", "NAT", "NetworkAttachmentType");
case KNetworkAttachmentType_Bridged: return QApplication::translate("VBoxGlobal", "Bridged Adapter", "NetworkAttachmentType");
case KNetworkAttachmentType_Internal: return QApplication::translate("VBoxGlobal", "Internal Network", "NetworkAttachmentType");
case KNetworkAttachmentType_HostOnly: return QApplication::translate("VBoxGlobal", "Host-only Adapter", "NetworkAttachmentType");
case KNetworkAttachmentType_Generic: return QApplication::translate("VBoxGlobal", "Generic Driver", "NetworkAttachmentType");
case KNetworkAttachmentType_NATNetwork: return QApplication::translate("VBoxGlobal", "NAT Network", "NetworkAttachmentType");
}
return QString();
}
/* QString <= KNetworkAdapterType: */
{
switch (type)
{
case KNetworkAdapterType_Am79C970A: return QApplication::translate("VBoxGlobal", "PCnet-PCI II (Am79C970A)", "NetworkAdapterType");
case KNetworkAdapterType_Am79C973: return QApplication::translate("VBoxGlobal", "PCnet-FAST III (Am79C973)", "NetworkAdapterType");
case KNetworkAdapterType_I82540EM: return QApplication::translate("VBoxGlobal", "Intel PRO/1000 MT Desktop (82540EM)", "NetworkAdapterType");
case KNetworkAdapterType_I82543GC: return QApplication::translate("VBoxGlobal", "Intel PRO/1000 T Server (82543GC)", "NetworkAdapterType");
case KNetworkAdapterType_I82545EM: return QApplication::translate("VBoxGlobal", "Intel PRO/1000 MT Server (82545EM)", "NetworkAdapterType");
#ifdef VBOX_WITH_VIRTIO
case KNetworkAdapterType_Virtio: return QApplication::translate("VBoxGlobal", "Paravirtualized Network (virtio-net)", "NetworkAdapterType");
#endif /* VBOX_WITH_VIRTIO */
}
return QString();
}
/* QString <= KNetworkAdapterPromiscModePolicy: */
{
switch (policy)
{
default:
}
return QString();
}
/* QString <= KPortMode: */
{
switch (mode)
{
case KPortMode_Disconnected: return QApplication::translate("VBoxGlobal", "Disconnected", "PortMode");
}
return QString();
}
/* QString <= KUSBControllerType: */
{
switch (type)
{
case KUSBControllerType_OHCI: return QApplication::translate("VBoxGlobal", "OHCI", "USBControllerType");
case KUSBControllerType_EHCI: return QApplication::translate("VBoxGlobal", "EHCI", "USBControllerType");
case KUSBControllerType_XHCI: return QApplication::translate("VBoxGlobal", "xHCI", "USBControllerType");
}
return QString();
}
/* QString <= KUSBDeviceState: */
{
switch (state)
{
case KUSBDeviceState_NotSupported: return QApplication::translate("VBoxGlobal", "Not supported", "USBDeviceState");
case KUSBDeviceState_Unavailable: return QApplication::translate("VBoxGlobal", "Unavailable", "USBDeviceState");
case KUSBDeviceState_Available: return QApplication::translate("VBoxGlobal", "Available", "USBDeviceState");
case KUSBDeviceState_Captured: return QApplication::translate("VBoxGlobal", "Captured", "USBDeviceState");
}
return QString();
}
/* QString <= KUSBDeviceFilterAction: */
{
switch (action)
{
case KUSBDeviceFilterAction_Ignore: return QApplication::translate("VBoxGlobal", "Ignore", "USBDeviceFilterAction");
case KUSBDeviceFilterAction_Hold: return QApplication::translate("VBoxGlobal", "Hold", "USBDeviceFilterAction");
}
return QString();
}
/* QString <= KAudioDriverType: */
{
switch (type)
{
case KAudioDriverType_Null: return QApplication::translate("VBoxGlobal", "Null Audio Driver", "AudioDriverType");
case KAudioDriverType_WinMM: return QApplication::translate("VBoxGlobal", "Windows Multimedia", "AudioDriverType");
case KAudioDriverType_OSS: return QApplication::translate("VBoxGlobal", "OSS Audio Driver", "AudioDriverType");
case KAudioDriverType_ALSA: return QApplication::translate("VBoxGlobal", "ALSA Audio Driver", "AudioDriverType");
case KAudioDriverType_DirectSound: return QApplication::translate("VBoxGlobal", "Windows DirectSound", "AudioDriverType");
case KAudioDriverType_CoreAudio: return QApplication::translate("VBoxGlobal", "CoreAudio", "AudioDriverType");
// case KAudioDriverType_MMPM:
case KAudioDriverType_Pulse: return QApplication::translate("VBoxGlobal", "PulseAudio", "AudioDriverType");
case KAudioDriverType_SolAudio: return QApplication::translate("VBoxGlobal", "Solaris Audio", "AudioDriverType");
}
return QString();
}
/* QString <= KAudioControllerType: */
{
switch (type)
{
case KAudioControllerType_AC97: return QApplication::translate("VBoxGlobal", "ICH AC97", "AudioControllerType");
case KAudioControllerType_SB16: return QApplication::translate("VBoxGlobal", "SoundBlaster 16", "AudioControllerType");
case KAudioControllerType_HDA: return QApplication::translate("VBoxGlobal", "Intel HD Audio", "AudioControllerType");
}
return QString();
}
/* QString <= KAuthType: */
{
switch (type)
{
}
return QString();
}
/* QString <= KStorageBus: */
{
switch (bus)
{
}
return QString();
}
/* QString <= KStorageControllerType: */
{
switch (type)
{
case KStorageControllerType_LsiLogic: return QApplication::translate("VBoxGlobal", "Lsilogic", "StorageControllerType");
case KStorageControllerType_BusLogic: return QApplication::translate("VBoxGlobal", "BusLogic", "StorageControllerType");
case KStorageControllerType_IntelAhci: return QApplication::translate("VBoxGlobal", "AHCI", "StorageControllerType");
case KStorageControllerType_PIIX3: return QApplication::translate("VBoxGlobal", "PIIX3", "StorageControllerType");
case KStorageControllerType_PIIX4: return QApplication::translate("VBoxGlobal", "PIIX4", "StorageControllerType");
case KStorageControllerType_ICH6: return QApplication::translate("VBoxGlobal", "ICH6", "StorageControllerType");
case KStorageControllerType_I82078: return QApplication::translate("VBoxGlobal", "I82078", "StorageControllerType");
case KStorageControllerType_LsiLogicSas: return QApplication::translate("VBoxGlobal", "LsiLogic SAS", "StorageControllerType");
case KStorageControllerType_USB: return QApplication::translate("VBoxGlobal", "USB", "StorageControllerType");
}
return QString();
}
/* QString <= KChipsetType: */
{
switch (type)
{
}
return QString();
}
/* QString <= KNATProtocol: */
{
switch (protocol)
{
}
return QString();
}
/* QString <= KNATProtocol: */
{
switch (protocol)
{
default:
{
break;
}
}
return strResult;
}
/* KNATProtocol <= QString: */
{
/* Here we have some fancy stuff allowing us
* to search through the keys using 'case-insensitive' rule: */
/* Invalid type for unknown words: */
{
AssertMsgFailed(("No value for '%s'"));
return KNATProtocol_UDP;
}
/* Corresponding type for known words: */
}
/* KPortMode <= QString: */
{
list.insert(QApplication::translate("VBoxGlobal", "Disconnected", "PortMode"), KPortMode_Disconnected);
list.insert(QApplication::translate("VBoxGlobal", "Host Device", "PortMode"), KPortMode_HostDevice);
{
}
}
/* KUSBDeviceFilterAction <= QString: */
{
list.insert(QApplication::translate("VBoxGlobal", "Ignore", "USBDeviceFilterAction"), KUSBDeviceFilterAction_Ignore);
list.insert(QApplication::translate("VBoxGlobal", "Hold", "USBDeviceFilterAction"), KUSBDeviceFilterAction_Hold);
{
}
}
/* KAudioDriverType <= QString: */
{
list.insert(QApplication::translate("VBoxGlobal", "Null Audio Driver", "AudioDriverType"), KAudioDriverType_Null);
list.insert(QApplication::translate("VBoxGlobal", "Windows Multimedia", "AudioDriverType"), KAudioDriverType_WinMM);
list.insert(QApplication::translate("VBoxGlobal", "OSS Audio Driver", "AudioDriverType"), KAudioDriverType_OSS);
list.insert(QApplication::translate("VBoxGlobal", "ALSA Audio Driver", "AudioDriverType"), KAudioDriverType_ALSA);
list.insert(QApplication::translate("VBoxGlobal", "Windows DirectSound", "AudioDriverType"), KAudioDriverType_DirectSound);
list.insert(QApplication::translate("VBoxGlobal", "CoreAudio", "AudioDriverType"), KAudioDriverType_CoreAudio);
// list.insert(..., KAudioDriverType_MMPM);
list.insert(QApplication::translate("VBoxGlobal", "PulseAudio", "AudioDriverType"), KAudioDriverType_Pulse);
list.insert(QApplication::translate("VBoxGlobal", "Solaris Audio", "AudioDriverType"), KAudioDriverType_SolAudio);
{
}
}
/* KAudioControllerType <= QString: */
{
list.insert(QApplication::translate("VBoxGlobal", "ICH AC97", "AudioControllerType"), KAudioControllerType_AC97);
list.insert(QApplication::translate("VBoxGlobal", "SoundBlaster 16", "AudioControllerType"), KAudioControllerType_SB16);
list.insert(QApplication::translate("VBoxGlobal", "Intel HD Audio", "AudioControllerType"), KAudioControllerType_HDA);
{
}
}
/* KAuthType <= QString: */
{
{
}
}
/* KStorageControllerType <= QString: */
{
list.insert(QApplication::translate("VBoxGlobal", "Lsilogic", "StorageControllerType"), KStorageControllerType_LsiLogic);
list.insert(QApplication::translate("VBoxGlobal", "BusLogic", "StorageControllerType"), KStorageControllerType_BusLogic);
list.insert(QApplication::translate("VBoxGlobal", "AHCI", "StorageControllerType"), KStorageControllerType_IntelAhci);
list.insert(QApplication::translate("VBoxGlobal", "PIIX3", "StorageControllerType"), KStorageControllerType_PIIX3);
list.insert(QApplication::translate("VBoxGlobal", "PIIX4", "StorageControllerType"), KStorageControllerType_PIIX4);
list.insert(QApplication::translate("VBoxGlobal", "ICH6", "StorageControllerType"), KStorageControllerType_ICH6);
list.insert(QApplication::translate("VBoxGlobal", "I82078", "StorageControllerType"), KStorageControllerType_I82078);
list.insert(QApplication::translate("VBoxGlobal", "LsiLogic SAS", "StorageControllerType"), KStorageControllerType_LsiLogicSas);
list.insert(QApplication::translate("VBoxGlobal", "USB", "StorageControllerType"), KStorageControllerType_USB);
{
}
}