VBoxGlobal.cpp revision dec9d74d86b70d20c0a62d7d0bbd49d0b5c26d28
/* $Id$ */
/** @file
* VBox Qt GUI - VBoxGlobal class implementation.
*/
/*
* Copyright (C) 2006-2013 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.
*/
/* Qt includes: */
#include <QProgressDialog>
#include <QLibraryInfo>
#include <QFileDialog>
#include <QToolTip>
#include <QTranslator>
#include <QDesktopWidget>
#include <QDesktopServices>
#include <QMutex>
#include <QReadLocker>
#include <QToolButton>
#include <QProcess>
#include <QThread>
#include <QPainter>
#include <QSettings>
#include <QTimer>
#include <QDir>
#include <QLocale>
# include <QNetworkProxy>
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
#include <QSpinBox>
#include <QStyleOptionSpinBox>
#ifdef Q_WS_WIN
# include <QEventLoop>
#endif /* Q_WS_WIN */
#ifdef Q_WS_X11
# include <QTextBrowser>
# include <QScrollBar>
# include <QX11Info>
#endif /* Q_WS_X11 */
#ifdef VBOX_GUI_WITH_PIDFILE
# include <QTextStream>
#endif /* VBOX_GUI_WITH_PIDFILE */
/* GUI includes: */
#include "VBoxGlobal.h"
#include "VBoxUtils.h"
#include "UISelectorWindow.h"
#include "UIMessageCenter.h"
#include "UIPopupCenter.h"
#include "QIMessageBox.h"
#include "QIDialogButtonBox.h"
#include "UIIconPool.h"
#include "UIShortcutPool.h"
#include "UIActionPoolSelector.h"
#include "UIActionPoolRuntime.h"
#include "UIExtraDataEventHandler.h"
#include "QIFileDialog.h"
# include "UINetworkManager.h"
# include "UIUpdateManager.h"
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
#include "UIMachine.h"
#include "UISession.h"
#include "UIConverter.h"
#include "UIMediumEnumerator.h"
#include "UIMedium.h"
#ifdef Q_WS_X11
# include "UIHostComboEditor.h"
# ifndef VBOX_OSE
# include "VBoxLicenseViewer.h"
# endif /* VBOX_OSE */
# include "VBoxX11Helper.h"
#endif /* Q_WS_X11 */
#ifdef Q_WS_MAC
# include "VBoxUtils-darwin.h"
# include "UIMachineWindowFullscreen.h"
# include "UIMachineWindowSeamless.h"
#endif /* Q_WS_MAC */
#ifdef VBOX_WITH_VIDEOHWACCEL
# include "VBoxFBOverlay.h"
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* COM includes: */
#include "CMachine.h"
#include "CSystemProperties.h"
#include "CUSBDevice.h"
#include "CUSBDeviceFilters.h"
#include "CUSBDeviceFilter.h"
#include "CBIOSSettings.h"
#include "CVRDEServer.h"
#include "CStorageController.h"
#include "CMediumAttachment.h"
#include "CAudioAdapter.h"
#include "CNetworkAdapter.h"
#include "CSerialPort.h"
#include "CParallelPort.h"
#include "CUSBController.h"
#include "CHostUSBDevice.h"
#include "CHostVideoInputDevice.h"
#include "CMediumFormat.h"
#include "CSharedFolder.h"
#include "CConsole.h"
#include "CSnapshot.h"
/* Other VBox includes: */
#include <VBox/VBoxOGLTest.h>
#ifdef Q_WS_X11
#endif /* Q_WS_X11 */
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
/* External includes: */
#include <math.h>
#ifdef Q_WS_WIN
#include "shlobj.h"
#endif /* Q_WS_WIN */
#ifdef Q_WS_X11
* in COMDefs.h. A better fix would be to isolate X11-specific
* stuff by placing XX* helpers below to a separate source file. */
#endif /* Q_WS_X11 */
//#define VBOX_WITH_FULL_DETAILS_REPORT /* hidden for now */
//#warning "port me: check this"
/// @todo bird: Use (U)INT_PTR, (U)LONG_PTR, DWORD_PTR, or (u)intptr_t.
#if defined(Q_OS_WIN64)
#else
typedef long Q_LONG; /* word up to 64 bit signed */
typedef unsigned long Q_ULONG; /* word up to 64 bit unsigned */
#endif
// VBoxGlobal
////////////////////////////////////////////////////////////////////////////////
/** @internal
*
* Determines the rendering mode from the argument. Sets the appropriate
* default rendering mode if the argument is NULL.
*/
{
#if defined(Q_WS_MAC) && defined(VBOX_GUI_USE_QUARTZ2D)
mode = Quartz2DMode;
#elif defined(VBOX_GUI_USE_QIMAGE)
mode = QImageMode;
#else
# error "Cannot determine the default render mode!"
#endif
if (aModeStr)
{
if (0) ;
#ifdef VBOX_GUI_USE_QIMAGE
mode = QImageMode;
#endif /* VBOX_GUI_USE_QIMAGE */
#ifdef VBOX_GUI_USE_QUARTZ2D
mode = Quartz2DMode;
#endif /* VBOX_GUI_USE_QUARTZ2D */
}
return mode;
}
/* static */
bool VBoxGlobal::m_sfCleanupInProgress = false;
/* static */
void VBoxGlobal::create()
{
/* Make sure instance is NOT created yet: */
if (m_spInstance)
{
AssertMsgFailed(("VBoxGlobal instance is already created!"));
return;
}
/* Create instance: */
new VBoxGlobal;
/* Prepare instance: */
m_spInstance->prepare();
}
/* static */
void VBoxGlobal::destroy()
{
/* Make sure instance is NOT destroyed yet: */
if (!m_spInstance)
{
AssertMsgFailed(("VBoxGlobal instance is already destroyed!"));
return;
}
/* Cleanup instance: */
/* Automatically on QApplication::aboutToQuit() signal: */
/* Destroy instance: */
delete m_spInstance;
}
: mValid (false)
, mSelectorWnd (NULL)
, m_pVirtualMachine(0)
, m_pMediumEnumerator(0)
, mIsKWinManaged (false)
#if defined(DEBUG_bird)
, mAgressiveCaching(false)
#else
, mAgressiveCaching(true)
#endif
, mRestoreCurrentSnapshot(false)
, mDisablePatm(false)
, mDisableCsam(false)
, mRecompileSupervisor(false)
, mRecompileUser(false)
, mExecuteAllInIem(false)
, mWarpPct(100)
, mVerString("1.0")
, m3DAvailable(-1)
, mSettingsPwSet(false)
{
/* Assign instance: */
m_spInstance = this;
}
VBoxGlobal::~VBoxGlobal()
{
/* Unassign instance: */
m_spInstance = 0;
}
/* static */
{
}
/* static */
{
}
/* static */
{
}
/* static */
{
}
{
return mVBox.GetVersion();
}
{
return mVBox.GetVersionNormalized();
}
bool VBoxGlobal::isBeta() const
{
}
#ifdef Q_WS_MAC
/** Returns #MacOSXRelease determined using <i>uname</i> call. */
{
/* Prepare 'utsname' struct: */
{
/* Parse known .release types: */
return MacOSXRelease_Mavericks;
else
return MacOSXRelease_MountainLion;
else
return MacOSXRelease_Lion;
else
return MacOSXRelease_SnowLeopard;
}
/* Unknown by default: */
return MacOSXRelease_Unknown;
}
#endif /* Q_WS_MAC */
/**
* Sets the new global settings and saves them to the VirtualBox server.
*/
{
{
return false;
}
/* We don't assign gs to our gset member here, because VBoxCallback
* will update gset as necessary when new settings are successfully
* sent to the VirtualBox server by gs.save(). */
return true;
}
/**
* Returns a reference to the main VBox VM Selector window.
* The reference is valid until application termination.
*
* There is only one such a window per VirtualBox application.
*/
{
("Must NOT be a VM console process"));
if (!mSelectorWnd)
{
/*
* We pass the address of mSelectorWnd to the constructor to let it be
* initialized right after the constructor is called. It is necessary
* to avoid recursion, since this method may be (and will be) called
* from the below constructor or from constructors/methods it calls.
*/
Assert (w == mSelectorWnd);
NOREF(w);
}
return *mSelectorWnd;
}
{
/* Some restrictions: */
/* Restore current snapshot if asked to do so: */
{
return false;
/* Show the snapshot-discard progress: */
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
if (progress.GetResultCode() != 0)
/* Clear the restore flag so media enum can be started, should be safe now. */
mRestoreCurrentSnapshot = false;
}
/* Create VM session: */
return false;
/* Start virtual machine: */
return true;
}
{
return m_pVirtualMachine;
}
{
/* Null if that is NOT console-process or machine not yet created: */
if (!isVMConsoleProcess() || !m_pVirtualMachine)
return 0;
/* Active machine-window otherwise: */
return m_pVirtualMachine->activeWindow();
}
/**
* Inner worker that for lazily querying for 3D support.
*
* Rational is that when starting a text mode guest (like DOS) that does not
* have 3D enabled, don't wast the developer's or user's time on launching the
* test application when starting the VM or editing it's settings.
*
* @returns true / false.
* @note If we ever end up checking this concurrently on multiple threads, use a
* RTONCE construct to serialize the efforts.
*/
bool VBoxGlobal::is3DAvailableWorker() const
{
#ifdef VBOX_WITH_CROGL
bool fSupported = VBoxOglIs3DAccelerationSupported();
#else
bool fSupported = false;
#endif
return fSupported;
}
#ifdef VBOX_GUI_WITH_PIDFILE
void VBoxGlobal::createPidfile()
{
if (!m_strPidfile.isEmpty())
{
{
}
else
}
}
void VBoxGlobal::deletePidfile()
{
if ( !m_strPidfile.isEmpty()
}
#endif
{
if (aForce)
return true;
if (mBrandingConfig.isEmpty())
{
mBrandingConfig += "/custom/custom.ini";
}
}
/**
* Gets a value from the custom .ini file
*/
{
}
#ifdef Q_WS_X11
{
/* Prepare empty resulting list: */
/* Get current display: */
/* If it's a Xinerama desktop: */
if (XineramaIsActive(pDisplay))
{
/* Reading Xinerama data: */
int iScreens = 0;
/* Fill resulting list: */
for (int i = 0; i < iScreens; ++ i)
/* Free screens data: */
}
/* Return resulting list: */
return result;
}
{
/* Get current display: */
/* Get virtual desktop window: */
/* Get 'client list' atom: */
/* Prepare empty resulting list: */
/* If atom does not exists return empty list: */
if (propNameAtom == None)
return result;
/* Get atom value: */
int iRealFormat = 0;
unsigned long uItemsCount = 0;
unsigned long uBytesAfter = 0;
unsigned char *pData = 0;
/* If get property is failed return empty list: */
return result;
/* Fill resulting list with win ids: */
for (ulong i = 0; i < uItemsCount; ++ i)
result << pWindowData[i];
/* Releasing resources: */
/* Return resulting list: */
return result;
}
{
/* Get current display: */
/* Get 'strut' atom: */
/* Prepare empty resulting list: */
/* If atom does not exists return empty list: */
if (propNameAtom == None)
return result;
/* Get atom value: */
int iRealFormat = 0;
ulong uItemsCount = 0;
ulong uBytesAfter = 0;
unsigned char *pData = 0;
/* If get property is failed return empty list: */
return result;
/* Fill resulting list with strut shifts: */
for (ulong i = 0; i < uItemsCount; ++ i)
result << pStrutsData[i];
/* Releasing resources: */
/* Return resulting list: */
return result;
}
#endif /* ifdef Q_WS_X11 */
{
/* Prepare empty result: */
#ifdef Q_WS_X11
/* Get current display: */
/* Get current application desktop: */
/* If it's a virtual desktop: */
if (pDesktopWidget->isVirtualDesktop())
{
/* If it's a Xinerama desktop: */
if (XineramaIsActive(pDisplay))
{
/* Get desktops list: */
/* Combine to get full virtual region: */
virtualRegion += desktop;
/* Remember initial virtual desktop: */
//AssertMsgFailed(("LOG... Virtual desktop is: %dx%dx%dx%d\n", virtualDesktop.x(), virtualDesktop.y(),
// virtualDesktop.width(), virtualDesktop.height()));
/* Set available geometry to screen geometry initially: */
/* Feat available geometry of virtual desktop to respect all the struts: */
{
/* Get window: */
/* If window has strut: */
{
if (uLeftShift)
{
//AssertMsgFailed(("LOG... Subtract left strut: top-left: %dx%d, size: %dx%d\n", sr.x(), sr.y(), sr.width(), sr.height()));
virtualRegion -= sr;
}
if (uRightShift)
{
//AssertMsgFailed(("LOG... Subtract right strut: top-left: %dx%d, size: %dx%d\n", sr.x(), sr.y(), sr.width(), sr.height()));
virtualRegion -= sr;
}
if (uTopShift)
{
//AssertMsgFailed(("LOG... Subtract top strut: top-left: %dx%d, size: %dx%d\n", sr.x(), sr.y(), sr.width(), sr.height()));
virtualRegion -= sr;
}
if (uBottomShift)
{
//AssertMsgFailed(("LOG... Subtract bottom strut: top-left: %dx%d, size: %dx%d\n", sr.x(), sr.y(), sr.width(), sr.height()));
virtualRegion -= sr;
}
}
}
/* Get final available geometry: */
}
}
/* If result is still NULL: */
{
/* Use QT default functionality: */
}
//AssertMsgFailed(("LOG... Final geometry: %dx%dx%dx%d\n", result.x(), result.y(), result.width(), result.height()));
#else /* ifdef Q_WS_X11 */
#endif /* ifndef Q_WS_X11 */
return result;
}
/**
* Returns the list of few guest OS types, queried from
* IVirtualBox corresponding to every family id.
*/
{
for (int i = 0; i < mFamilyIDs.size(); ++i)
return result;
}
/**
* Returns the list of all guest OS types, queried from
* IVirtualBox corresponding to passed family id.
*/
{
AssertMsg(mFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
}
/**
* Returns the icon corresponding to the given guest OS type id.
*/
{
return p ? *p : none;
}
/**
* Returns the guest OS type object corresponding to the given type id of list
* containing OS types related to OS family determined by family id attribute.
* If the index is invalid a null object is returned.
*/
{
{
}
else
{
for (int i = 0; i < mFamilyIDs.size(); ++ i)
}
return list [j];
return CGuestOSType();
}
/**
* Returns the description corresponding to the given guest OS type id.
*/
{
for (int i = 0; i < mFamilyIDs.size(); ++ i)
{
return list [j].GetDescription();
}
}
struct PortConfig
{
const char *name;
};
static const PortConfig kComKnownPorts[] =
{
{ "COM1", 4, 0x3F8 },
{ "COM2", 3, 0x2F8 },
{ "COM3", 4, 0x3E8 },
{ "COM4", 3, 0x2E8 },
/* must not contain an element with IRQ=0 and IOBase=0 used to cause
* toCOMPortName() to return the "User-defined" string for these values. */
};
static const PortConfig kLptKnownPorts[] =
{
{ "LPT1", 7, 0x378 },
{ "LPT2", 5, 0x278 },
{ "LPT1", 2, 0x3BC },
/* must not contain an element with IRQ=0 and IOBase=0 used to cause
* toLPTPortName() to return the "User-defined" string for these values. */
};
/**
* Similar to toString (KMediumType), but returns 'Differencing' for
* normal hard disks that have a parent.
*/
{
{
return mDiskTypes_Differencing;
}
}
/**
* Returns the list of the standard COM port names (i.e. "COMx").
*/
{
return list;
}
/**
* Returns the list of the standard LPT port names (i.e. "LPTx").
*/
{
return list;
}
/**
* Returns the name of the standard COM port corresponding to the given
* parameters, or "User-defined" (which is also returned when both
* @a aIRQ and @a aIOBase are 0).
*/
{
return kComKnownPorts [i].name;
return mUserDefinedPortName;
}
/**
* Returns the name of the standard LPT port corresponding to the given
* parameters, or "User-defined" (which is also returned when both
* @a aIRQ and @a aIOBase are 0).
*/
{
return kLptKnownPorts [i].name;
return mUserDefinedPortName;
}
/**
* Returns port parameters corresponding to the given standard COM name.
* Returns @c true on success, or @c false if the given port name is not one
* of the standard names (i.e. "COMx").
*/
{
{
return true;
}
return false;
}
/**
* Returns port parameters corresponding to the given standard LPT name.
* Returns @c true on success, or @c false if the given port name is not one
* of the standard names (i.e. "LPTx").
*/
{
{
return true;
}
return false;
}
{
/* Search for corresponding UI medium: */
{
/* UI medium may be new and not among our mediums, request enumeration: */
/* Search for corresponding UI medium again: */
{
/* Medium might be deleted already, return null string: */
return QString();
}
}
/* Return UI medium details: */
}
/**
* Returns the details of the given USB device as a single-line string.
*/
{
else
{
{
sDetails =
}
else
{
sDetails = p;
else
sDetails = m + " " + p;
}
if (r != 0)
}
}
/**
* Returns the multi-line description of the given USB device.
*/
{
tr ("<nobr>Vendor ID: %1</nobr><br>"
"<nobr>Product ID: %2</nobr><br>"
"<nobr>Revision: %3</nobr>", "USB device tooltip")
/* add the state field if it's a host USB device */
{
}
return tip;
}
/**
* Returns the multi-line description of the given USB filter
*/
{
if (!manufacturer.isEmpty())
.arg (manufacturer);
/* add the state field if it's a host USB device */
{
}
return tip;
}
/** Returns the multi-line description of the given CHostVideoInputDevice filter. */
{
}
/**
* Returns a details report on a given VM represented as a HTML table.
*
* @param aMachine Machine to create a report for.
* @param aWithLinks @c true if section titles should be hypertext links.
*/
{
/* Details templates */
static const char *sTableTpl =
"<table border=0 cellspacing=1 cellpadding=0>%1</table>";
static const char *sSectionHrefTpl =
"<tr><td width=22 rowspan=%1 align=left><img src='%2'></td>"
"<td colspan=3><b><a href='%3'><nobr>%4</nobr></a></b></td></tr>"
"%5"
"<tr><td colspan=3><font size=1> </font></td></tr>";
static const char *sSectionBoldTpl =
"<tr><td width=22 rowspan=%1 align=left><img src='%2'></td>"
"<td colspan=3><!-- %3 --><b><nobr>%4</nobr></b></td></tr>"
"%5"
"<tr><td colspan=3><font size=1> </font></td></tr>";
static const char *sSectionItemTpl1 =
"<tr><td width=40%><nobr><i>%1</i></nobr></td><td/><td/></tr>";
static const char *sSectionItemTpl2 =
"<tr><td width=40%><nobr>%1:</nobr></td><td/><td>%2</td></tr>";
static const char *sSectionItemTpl3 =
"<tr><td width=40%><nobr>%1</nobr></td><td/><td/></tr>";
/* Compose details report */
/* General */
{
report += sectionTpl
"#general", /* link */
item); /* items */
}
/* System */
{
/* BIOS Settings holder */
/* System details row count: */
/* Boot order */
{
if (device == KDeviceType_Null)
continue;
bootOrder += ", ";
}
/* ACPI */
/* I/O APIC */
#endif /* VBOX_WITH_FULL_DETAILS_REPORT */
/* Nested Paging */
if (fVTxAMDVSupported)
#endif /* VBOX_WITH_FULL_DETAILS_REPORT */
;
if (fVTxAMDVSupported)
report += sectionTpl
"#system", /* link */
item); /* items */
}
/* Display */
{
/* Rows including section header and footer */
int rows = 2;
/* Video tab */
++rows;
if (cGuestScreens > 1)
{
.arg(cGuestScreens);
++rows;
}
++rows;
#ifdef VBOX_WITH_VIDEOHWACCEL
++ rows;
#endif
/* VRDP tab */
{
if (srv.GetEnabled())
else
++ rows;
}
report += sectionTpl
"#display", /* link */
item); /* items */
}
/* Storage */
{
/* Rows including section header and footer */
int rows = 2;
/* Iterate over the all machine controllers: */
for (int i = 0; i < controllers.size(); ++i)
{
/* Get current controller: */
/* Add controller information: */
++ rows;
/* Populate sorted map with attachments information: */
CMediumAttachmentVector attachments = aMachine.GetMediumAttachmentsOfController(controller.GetName());
for (int j = 0; j < attachments.size(); ++j)
{
/* Get current attachment: */
/* Prepare current storage slot: */
if (!strDeviceType.isNull())
/* Prepare current medium object: */
/* Prepare information about current medium & attachment: */
/* Insert that attachment into map: */
if (!strAttachmentInfo.isNull())
}
/* Iterate over the sorted map with attachments information: */
{
/* Add controller information: */
++rows;
}
}
{
++ rows;
}
report += sectionTpl
"#storage", /* link */
item); /* items */
}
/* Audio */
{
if (audio.GetEnabled())
else
report += sectionTpl
"#audio", /* link */
item); /* items */
}
/* Network */
{
{
if (adapter.GetEnabled())
{
/* don't use the adapter type string for types that have
* this name instead */
if (type == KNetworkAttachmentType_Bridged)
else if (type == KNetworkAttachmentType_Internal)
else if (type == KNetworkAttachmentType_HostOnly)
else if (type == KNetworkAttachmentType_Generic)
else if (type == KNetworkAttachmentType_NATNetwork)
else
++ rows;
}
}
{
++ rows;
}
report += sectionTpl
"#network", /* link */
item); /* items */
}
/* Serial Ports */
{
{
if (port.GetEnabled())
{
if (mode == KPortMode_HostPipe ||
mode == KPortMode_HostDevice ||
else
++ rows;
}
}
{
++ rows;
}
report += sectionTpl
"#serialPorts", /* link */
item); /* items */
}
/* Parallel Ports */
{
{
if (port.GetEnabled())
{
QString (" (<nobr>%1</nobr>)")
++ rows;
}
}
{
++ rows;
}
/* Temporary disabled */
"#parallelPorts", /* link */
item); /* items */
}
/* USB */
{
&& aMachine.GetUSBProxyAvailable())
{
/* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
if (cOhciCtls)
{
active ++;
}
else
report += sectionTpl
"#usb", /* link */
item); /* items */
}
}
/* Shared Folders */
{
if (count > 0)
{
}
else
report += sectionTpl
"#sfolders", /* link */
item); /* items */
}
}
{
/* Prepare session: */
/* Simulate try-catch block: */
bool fSuccess = false;
do
{
/* Create empty session instance: */
{
break;
}
/* Search for the corresponding machine: */
{
break;
}
/* Lock found machine to session: */
{
break;
}
/* Pass the language ID as the property to the guest: */
{
/* Make sure that the language is in two letter code.
* Note: if languageId() returns an empty string lang.name() will
* return "C" which is an valid language code. */
}
/* Success finally: */
fSuccess = true;
}
while (0);
/* Cleanup try-catch block: */
if (!fSuccess)
/* Return session: */
return session;
}
void VBoxGlobal::reloadProxySettings()
{
if (proxyManager.authEnabled())
{
proxyManager.setAuthEnabled(false);
}
if (proxyManager.proxyEnabled())
{
#if 0
#else
#endif
}
else
{
}
}
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
{
/* Create medium in medium-enumerator: */
if (m_pMediumEnumerator)
}
{
/* Delete medium from medium-enumerator: */
if (m_pMediumEnumerator)
}
/* Open some external medium using file open dialog
* and temporary cache (enumerate) it in GUI inner mediums cache: */
bool fUseLastFolder /* = false */)
{
/* Initialize variables: */
switch (mediumType)
{
case UIMediumType_HardDisk:
{
if (strLastFolder.isEmpty())
if (strLastFolder.isEmpty())
break;
}
case UIMediumType_DVD:
{
if (strLastFolder.isEmpty())
if (strLastFolder.isEmpty())
break;
}
case UIMediumType_Floppy:
{
if (strLastFolder.isEmpty())
if (strLastFolder.isEmpty())
break;
}
default:
break;
}
/* Prepare filters and backends: */
{
/* Get iterated filter: */
/* Create one backend filter string: */
/* Save the suffix's for the "All" entry: */
}
/* Create open file dialog: */
QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, pParent, strTitle, 0, true, true);
/* If dialog has some result: */
return QString();
}
QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0*/)
{
/* Convert to native separators: */
/* Initialize variables: */
/* Remember the path of the last chosen medium: */
QString();
/* Update recently used list: */
QString();
/* Open corresponding medium: */
CMedium cmedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite, false);
{
/* Prepare vbox medium wrapper: */
/* First of all we should test if that medium already opened: */
{
/* And create new otherwise: */
}
/* Return uimedium id: */
}
else
return QString();
}
{
/* Make sure VBoxGlobal is already valid: */
/* Make sure medium-enumerator is already created: */
if (!m_pMediumEnumerator)
return;
/* Make sure enumeration is not already started: */
return;
/* Ignore the request during VBoxGlobal cleanup: */
return;
/* If asked to restore snapshot, don't do this till *after* we're done
* restoring or the code with have a heart attack. */
if (shouldRestoreCurrentSnapshot())
return;
/* Developer doesn't want any unnecessary media caching! */
if (!fForceStart && !agressiveCaching())
return;
/* Redirect request to medium-enumerator: */
if (m_pMediumEnumerator)
}
bool VBoxGlobal::isMediumEnumerationInProgress() const
{
/* Redirect request to medium-enumerator: */
return m_pMediumEnumerator
}
{
/* Redirect call to medium-enumerator: */
if (m_pMediumEnumerator)
return UIMedium();
}
{
/* Redirect call to medium-enumerator: */
if (m_pMediumEnumerator)
return m_pMediumEnumerator->mediumIDs();
}
{
/* Current attachment attributes: */
const CMediumAttachment currentAttachment = machine.GetMediumAttachment(strControllerName, storageSlot.port, storageSlot.device);
const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
/* Other medium-attachments of same machine: */
/* Determine device & medium types: */
/* Prepare open-existing-medium action: */
QAction *pActionOpenExistingMedium = menu.addAction(QIcon(":/select_file_16px.png"), QString(), pListener, pszSlotName);
pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
/* Insert separator: */
menu.addSeparator();
/* Get existing-host-drive vector: */
switch (mediumType)
{
default: break;
}
/* Prepare choose-existing-host-drive actions: */
{
/* Make sure host-drive usage is unique: */
bool fIsHostDriveUsed = false;
{
if (otherAttachment != currentAttachment)
{
{
fIsHostDriveUsed = true;
break;
}
}
}
/* If host-drives usage is unique: */
if (!fIsHostDriveUsed)
{
QAction *pActionChooseHostDrive = menu.addAction(UIMedium(medium, mediumType).name(), pListener, pszSlotName);
pActionChooseHostDrive->setCheckable(true);
pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
}
}
/* Get recent-medium list: */
switch (mediumType)
{
default: break;
}
const QStringList recentMediumList = vboxGlobal().virtualBox().GetExtraData(strRecentMediumAddress).split(';');
/* Prepare choose-recent-medium actions: */
{
/* Convert separators to native: */
/* Confirm medium presence: */
continue;
/* Make sure recent-medium usage is unique: */
bool fIsRecentMediumUsed = false;
{
if (otherAttachment != currentAttachment)
{
{
fIsRecentMediumUsed = true;
break;
}
}
}
/* If recent-medium usage is unique: */
if (!fIsRecentMediumUsed)
{
QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), pListener, pszSlotName);
pActionChooseRecentMedium->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation);
pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
}
}
/* Insert separator: */
menu.addSeparator();
/* Prepare unmount-current-medium action: */
switch (mediumType)
{
case UIMediumType_DVD:
pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file..."));
pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_disabled_16px.png"));
break;
case UIMediumType_Floppy:
pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file..."));
pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_disabled_16px.png"));
break;
default:
break;
}
}
{
/* Mount (by default): */
bool fMount = true;
/* Null medium (by default): */
/* With null ID (by default): */
/* Current mount-target attributes: */
const CMediumAttachment currentAttachment = constMachine.GetMediumAttachment(target.name, target.port, target.device);
/* Which additional info do we have? */
{
/* Do we have an exact ID? */
{
/* New mount-target attributes: */
/* Invoke file-open dialog to choose medium ID: */
{
/* Keyboard can be captured by machine-view.
* So we should clear machine-view focus to let file-open dialog get it.
* That way the keyboard will be released too.. */
QWidget *pLastFocusedWidget = 0;
if (QApplication::focusWidget())
{
}
/* Call for file-open dialog: */
const QString strMediumID = vboxGlobal().openMediumWithFileOpenDialog(target.mediumType, activeMachineWindow(),
/* Return focus back: */
if (pLastFocusedWidget)
/* Accept new medium ID: */
if (!strMediumID.isNull())
/* Else just exit: */
else return;
}
/* Use medium ID which was passed: */
/* Should we mount or unmount? */
/* Prepare target medium: */
break;
}
/* Do we have a resent location? */
{
/* Open medium by location and get new medium ID if any: */
/* Else just exit: */
return;
/* Should we mount or unmount? */
/* Prepare target medium: */
break;
}
}
/* Get editable machine: */
/* Session state unlocked? */
if (sessionState == KSessionState_Unlocked)
{
/* Open own 'write' session: */
}
/* Is it Selector UI call? */
else if (!isVMConsoleProcess())
{
/* Open existing 'shared' session: */
}
/* Else this is Runtime UI call
* which has session locked for itself. */
bool fWasMounted = false;
fWasMounted = true;
else
{
/* Ask for force remounting: */
{
fWasMounted = true;
else
}
}
/* Save settings: */
if (fWasMounted)
{
}
/* Close session to editable machine if necessary: */
}
/**
* Native language name of the currently installed translation.
* Returns "English" if no translation is installed
* or if the translation file is invalid.
*/
{
"Native language name");
}
/**
* Native language country name of the currently installed translation.
* Returns "--" if no translation is installed or if the translation file is
* invalid, or if the language is independent on the country.
*/
{
"Native language country name "
"(empty if this language is for all countries)");
}
/**
* Language name of the currently installed translation, in English.
* Returns "English" if no translation is installed
* or if the translation file is invalid.
*/
{
"Language name, in English");
}
/**
* Language country name of the currently installed translation, in English.
* Returns "--" if no translation is installed or if the translation file is
* invalid, or if the language is independent on the country.
*/
{
"Language country name, in English "
"(empty if native country name is empty)");
}
/**
* Comma-separated list of authors of the currently installed translation.
* Returns "Oracle Corporation" if no translation is installed or if the
* translation file is invalid, or if the translation is supplied by Oracle
* Corporation
*/
{
"Comma-separated list of translators");
}
/**
* Changes the language of all global string constants according to the
* currently installed translations tables.
*/
void VBoxGlobal::retranslateUi()
{
/* Re-enumerate uimedium since they contain some translations too: */
if (mValid)
#ifdef Q_WS_X11
/* As X11 do not have functionality for providing human readable key names,
* we keep a table of them, which must be updated when the language is changed. */
#endif /* Q_WS_X11 */
}
// public static stuff
////////////////////////////////////////////////////////////////////////////////
/* static */
{
return true;
return false;
}
const char *gVBoxLangSubDir = "/nls";
const char *gVBoxLangFileBase = "VirtualBox_";
const char *gVBoxLangFileExt = ".qm";
const char *gVBoxLangIDRegExp = "(([a-z]{2})(?:_([A-Z]{2}))?)|(C)";
const char *gVBoxBuiltInLangName = "C";
class VBoxTranslator : public QTranslator
{
public:
: QTranslator (aParent) {}
{
return false;
}
private:
};
static VBoxTranslator *sTranslator = 0;
/**
* Returns the loaded (active) language ID.
* Note that it may not match with VBoxGlobalSettings::languageId() if the
* specified language cannot be loaded.
* If the built-in language is active, this method returns "C".
*
* @note "C" is treated as the built-in language for simplicity -- the C
* locale is used in unix environments as a fallback when the requested
* locale is invalid. This way we don't need to process both the "built_in"
* language and the "C" language (which is a valid environment setting)
* separately.
*/
/* static */
{
return sLoadedLangId;
}
/**
* Loads the language by language ID.
*
* @param aLangId Language ID in in form of xx_YY. QString::null means the
* system default language.
*/
/* static */
{
/* If C is selected we change it temporary to en. This makes sure any extra
* "en" translation file will be loaded. This is necessary for loading the
* plural forms of some of our translations. */
bool fResetToC = false;
if (langId == "C")
{
langId = "en";
fResetToC = true;
}
char szNlsPath[RTPATH_MAX];
int rc;
{
/* the language ID should match the regexp completely */
AssertReturnVoid (pos == 0);
{
}
{
}
else
{
/* Never complain when the default language is requested. In any
* case, if no explicit language file exists, we will simply
* fall-back to English (built-in). */
/* selectedLangId remains built-in here */
}
}
/* delete the old translator if there is one */
if (sTranslator)
{
/* QTranslator destructor will call qApp->removeTranslator() for
* us. It will also delete all its child translations we attach to it
* below, so we don't have to care about them specially. */
delete sTranslator;
}
/* load new language files */
bool loadOk = true;
if (sTranslator)
{
if (selectedLangId != gVBoxBuiltInLangName)
{
}
/* we install the translator in any case: on failure, this will
* activate an empty translator that will give us English
* (built-in) */
}
else
loadOk = false;
if (loadOk)
else
{
}
/* Try to load the corresponding Qt translation */
if (sLoadedLangId != gVBoxBuiltInLangName)
{
#ifdef Q_OS_UNIX
/* We use system installations of Qt on Linux systems, so first, try
* to load the Qt translation from the system location. */
/* Note that the Qt translation supplied by Oracle is always loaded
* afterwards to make sure it will take precedence over the system
* translation (it may contain more decent variants of translation
* that better correspond to VirtualBox UI). We need to load both
* because a newer version of Qt may be installed on the user computer
* and the Oracle version may not fully support it. We don't do it on
* Win32 because we supply a Qt library there and therefore the
* Oracle translation is always the best one. */
#endif
/* The below message doesn't fit 100% (because it's an additional
* language and the main one won't be reset to built-in on failure)
* but the load failure is so rare here that it's not worth a separate
* message (but still, having something is better than having none) */
}
if (fResetToC)
sLoadedLangId = "C";
#ifdef Q_WS_MAC
/* Qt doesn't translate the items in the Application menu initially.
* Manually trigger an update. */
#endif /* Q_WS_MAC */
}
{
#if defined (Q_WS_WIN32)
# if defined VBOX_OSE
# else
# endif
#endif
/* Where are the docs located? */
char szDocsPath[RTPATH_MAX];
/* Make sure that the language is in two letter code.
* Note: if languageId() returns an empty string lang.name() will
* return "C" which is an valid language code. */
/* Construct the path and the filename */
/* Check if a help file with that name exists */
return manual;
/* Fall back to the standard */
return manual;
}
/**
* Replacement for QToolButton::setTextLabel() that handles the shortcut
* letter (if it is present in the argument string) as if it were a setText()
* call: the shortcut letter is used to automatically assign an "Alt+<letter>"
* accelerator key sequence to the given tool button.
*
* @note This method preserves the icon set if it was assigned before. Only
* the text label and the accelerator are changed.
*
* @param aToolButton Tool button to set the text label on.
* @param aTextLabel Text label to set.
*/
/* static */
const QString &aTextLabel)
{
/* remember the icon set as setText() will kill it */
/* re-use the setText() method to detect and set the accelerator */
/* set the accel last as setIconSet() would kill it */
}
/**
* Performs direct and flipped search of position for \a aRectangle to make sure
* it is fully contained inside \a aBoundRegion region by moving & resizing
* \a aRectangle if necessary. Selects the minimum shifted result between direct
* and flipped variants.
*/
/* static */
bool aCanResize /* = true */)
{
/* Direct search for normalized rectangle */
/* Flipped search for normalized rectangle */
/* Calculate shift from starting position for both variants */
/* Return minimum shifted variant */
}
/**
* Ensures that the given rectangle \a aRectangle is fully contained within the
* region \a aBoundRegion by moving \a aRectangle if necessary. If \a aRectangle is
* larger than \a aBoundRegion, top left corner of \a aRectangle is aligned with the
* top left corner of maximum available rectangle and, if \a aCanResize is true,
* \a aRectangle is shrinked to become fully visible.
*/
/* static */
bool /* aCanResize = true */)
{
/* Storing available horizontal sub-rectangles & vertical shifts */
{
int itemPosition = 0;
{
}
int shift2TopPos = 0;
int shift2BotPos = 0;
}
/* Trying to find the appropriate place for window */
{
/* Move to appropriate vertical */
/* Search horizontal shift */
int maxShift = 0;
{
continue;
{
}
{
}
}
/* Shift across the horizontal direction */
/* Check the translated rectangle to feat the rules */
}
{
/* Resize window to feat desirable size
* using max of available rectangles */
{
{
maxRectangle = item;
}
}
result = aRectangle;
}
return result;
}
/**
* Returns the flipped (transposed) region.
*/
/* static */
{
return result;
}
/**
* Aligns the center of \a aWidget with the center of \a aRelative.
*
* If necessary, \a aWidget's position is adjusted to make it fully visible
* within the available desktop area. If \a aWidget is bigger then this area,
* it will also be resized unless \a aCanResize is false or there is an
* inappropriate minimum size limit (in which case the top left corner will be
* simply aligned with the top left corner of the available desktop area).
*
* \a aWidget must be a top-level widget. \a aRelative may be any widget, but
* if it's not top-level itself, its top-level widget will be used for
* calculations. \a aRelative can also be NULL, in which case \a aWidget will
* be centered relative to the available desktop area.
*/
/* static */
bool aCanResize /* = true */)
{
if (w)
{
w = w->window();
parentGeo = w->frameGeometry();
/* On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level
* widgets with parents, what a shame. Use mapToGlobal() to workaround. */
parentGeo.moveTopLeft (d);
}
else
{
}
/* On X11, there is no way to determine frame geometry (including WM
* decorations) before the widget is shown for the first time. Stupidly
* enumerate other top level widgets to find the thickest frame. The code
* is based on the idea taken from QDialog::adjustPositionInternal(). */
{
continue;
}
/// @todo (r=dmik) not sure if we really need this
#if 0
/* sanity check for decoration frames. With embedding, we
* might get extraordinary values */
{
extrah = 50;
extraw = 20;
}
#endif
/* On non-X11 platforms, the following would be enough instead of the
* above workaround: */
// QRect geo = frameGeometry();
/* ensure the widget is within the available desktop area */
#ifdef Q_WS_MAC
/* No idea why, but Qt doesn't respect if there is a unified toolbar on the
* ::move call. So manually add the height of the toolbar before setting
* the position. */
if (w)
#endif /* Q_WS_MAC */
if (aCanResize &&
}
/**
* Returns the decimal separator for the current locale.
*/
/* static */
{
}
/**
* Returns the regexp string that defines the format of the human-readable
* size representation, <tt>####[.##] B|KB|MB|GB|TB|PB</tt>.
*
* This regexp will capture 5 groups of text:
* - cap(1): integer number in case when no decimal point is present
* (if empty, it means that decimal point is present)
* - cap(2): size suffix in case when no decimal point is present (may be empty)
* - cap(3): integer number in case when decimal point is present (may be empty)
* - cap(4): fraction number (hundredth) in case when decimal point is present
* - cap(5): size suffix in case when decimal point is present (note that
* B cannot appear there)
*/
/* static */
{
QString ("^(?:(?:(\\d+)(?:\\s?(%2|%3|%4|%5|%6|%7))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(%3|%4|%5|%6|%7))))$")
.arg (decimalSep())
return regexp;
}
/**
* Parses the given size string that should be in form of
* <tt>####[.##] B|KB|MB|GB|TB|PB</tt> and returns
* the size value in bytes. Zero is returned on error.
*/
/* static */
{
if (pos != -1)
{
{
}
denom = 1;
if (denom == 1)
return intg;
return intg;
}
else
return 0;
}
/**
* Formats the given @a aSize value in bytes to a human readable string
* in form of <tt>####[.##] B|KB|MB|GB|TB|PB</tt>.
*
* The @a aMode and @a aDecimal parameters are used for rounding the resulting
* number when converting the size value to KB, MB, etc gives a fractional part:
* <ul>
* <li>When \a aMode is FormatSize_Round, the result is rounded to the
* closest number containing \a aDecimal decimal digits.
* </li>
* <li>When \a aMode is FormatSize_RoundDown, the result is rounded to the
* largest number with \a aDecimal decimal digits that is not greater than
* the result. This guarantees that converting the resulting string back to
* the integer value in bytes will not produce a value greater that the
* initial size parameter.
* </li>
* <li>When \a aMode is FormatSize_RoundUp, the result is rounded to the
* smallest number with \a aDecimal decimal digits that is not less than the
* result. This guarantees that converting the resulting string back to the
* integer value in bytes will not produce a value less that the initial
* size parameter.
* </li>
* </ul>
*
* @param aSize Size value in bytes.
* @param aMode Conversion mode.
* @param aDecimal Number of decimal digits in result.
* @return Human-readable size string.
*/
/* static */
{
int suffix = 0;
{
denom = 1;
suffix = 0;
}
{
suffix = 1;
}
{
suffix = 2;
}
{
suffix = 3;
}
{
suffix = 4;
}
else
{
suffix = 5;
}
if (denom > 1)
{
if (decm)
{
/* not greater */
if (aMode == FormatSize_RoundDown)
/* not less */
else if (aMode == FormatSize_RoundUp)
/* nearest */
}
/* check for the fractional part overflow due to rounding */
{
decm = 0;
++ intg;
/* check if we've got 1024 XB after rounding and scale down if so */
{
intg /= 1024;
++ suffix;
}
}
}
else
{
}
}
/**
* Returns the required video memory in bytes for the current desktop
* resolution at maximum possible screen depth in bpp.
*/
/* static */
{
/* We create a list of the size of all available host monitors. This list
* is sorted by value and by starting with the biggest one, we calculate
* the memory requirements for every guest screen. This is of course not
* correct, but as we can't predict on which host screens the user will
* open the guest windows, this is the best assumption we can do, cause it
* is the worst case. */
for (int i = 0; i < pDW->numScreens(); ++i)
{
}
/* Now sort the vector */
/* For the case that there are more guest screens configured then host
* screens available, replace all zeros with the greatest value in the
* vector. */
for (int i = 0; i < screenSize.size(); ++i)
if (screenSize.at(i) == 0)
for (int i = 0; i < cMonitors; ++i)
{
/* Calculate summary required memory amount in bits */
32 + /* we will take the maximum possible bpp for now */
8 * 4096; /* adapter info */
}
/* Translate value into megabytes with rounding to highest side */
{
/* Windows guests need offscreen VRAM too for graphics acceleration features: */
#ifdef VBOX_WITH_CRHGSMI
{
/* wddm mode, there are two surfaces for each screen: shadow & primary */
needMBytes *= 3;
}
else
#endif /* VBOX_WITH_CRHGSMI */
{
needMBytes *= 2;
}
}
return needMBytes * _1M;
}
/**
* Puts soft hyphens after every path component in the given file name.
*
* @param aFileName File name (must be a full path name).
*/
/* static */
{
/// @todo (dmik) remove?
// QString result = QDir::toNativeSeparators (fn);
//#ifdef Q_OS_LINUX
// result.replace ('/', "/<font color=red>­</font>");
//#else
// result.replace ('\\', "\\<font color=red>­</font>");
//#endif
// return result;
}
/**
* Reformats the input string @a aStr so that:
* - strings in single quotes will be put inside <nobr> and marked
* with blue color;
* - UUIDs be put inside <nobr> and marked
* with green color;
* - replaces new line chars with </p><p> constructs to form paragraphs
* (note that <p> and </p> are not appended to the beginning and to the
* end of the string respectively, to allow the result be appended
* or prepended to the existing paragraph).
*
* If @a aToolTip is true, colouring is not applied, only the <nobr> tag
* is added. Also, new line chars are replaced with <br> instead of <p>.
*/
/* static */
{
if (!aToolTip)
{
strFont = "<font color=#0000CC>";
uuidFont = "<font color=#008000>";
endFont = "</font>";
}
/* replace special entities, '&' -- first! */
/* mark strings in single quotes with color */
rx.setMinimal (true);
/* mark UUIDs with color */
"((?:^|\\s)[(]?)"
"(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})"
"(?=[:.-!);]?(?:\\s|$))"),
/* split to paragraphs at \n chars */
if (!aToolTip)
else
return text;
}
/* static */
{
return strText
}
/**
* Reformats the input string @a aStr so that:
* - strings in single quotes will be put inside <nobr> and marked
* with bold style;
* - UUIDs be put inside <nobr> and marked
* with italic style;
* - replaces new line chars with </p><p> constructs to form paragraphs
* (note that <p> and </p> are not appended to the beginning and to the
* end of the string respectively, to allow the result be appended
* or prepended to the existing paragraph).
*/
/* static */
{
/* replace special entities, '&' -- first! */
/* mark strings in single quotes with bold style */
rx.setMinimal (true);
/* mark UUIDs with italic style */
"((?:^|\\s)[(]?)"
"(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})"
"(?=[:.-!);]?(?:\\s|$))"),
/* split to paragraphs at \n chars */
return text;
}
/**
* This does exactly the same as QLocale::system().name() but corrects its
* wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes
* precedence over any other locale setting in the QLocale::system()
* implementation). This implementation first looks at LC_ALL (as defined by
* SUS), then looks at LC_MESSAGES which is designed to define a language for
* program messages in case if it differs from the language for other locale
* categories. Then it looks for LANG and finally falls back to
* QLocale::system().name().
*
* The order of precedence is well defined here:
*
* @note This method will return "C" when the requested locale is invalid or
* when the "C" locale is set explicitly.
*/
/* static */
{
#if defined (Q_WS_MAC)
/* QLocale return the right id only if the user select the format of the
* language also. So we use our own implementation */
return ::darwinSystemLanguage();
const char *s = RTEnvGet ("LC_ALL");
if (s == 0)
s = RTEnvGet ("LC_MESSAGES");
if (s == 0)
s = RTEnvGet ("LANG");
if (s != 0)
#endif
}
#if defined (Q_WS_X11)
{
True /* only_if_exists */);
if (propNameAtom == None)
return NULL;
int actFmt = 0;
unsigned long nItems = 0;
unsigned long nBytesAfter = 0;
return NULL;
return reinterpret_cast <char *> (propVal);
}
unsigned long aData4 = 0)
{
return False;
/* always send as 32 bit for now */
SubstructureRedirectMask, &ev) != 0;
}
#endif
/**
* Activates the specified window. If necessary, the window will be
* de-iconified activation.
*
* @note On X11, it is implied that @a aWid represents a window of the same
* display the application was started on.
*
* @param aWId Window ID to activate.
* @param aSwitchDesktop @c true to switch to the window's desktop before
* activation.
*
* @return @c true on success and @c false otherwise.
*/
/* static */
{
bool result = true;
#if defined (Q_WS_WIN32)
else if (!IsWindowVisible (aWId))
if (aSwitchDesktop)
{
/* try to find the desktop ID using the NetWM property */
"_NET_WM_DESKTOP");
/* if the NetWM properly is not supported try to find the desktop
* ID using the GNOME WM property */
"_WIN_WORKSPACE");
{
"_NET_CURRENT_DESKTOP",
*desktop);
if (!ok)
{
LogWarningFunc (("Couldn't switch to desktop=%08X\n",
desktop));
result = false;
}
}
else
{
LogWarningFunc (("Couldn't find a desktop ID for aWId=%08X\n",
aWId));
result = false;
}
}
#else
AssertFailed();
result = false;
#endif
if (!result)
return result;
}
/**
* Removes the accelerator mark (the ampersand symbol) from the given string
* and returns the result. The string is supposed to be a menu item's text
* that may (or may not) contain the accelerator mark.
*
* In order to support accelerators used in non-alphabet languages
* (e.g. Japanese) that has a form of "(&<L>)" (where <L> is a latin letter),
* this method first searches for this pattern and, if found, removes it as a
* whole. If such a pattern is not found, then the '&' character is simply
* removed from the string.
*
* @note This function removes only the first occurrence of the accelerator
* mark.
*
* @param aText Menu item's text to remove the accelerator mark from.
*
* @return The resulting string.
*/
/* static */
{
if (pos >= 0)
else
{
if (pos >= 0)
}
return result;
}
/* static */
{
#ifdef Q_WS_MAC
#else
#endif
return strText;
else
}
/* static */
{
#ifdef Q_WS_MAC
#else
#endif
return key;
}
/**
* Joins two pixmaps horizontally with 2px space between them and returns the
* result.
*
* @param aPM1 Left pixmap.
* @param aPM2 Right pixmap.
*/
/* static */
{
return aPM2;
return aPM1;
return result;
}
/**
* Searches for a widget that with @a aName (if it is not NULL) which inherits
* @a aClassName (if it is not NULL) and among children of @a aParent. If @a
* aParent is NULL, all top-level widgets are searched. If @a aRecursive is
* true, child widgets are recursively searched as well.
*/
/* static */
const char *aClassName /* = NULL */,
bool aRecursive /* = false */)
{
{
{
return w;
if (aRecursive)
{
if (w)
return w;
}
}
return NULL;
}
/* Find the first children of aParent with the appropriate properties.
* Please note that this call is recursively. */
{
return child;
}
return NULL;
}
/**
* Figures out which medium formats are currently supported by VirtualBox for
* the given device type.
* Returned is a list of pairs with the form
* <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
*/
/* static */
{
for (int i = 0; i < mediumFormats.size(); ++ i)
{
/* File extensions */
QStringList f;
for (int a = 0; a < fileExtensions.size(); ++ a)
if (deviceTypes [a] == enmType)
/* Create a pair out of the backend description and all suffix's. */
if (!f.isEmpty())
}
return backendPropList;
}
/**
* Figures out which hard disk formats are currently supported by VirtualBox.
* Returned is a list of pairs with the form
* <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
*/
/* static */
{
return MediumBackends(KDeviceType_HardDisk);
}
/**
* Returned is a list of pairs with the form
* <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
*/
/* static */
{
return MediumBackends(KDeviceType_DVD);
}
/**
* Figures out which floppy disk formats are currently supported by VirtualBox.
* Returned is a list of pairs with the form
* <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
*/
/* static */
{
return MediumBackends(KDeviceType_Floppy);
}
/* static */
{
else
{
else
}
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* static */
{
return VBoxQGLOverlay::isAcceleration2DVideoAvailable();
}
/** additional video memory required for the best 2D support performance
* total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
/* static */
{
return VBoxQGLOverlay::required2DOffscreenVideoMemory();
}
#endif
#ifdef VBOX_WITH_CRHGSMI
/* static */
quint64 VBoxGlobal::required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
{
return cbSize;
}
/* static */
{
}
#endif /* VBOX_WITH_CRHGSMI */
/* static */
{
if (strBaseMediumFormatName == "VDI")
return tr("VDI (VirtualBox Disk Image)");
else if (strBaseMediumFormatName == "VMDK")
return tr("VMDK (Virtual Machine Disk)");
else if (strBaseMediumFormatName == "VHD")
return tr("VHD (Virtual Hard Disk)");
else if (strBaseMediumFormatName == "Parallels")
return tr("HDD (Parallels Hard Disk)");
else if (strBaseMediumFormatName == "QED")
return tr("QED (QEMU enhanced disk)");
else if (strBaseMediumFormatName == "QCOW")
return tr("QCOW (QEMU Copy-On-Write)");
return strBaseMediumFormatName;
}
/* static */
{
/* Load corresponding extra-data value: */
/* 'false' if value was not set: */
if (strExtraDataValue.isEmpty())
return false;
/* Handle particular values: */
|| strExtraDataValue == "1";
}
/* static */
{
/* Load corresponding extra-data value: */
/* 'false' if value was not set: */
if (strExtraDataValue.isEmpty())
return false;
/* Handle particular values: */
|| strExtraDataValue == "1";
}
/* static */
{
/* 'true' if disabling is not approved by the extra-data: */
}
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
/* static */
{
/* 'false' for null machines: */
return false;
/* 'true' for inaccessible machines,
* because we can't verify anything in that case: */
if (!machine.GetAccessible())
return true;
/* 'true' if hiding is not approved by the extra-data: */
}
/* static */
bool fIncludingMachineGeneralCheck /* = false*/,
bool fIncludingMachineStateCheck /* = false*/)
{
/* Should we perform machine general check? */
{
/* 'false' for null machines: */
return false;
/* 'false' for inaccessible machines,
* because we can't configure anything in that case: */
if (!machine.GetAccessible())
return true;
}
/* Should we perform machine state check? */
{
/* 'false' for machines in [stuck] state: */
return false;
}
/* 'true' if reconfiguration is not restricted by the extra-data: */
}
/* static */
bool fIncludingMachineGeneralCheck /* = false*/)
{
/* Should we perform machine general check? */
{
/* 'false' for null machines: */
return false;
/* 'true' for inaccessible machines,
* because we can't verify anything in that case: */
if (!machine.GetAccessible())
return true;
}
/* 'true' if hiding is not approved by the extra-data: */
}
/* static */
bool fIncludingSanityCheck /* = true*/)
{
{
/* 'false' for null machines,
* there is nothing to start anyway: */
return false;
/* 'false' for inaccessible machines,
* we can't start them anyway: */
if (!machine.GetAccessible())
return false;
}
/* 'true' if guest-screen auto-mounting approved by the extra-data: */
}
/* static */
bool fIncludingSanityCheck /* = true*/)
{
{
/* 'false' for null machines,
* we can't operate snapshot in that case: */
return false;
/* 'false' for inaccessible machines,
* we can't operate snapshot in that case: */
if (!machine.GetAccessible())
return false;
}
/* 'true' if snapshot operations are not restricted by the extra-data: */
}
/** Returns default machine close action for passed @a machine. */
{
return gpConverter->fromInternalString<MachineCloseAction>(machine.GetExtraData(GUI_DefaultCloseAction));
}
/* static */
{
/* Prepare result: */
/* Load restricted runtime-menu-types: */
/* Convert list into appropriate values: */
{
if (value != RuntimeMenuType_Invalid)
}
/* Return result: */
return result;
}
#ifdef Q_WS_MAC
/* static */
RuntimeMenuApplicationActionType VBoxGlobal::restrictedRuntimeMenuApplicationActionTypes(CMachine &machine)
{
/* Prepare result: */
/* Load restricted runtime-application-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuApplicationActionType value = gpConverter->fromInternalString<RuntimeMenuApplicationActionType>(strValue);
}
/* Return result: */
return result;
}
#endif /* Q_WS_MAC */
/* static */
{
/* Prepare result: */
/* Load restricted runtime-machine-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuMachineActionType value = gpConverter->fromInternalString<RuntimeMenuMachineActionType>(strValue);
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted runtime-view-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuViewActionType value = gpConverter->fromInternalString<RuntimeMenuViewActionType>(strValue);
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted runtime-devices-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuDevicesActionType value = gpConverter->fromInternalString<RuntimeMenuDevicesActionType>(strValue);
}
/* Return result: */
return result;
}
#ifdef VBOX_WITH_DEBUGGER_GUI
/* static */
RuntimeMenuDebuggerActionType VBoxGlobal::restrictedRuntimeMenuDebuggerActionTypes(CMachine &machine)
{
/* Prepare result: */
/* Load restricted runtime-debugger-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuDebuggerActionType value = gpConverter->fromInternalString<RuntimeMenuDebuggerActionType>(strValue);
}
/* Return result: */
return result;
}
#endif /* VBOX_WITH_DEBUGGER_GUI */
/* static */
{
/* Prepare result: */
/* Load restricted runtime-help-menu action-types: */
/* Convert list into appropriate values: */
{
RuntimeMenuHelpActionType value = gpConverter->fromInternalString<RuntimeMenuHelpActionType>(strValue);
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted visual-state-types: */
/* Convert list into appropriate values: */
{
if (value != UIVisualStateType_Invalid)
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted status-bar-indicators: */
/* Convert list into appropriate values: */
{
if (value != IndicatorType_Invalid)
}
/* Return result: */
return result;
}
/** Returns merged restricted machine close actions for passed @a machine. */
{
/* Prepare result: */
/* Load restricted machine-close-actions: */
/* Convert list into appropriate values: */
{
if (value != MachineCloseAction_Invalid)
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted global-settings-pages: */
/* Convert list into appropriate values: */
{
if (value != GlobalSettingsPageType_Invalid)
}
/* Return result: */
return result;
}
/* static */
{
/* Prepare result: */
/* Load restricted machine-settings-pages: */
/* Convert list into appropriate values: */
{
if (value != MachineSettingsPageType_Invalid)
}
/* Return result: */
return result;
}
#ifdef RT_OS_LINUX
/* static */
void VBoxGlobal::checkForWrongUSBMounted()
{
return;
/* Fetch contents: */
for (;;)
{
break;
}
/* Grep contents for usbfs presence: */
return;
/* Show corresponding warning: */
}
#endif /* RT_OS_LINUX */
/* static */
{
/* Load options: */
/* Acquire edit-field rectangle: */
&option,
pSpinBox);
/* Calculate minimum-width magic: */
/* Tune spin-box minimum-width: */
}
// Public slots
////////////////////////////////////////////////////////////////////////////////
/**
*
* @param aURL URL to open
*
* @return true on success and false otherwise
*/
{
/* Service event */
class ServiceEvent : public QEvent
{
public:
private:
bool mResult;
};
/* Service-Client object */
class ServiceClient : public QEventLoop
{
public:
ServiceClient() : mResult (false) {}
private:
{
{
quit();
return true;
}
return false;
}
bool mResult;
};
/* Service-Server object */
class ServiceServer : public QThread
{
public:
private:
void run()
{
}
};
if (!result)
return result;
}
{
/* Make sure medium-enumeration is not in progress! */
/* Load passed language: */
}
{
/* Reload proxy settings: */
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
}
// Protected members
////////////////////////////////////////////////////////////////////////////////
{
aObject->isWidgetType() &&
{
/* Catch the language change event before any other widget gets it in
* order to invalidate cached string resources (like the details view
* templates) that may be used by other widgets. */
{
/* call this only once per every language change (see
* QApplication::installTranslator() for details) */
}
}
}
#ifdef VBOX_WITH_DEBUGGER_GUI
{
}
{
}
{
}
{
}
#endif /* VBOX_WITH_DEBUGGER_GUI */
// Private members
////////////////////////////////////////////////////////////////////////////////
bool VBoxGlobal::processArgs()
{
bool fResult = false;
{
/* We break out after the first parameter, cause there could be
parameters with arguments (e.g. --comment comment). */
break;
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
}
{
{
{
{
fResult = true;
/* Remove from the arg list. */
}
}
}
}
{
m_ArgUrlList = list;
}
return fResult;
}
void VBoxGlobal::prepare()
{
/* Make sure QApplication cleanup us on exit: */
/* Create message-center: */
/* Create popup-center: */
UIPopupCenter::create();
/* Load translation based on the current locale: */
loadLanguage();
#ifdef DEBUG
mVerString += " [DEBUG]";
#endif
{
#ifdef VBOX_WITH_XPCOM
if (rc == NS_ERROR_FILE_ACCESS_DENIED)
{
}
else
#endif
return;
}
{
return;
}
/* create default non-null global settings */
gset = VBoxGlobalSettings (false);
/* try to load global settings */
{
return;
}
/* Load translation based on the user settings: */
if (!sLanguageId.isNull())
/* Initialize guest OS Type list. */
if (osTypeCount > 0)
{
/* Here we ASSUME the 'Other' types are always the first, so we
* remember it and will append it to the list when finished.
* We do a two pass, first adding the specific types, then the two
* 'Other' types. */
for (int j = 0; j < 2; j++)
{
for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
{
{
mFamilyIDs << familyId;
}
}
}
}
/* Fill in OS type icon dictionary. */
static const char * const s_kOSTypeIcons[][2] =
{
{"Other", ":/os_other.png"},
{"Other_64", ":/os_other_64.png"},
{"DOS", ":/os_dos.png"},
{"Netware", ":/os_netware.png"},
{"L4", ":/os_l4.png"},
{"Windows31", ":/os_win31.png"},
{"Windows95", ":/os_win95.png"},
{"Windows98", ":/os_win98.png"},
{"WindowsMe", ":/os_winme.png"},
{"WindowsNT4", ":/os_winnt4.png"},
{"Windows2000", ":/os_win2k.png"},
{"WindowsXP", ":/os_winxp.png"},
{"WindowsXP_64", ":/os_winxp_64.png"},
{"Windows2003", ":/os_win2k3.png"},
{"Windows2003_64", ":/os_win2k3_64.png"},
{"WindowsVista", ":/os_winvista.png"},
{"WindowsVista_64", ":/os_winvista_64.png"},
{"Windows2008", ":/os_win2k8.png"},
{"Windows2008_64", ":/os_win2k8_64.png"},
{"Windows7", ":/os_win7.png"},
{"Windows7_64", ":/os_win7_64.png"},
{"Windows8", ":/os_win8.png"},
{"Windows8_64", ":/os_win8_64.png"},
{"Windows81", ":/os_win8.png"},
{"Windows81_64", ":/os_win8_64.png"},
{"Windows2012_64", ":/os_win2k12_64.png"},
{"WindowsNT", ":/os_win_other.png"},
{"WindowsNT_64", ":/os_win_other.png"}, /// @todo os_win_other_64.png
{"OS2Warp3", ":/os_os2warp3.png"},
{"OS2Warp4", ":/os_os2warp4.png"},
{"OS2Warp45", ":/os_os2warp45.png"},
{"OS2eCS", ":/os_os2ecs.png"},
{"OS21x", ":/os_os2_other.png"},
{"OS2", ":/os_os2_other.png"},
{"Linux22", ":/os_linux22.png"},
{"Linux24", ":/os_linux24.png"},
{"Linux24_64", ":/os_linux24_64.png"},
{"Linux26", ":/os_linux26.png"},
{"Linux26_64", ":/os_linux26_64.png"},
{"ArchLinux", ":/os_archlinux.png"},
{"ArchLinux_64", ":/os_archlinux_64.png"},
{"Debian", ":/os_debian.png"},
{"Debian_64", ":/os_debian_64.png"},
{"OpenSUSE", ":/os_opensuse.png"},
{"OpenSUSE_64", ":/os_opensuse_64.png"},
{"Fedora", ":/os_fedora.png"},
{"Fedora_64", ":/os_fedora_64.png"},
{"Gentoo", ":/os_gentoo.png"},
{"Gentoo_64", ":/os_gentoo_64.png"},
{"Mandriva", ":/os_mandriva.png"},
{"Mandriva_64", ":/os_mandriva_64.png"},
{"RedHat", ":/os_redhat.png"},
{"RedHat_64", ":/os_redhat_64.png"},
{"Turbolinux", ":/os_turbolinux.png"},
{"Turbolinux_64", ":/os_turbolinux_64.png"},
{"Ubuntu", ":/os_ubuntu.png"},
{"Ubuntu_64", ":/os_ubuntu_64.png"},
{"Xandros", ":/os_xandros.png"},
{"Xandros_64", ":/os_xandros_64.png"},
{"Oracle", ":/os_oracle.png"},
{"Oracle_64", ":/os_oracle_64.png"},
{"Linux", ":/os_linux_other.png"},
{"Linux_64", ":/os_linux_other.png"}, /// @todo os_linux_other_64.png
{"FreeBSD", ":/os_freebsd.png"},
{"FreeBSD_64", ":/os_freebsd_64.png"},
{"OpenBSD", ":/os_openbsd.png"},
{"OpenBSD_64", ":/os_openbsd_64.png"},
{"NetBSD", ":/os_netbsd.png"},
{"NetBSD_64", ":/os_netbsd_64.png"},
{"Solaris", ":/os_solaris.png"},
{"Solaris_64", ":/os_solaris_64.png"},
{"OpenSolaris", ":/os_oraclesolaris.png"},
{"OpenSolaris_64", ":/os_oraclesolaris_64.png"},
{"Solaris11_64", ":/os_oraclesolaris_64.png"},
{"QNX", ":/os_qnx.png"},
{"MacOS", ":/os_macosx.png"},
{"MacOS_64", ":/os_macosx_64.png"},
{"MacOS106", ":/os_macosx.png"},
{"MacOS106_64", ":/os_macosx_64.png"},
{"MacOS107_64", ":/os_macosx_64.png"},
{"MacOS108_64", ":/os_macosx_64.png"},
{"MacOS109_64", ":/os_macosx_64.png"},
{"JRockitVE", ":/os_jrockitve.png"},
};
{
}
qApp->installEventFilter (this);
/* process command line */
bool bForceSeamless = false;
bool bForceFullscreen = false;
#ifdef Q_WS_X11
#endif
#ifdef VBOX_WITH_DEBUGGER_GUI
# ifdef VBOX_WITH_DEBUGGER_GUI_MENU
# else
# endif
mStartPaused = false;
#endif
mShowStartVMErrors = true;
bool startVM = false;
int i = 1;
while (i < argc)
{
/* NOTE: the check here must match the corresponding check for the
* options to start a VM in main.cpp and hardenedmain.cpp exactly,
* otherwise there will be weird error messages. */
{
if (++i < argc)
{
startVM = true;
}
}
#ifdef VBOX_GUI_WITH_PIDFILE
{
if (++i < argc)
}
#endif /* VBOX_GUI_WITH_PIDFILE */
{
bForceSeamless = true;
}
{
bForceFullscreen = true;
}
{
++i;
}
{
if (++i < argc)
}
{
if (++i < argc)
{
mSettingsPwSet = true;
}
}
{
if (++i < argc)
{
int vrc = VINF_SUCCESS;
if (!fStdIn)
else
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
continue;
else
{
unsigned i;
;
mSettingsPw[i] = '\0';
mSettingsPwSet = true;
}
}
if (!fStdIn)
}
}
}
mShowStartVMErrors = false;
mAgressiveCaching = true;
mAgressiveCaching = false;
mRestoreCurrentSnapshot = true;
mDisablePatm = true;
mDisableCsam = true;
mRecompileSupervisor = true;
mRecompileUser = true;
{
if (++i < argc)
}
#ifdef VBOX_WITH_DEBUGGER_GUI
setDebuggerVar(&mDbgEnabled, true);
{
setDebuggerVar(&mDbgEnabled, true);
setDebuggerVar(&mDbgAutoShow, true);
setDebuggerVar(&mDbgAutoShowCommandLine, true);
setDebuggerVar(&mDbgAutoShowStatistics, true);
mStartPaused = true;
}
{
setDebuggerVar(&mDbgEnabled, true);
setDebuggerVar(&mDbgAutoShow, true);
setDebuggerVar(&mDbgAutoShowCommandLine, true);
mStartPaused = true;
}
{
setDebuggerVar(&mDbgEnabled, true);
setDebuggerVar(&mDbgAutoShow, true);
setDebuggerVar(&mDbgAutoShowStatistics, true);
mStartPaused = true;
}
{
setDebuggerVar(&mDbgEnabled, false);
setDebuggerVar(&mDbgAutoShow, false);
setDebuggerVar(&mDbgAutoShowCommandLine, false);
setDebuggerVar(&mDbgAutoShowStatistics, false);
}
/* Not quite debug options, but they're only useful with the debugger bits. */
mStartPaused = true;
mStartPaused = false;
#endif
/** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */
i++;
}
if (startVM)
{
{
}
else
{
if (m.isNull())
{
if (showStartVMErrors())
return;
}
}
}
/* After initializing *vmUuid* we already know if that is VM process or not: */
if (!isVMConsoleProcess())
{
/* We should create separate logging file for VM selector: */
char szLogFile[RTPATH_MAX];
const char *pszLogFile = NULL;
/* Create release logger, to file: */
"all",
"VBOX_GUI_SELECTORWINDOW_RELEASE_LOG",
1,
60 * 60,
_1M,
sizeof(szError));
}
if (mSettingsPwSet)
{
}
{
}
#ifdef VBOX_WITH_DEBUGGER_GUI
/* setup the debugger gui. */
if (RTEnvExist("VBOX_GUI_NO_DEBUGGER"))
if (mDbgEnabled)
{
if (RT_FAILURE(vrc))
{
}
}
#endif
mValid = true;
UIConverter::prepare();
/* Cache IMedium data.
* There could be no used mediums at all,
* but this method should be run anyway just to enumerate null UIMedium object,
* used by some VBox smart widgets, like VBoxMediaComboBox: */
{
/* Prepare medium-enumerator: */
this, SIGNAL(sigMediumEnumerationStarted()));
this, SIGNAL(sigMediumEnumerationFinished()));
}
if (agressiveCaching())
/* Prepare global settings change handler: */
this, SLOT(sltProcessGlobalSettingChange()));
/* Handle global settings change for the first time: */
/* Create shortcut pool: */
UIShortcutPool::create();
/* Create action pool: */
if (isVMConsoleProcess())
{
}
else
{
}
/* Create network manager: */
/* Schedule update manager: */
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
}
void VBoxGlobal::cleanup()
{
/* Preventing some unwanted stuff
* which could de called from the other threads: */
m_sfCleanupInProgress = true;
/* Shutdown update manager: */
/* Destroy network manager: */
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
/* Destroy action pool: */
UIActionPool::destroy();
/* Destroy shortcut pool: */
#ifdef VBOX_GUI_WITH_PIDFILE
#endif
/* Destroy our event handlers */
/* Destroy the GUI root windows _BEFORE_ the media-mess, because there is
code in the GUI that's using the media code an will be racing us! */
if (mSelectorWnd)
{
delete mSelectorWnd;
mSelectorWnd = NULL;
}
if (m_pVirtualMachine)
{
delete m_pVirtualMachine;
}
/* Cleanup medium-enumerator: */
delete m_pMediumEnumerator;
m_pMediumEnumerator = 0;
/* Destroy whatever this converter stuff is: */
UIConverter::cleanup();
/* Ensure mOsTypeIcons is cleaned up: */
/* ensure CGuestOSType objects are no longer used */
mFamilyIDs.clear();
/* the last steps to ensure we don't use COM any more */
/* There may be UIMedium(s)EnumeratedEvent instances still in the message
* queue which reference COM objects. Remove them to release those objects
* before uninitializing the COM subsystem. */
QApplication::removePostedEvents (this);
COMBase::CleanupCOM();
/* Destroy popup-center: */
UIPopupCenter::destroy();
/* Destroy message-center: */
mValid = false;
}
#ifdef VBOX_WITH_DEBUGGER_GUI
# define VBOXGLOBAL_DBG_CFG_VAR_FALSE (0)
# define VBOXGLOBAL_DBG_CFG_VAR_TRUE (1)
# define VBOXGLOBAL_DBG_CFG_VAR_MASK (1)
/**
* Initialize a debugger config variable.
*
* @param piDbgCfgVar The debugger config variable to init.
* @param pszEnvVar The environment variable name relating to this
* variable.
* @param pszExtraDataName The extra data name relating to this variable.
* @param fDefault The default value.
*/
void VBoxGlobal::initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault)
{
char szEnvValue[256];
if (RT_SUCCESS(rc))
{
if (strEnvValue.isEmpty())
strEnvValue = "yes";
}
else if (rc != VERR_ENV_VAR_NOT_FOUND)
strEnvValue = "veto";
if (strExtraValue.isEmpty())
strExtraValue = QString();
else
{
|| pStr->toLongLong() != 0)
|| pStr->toLongLong() == 0)
else
{
LogFunc(("Ignoring unknown value '%s' for '%s'\n", pStr->toAscii().constData(), pStr == &strEnvValue ? pszEnvVar : pszExtraDataName));
}
}
}
/**
* Set a debugger config variable according according to start up argument.
*
* @param piDbgCfgVar The debugger config variable to set.
* @param fState The value from the command line.
*/
{
if (!(*piDbgCfgVar & VBOXGLOBAL_DBG_CFG_VAR_DONE))
}
/**
* Checks the state of a debugger config variable, updating it with the machine
* settings on the first invocation.
*
* @returns true / false.
* @param piDbgCfgVar The debugger config variable to consult.
* @param rMachine Reference to the machine object.
* @param pszExtraDataName The extra data name relating to this variable.
*/
bool VBoxGlobal::isDebuggerWorker(int *piDbgCfgVar, CMachine &rMachine, const char *pszExtraDataName)
{
{
|| str.toLongLong() != 0)
|| str.toLongLong() == 0)
else
}
}
#endif /* VBOX_WITH_DEBUGGER_GUI */
/** @fn vboxGlobal
*
* Shortcut to the static VBoxGlobal::instance() method, for convenience.
*/
{
#ifdef Q_WS_MAC
#else
#endif
return false;
/* winId = 0 it means the console window has already done everything
* necessary to implement the "show window" semantics. */
if (id == 0)
return true;
#if defined (Q_WS_WIN32) || defined (Q_WS_X11)
/*
* This is just for the case were the other process cannot steal
* the focus from us. It will send us a PSN so we can try.
*/
if (!rc)
Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
else
return !rc;
#endif
return false;
/// @todo Below is the old method of switching to the console window
// based on the process ID of the console process. It should go away
// after the new (callback-based) method is fully tested.
#if 0
if (!canSwitchTo())
return false;
#if defined (Q_WS_WIN32)
/* if there are blockers (modal and modeless dialogs, etc), find the
* topmost one */
do
{
else
break;
}
while (1);
/* first, check that the primary window is visible */
else if (!IsWindowVisible(mWinId))
#if 0
#endif
/* then, activate the topmost in the group */
return true;
return false;
if (!rc)
{
if (!rc)
{
ShowHideProcess(&psn, true);
return true;
}
}
return false;
#else
return false;
#endif
#endif
}
{
/* Switch to machine window(s) if possible: */
if (machine.CanShowConsoleWindow())
/* Make sure machine-state is one of required: */
|| state == KMachineState_Saved
|| state == KMachineState_Aborted
, ("Machine must be PoweredOff/Saved/Teleported/Aborted (%d)", state));
/* Create empty session instance: */
{
return false;
}
/* Configure environment: */
#ifdef Q_OS_WIN
/* Allow started VM process to be foreground window: */
#endif /* Q_OS_WIN */
#ifdef Q_WS_X11
/* Make sure VM process will start on the same display as the VM selector: */
if (pDisplay)
if (pXauth)
#endif /* Q_WS_X11 */
/* Prepare "VM spawning" progress: */
{
return false;
}
/* Postpone showing "VM spawning" progress.
* Hope 1 minute will be enough to spawn any running VM silently,
* otherwise we better show the progress... */
int iSpawningDuration = 60000;
":/progress_start_90px.png", 0, iSpawningDuration);
/* Unlock machine, close session: */
/* True finally: */
return true;
}