VBoxGlobal.cpp revision 2a25e39118ba0feec97b3ffedf599e0a61926cf8
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxGlobal class implementation
*/
/*
* Copyright (C) 2006-2010 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "VBoxGlobal.h"
#include "VBoxDefs.h"
#include "VBoxSelectorWnd.h"
#include "VBoxConsoleWnd.h"
#include "VBoxProblemReporter.h"
#include "QIHotKeyEdit.h"
#include "QIMessageBox.h"
#include "QIDialogButtonBox.h"
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
# include "UIMachine.h"
# include "UISession.h"
#endif
#ifdef VBOX_WITH_REGISTRATION
# include "UIRegistrationWzd.h"
#endif
#include "VBoxUpdateDlg.h"
#ifdef VBOX_WITH_VIDEOHWACCEL
#include "VBoxFrameBuffer.h"
#endif
/* Qt includes */
#include <QProgressDialog>
#include <QLibraryInfo>
#include <QFileDialog>
#include <QToolTip>
#include <QTranslator>
#include <QDesktopWidget>
#include <QDesktopServices>
#include <QMutex>
#include <QToolButton>
#include <QProcess>
#include <QThread>
#include <QPainter>
#include <QSettings>
#include <QTimer>
#include <QDir>
#include <QHelpEvent>
#include <QLocale>
#include <math.h>
#ifdef Q_WS_X11
# ifndef VBOX_OSE
# include "VBoxLicenseViewer.h"
# endif /* VBOX_OSE */
# include <QTextBrowser>
# include <QScrollBar>
# include <QX11Info>
# include "VBoxX11Helper.h"
#endif
#ifdef Q_WS_MAC
# include "VBoxUtils-darwin.h"
#endif /* Q_WS_MAC */
#if defined (Q_WS_WIN)
#include "shlobj.h"
#include <QEventLoop>
#endif
#if defined (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
#ifdef VBOX_GUI_WITH_SYSTRAY
#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
#define HOSTSUFF_EXE ".exe"
#else /* !RT_OS_WINDOWS */
#define HOSTSUFF_EXE ""
#endif /* !RT_OS_WINDOWS */
#endif
#if defined (Q_WS_X11)
#endif
//#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
// VBoxMediaEnumEvent
/////////////////////////////////////////////////////////////////////////////
class VBoxMediaEnumEvent : public QEvent
{
public:
/** Constructs a regular enum event */
{}
/** Constructs the last enum event */
{}
/** Last enumerated medium (not valid when #last is true) */
const VBoxMedium mMedium;
/** Opaque iterator provided by the event sender (guaranteed to be
* the same variable for all media in the single enumeration procedure) */
/** Whether this is the last event for the given enumeration or not */
const bool mLast;
};
// VirtualBox callback class
/////////////////////////////////////////////////////////////////////////////
{
public:
, mIsRegDlgOwner (false)
, mIsUpdDlgOwner (false)
#ifdef VBOX_GUI_WITH_SYSTRAY
, mIsTrayIconOwner (false)
#endif
{
#if defined (Q_OS_WIN32)
refcnt = 0;
#endif
}
virtual ~VBoxCallback() {}
#if defined (Q_OS_WIN32)
{
return ::InterlockedIncrement (&refcnt);
}
{
if (cnt == 0)
delete this;
return cnt;
}
#endif
// IVirtualBoxCallback methods
// Note: we need to post custom events to the GUI event queue
// instead of doing what we need directly from here because on Win32
// these callback methods are never called on the main GUI thread.
// Another reason to handle events asynchronously is that internally
// most callback interface methods are called from under the initiator
// object's lock, so accessing the initiator object (for example, reading
// some property) directly from the callback method will definitely cause
// a deadlock.
{
(KMachineState) state));
return S_OK;
}
{
return S_OK;
}
{
if (!error || !allowChange)
return E_INVALIDARG;
{
/* it's a global extra data key someone wants to change */
{
{
if (mIsRegDlgOwner)
{
*allowChange = TRUE;
else
*allowChange = FALSE;
}
else
*allowChange = TRUE;
return S_OK;
}
{
if (mIsUpdDlgOwner)
{
*allowChange = TRUE;
else
*allowChange = FALSE;
}
else
*allowChange = TRUE;
return S_OK;
}
#ifdef VBOX_GUI_WITH_SYSTRAY
{
if (mIsTrayIconOwner)
{
*allowChange = TRUE;
else
*allowChange = FALSE;
}
else
*allowChange = TRUE;
return S_OK;
}
#endif
/* try to set the global setting to check its syntax */
{
/* this is a known GUI property key */
if (!gs)
{
/* disallow the change when there is an error*/
*allowChange = FALSE;
}
else
*allowChange = TRUE;
return S_OK;
}
}
}
/* not interested in this key -- never disagree */
*allowChange = TRUE;
return S_OK;
}
{
{
{
{
{
mIsRegDlgOwner = false;
}
{
mIsRegDlgOwner = true;
}
else
}
{
{
mIsUpdDlgOwner = false;
}
{
mIsUpdDlgOwner = true;
}
else
}
if (sKey == "GUI/LanguageID")
#ifdef VBOX_GUI_WITH_SYSTRAY
if (sKey == "GUI/MainWindowCount")
{
{
mIsTrayIconOwner = false;
}
{
mIsTrayIconOwner = true;
}
else
}
QApplication::postEvent (&mGlobal, new VBoxChangeTrayIconEvent ((sVal.toLower() == "true") ? true : false));
#endif
#ifdef Q_WS_MAC
{
/* Default to true if it is an empty value */
}
#endif
}
}
#ifdef Q_WS_MAC
else if (mGlobal.isVMConsoleProcess())
{
/* Check for the currently running machine */
{
// TODO_NEW_CORE: we should cleanup
// VBoxChangeDockIconUpdateEvent to have no parameters. So it
// could really be use for both events and the consumer should
// ask per GetExtraData how the current values are.
{
/* Default to true if it is an empty value */
}
}
}
#endif /* Q_WS_MAC */
return S_OK;
}
{
/** @todo */
return S_OK;
}
{
registered));
return S_OK;
}
{
(KSessionState) state));
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
IN_BSTR /* key */,
IN_BSTR /* value */,
IN_BSTR /* flags */)
{
return S_OK;
}
private:
{
// currently, we don't post events if we are in the VM execution
// console mode, to save some CPU ticks (so far, there was no need
// to handle VirtualBox callback events in the execution console mode)
if (!mGlobal.isVMConsoleProcess())
}
/** protects #OnExtraDataChange() */
bool mIsRegDlgOwner;
bool mIsUpdDlgOwner;
#ifdef VBOX_GUI_WITH_SYSTRAY
bool mIsTrayIconOwner;
#endif
#if defined (Q_OS_WIN32)
private:
long refcnt;
#endif
};
#if !defined (Q_OS_WIN32)
#endif
// VBoxGlobal
////////////////////////////////////////////////////////////////////////////////
static bool sVBoxGlobalInited = false;
static bool sVBoxGlobalInCleanup = false;
/** @internal
*
* Special routine to do VBoxGlobal cleanup when the application is being
* terminated. It is called before some essential Qt functionality (for
* instance, QThread) becomes unavailable, allowing us to use it from
* VBoxGlobal::cleanup() if necessary.
*/
static void vboxGlobalCleanup()
{
sVBoxGlobalInCleanup = true;
vboxGlobal().cleanup();
}
/** @internal
*
* Determines the rendering mode from the argument. Sets the appropriate
* default rendering mode if the argumen is NULL.
*/
{
#if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)
# ifdef RT_ARCH_X86
/* Quartz2DMode doesn't refresh correctly on 32-bit Snow Leopard, use image mode. */
// char szRelease[80];
// if ( RT_SUCCESS (RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szRelease, sizeof (szRelease)))
// && !strncmp (szRelease, "10.", 3))
// mode = VBoxDefs::QImageMode;
# endif
#elif (defined (Q_WS_WIN32) || defined (Q_WS_PM) || defined (Q_WS_X11)) && defined (VBOX_GUI_USE_QIMAGE)
#elif defined (VBOX_GUI_USE_QIMAGE)
#else
# error "Cannot determine the default render mode!"
#endif
if (aModeStr)
{
if (0) ;
#if defined (VBOX_GUI_USE_QIMAGE)
#endif
#if defined (VBOX_GUI_USE_SDL)
#endif
#if defined (VBOX_GUI_USE_DDRAW)
#endif
#if defined (VBOX_GUI_USE_QUARTZ2D)
#endif
#if defined (VBOX_GUI_USE_QGLFB)
#endif
//#if defined (VBOX_GUI_USE_QGL)
// else if (::strcmp (aModeStr, "qgloverlay") == 0)
// mode = VBoxDefs::QGLOverlayMode;
//#endif
}
return mode;
}
/** @class VBoxGlobal
*
* The VBoxGlobal class incapsulates the global VirtualBox data.
*
* There is only one instance of this class per VirtualBox application,
* the reference to it is returned by the static instance() method, or by
* the global vboxGlobal() function, that is just an inlined shortcut.
*/
: mValid (false)
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
, m_pVirtualMachine(0)
#endif
, mMainWindow (NULL)
#ifdef VBOX_WITH_REGISTRATION
#endif
#ifdef VBOX_GUI_WITH_SYSTRAY
, mIsTrayMenu (false)
, mIncreasedWindowCounter (false)
#endif
, mMediaEnumThread (NULL)
, mIsKWinManaged (false)
, mVerString ("1.0")
{
}
//
// Public members
/////////////////////////////////////////////////////////////////////////////
/**
* Returns a reference to the global VirtualBox data, managed by this class.
*
* The main() function of the VBox GUI must call this function soon after
* creating a QApplication instance but before opening any of the main windows
* (to let the VBoxGlobal initialization procedure use various Qt facilities),
* and continue execution only when the isValid() method of the returned
* instancereturns true, i.e. do something like:
*
* @code
* if ( !VBoxGlobal::instance().isValid() )
* return 1;
* @endcode
* or
* @code
* if ( !vboxGlobal().isValid() )
* return 1;
* @endcode
*
* @note Some VBoxGlobal methods can be used on a partially constructed
* VBoxGlobal instance, i.e. from constructors and methods called
* from the VBoxGlobal::init() method, which obtain the instance
* using this instance() call or the ::vboxGlobal() function. Currently, such
* methods are:
* #vmStateText, #vmTypeIcon, #vmTypeText, #vmTypeTextList, #vmTypeFromText.
*
* @see ::vboxGlobal
*/
{
static VBoxGlobal vboxGlobal_instance;
if (!sVBoxGlobalInited)
{
/* check that a QApplication instance is created */
if (qApp)
{
sVBoxGlobalInited = true;
/* add our cleanup handler to the list of Qt post routines */
}
else
AssertMsgFailed (("Must construct a QApplication first!"));
}
return vboxGlobal_instance;
}
VBoxGlobal::~VBoxGlobal()
{
}
/* static */
{
}
/* static */
{
}
/* static */
{
}
/* static */
{
}
/**
* 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 successfullly
* 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.
*/
{
#if defined (VBOX_GUI_SEPARATE_VM_PROCESS)
("Must NOT be a VM console process"));
#endif
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;
}
{
if (isVMConsoleProcess())
{
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
if (m_pVirtualMachine)
return m_pVirtualMachine->mainWindow();
else
#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
return &consoleWnd();
}
return NULL;
}
/**
* Returns a reference to the main VBox VM Console window.
* The reference is valid until application termination.
*
* There is only one such a window per VirtualBox application.
*/
{
#if defined (VBOX_GUI_SEPARATE_VM_PROCESS)
("Must be a VM console process"));
#endif
if (!mConsoleWnd)
{
/*
* We pass the address of mConsoleWnd 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 == mConsoleWnd);
NOREF(w);
}
return *mConsoleWnd;
}
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
{
{
return true;
}
return false;
}
{
return m_pVirtualMachine;
}
#endif
{
if (aForce)
return true;
if (mBrandingConfig.isEmpty())
{
mBrandingConfig += "/custom/custom.ini";
}
}
/**
* Gets a value from the custom .ini file
*/
{
}
#ifdef VBOX_GUI_WITH_SYSTRAY
/**
* Returns true if the current instance a systray menu only (started with
* "-systray" parameter).
*/
bool VBoxGlobal::isTrayMenu() const
{
return mIsTrayMenu;
}
{
}
/**
* Spawns a new selector window (process).
*/
void VBoxGlobal::trayIconShowSelector()
{
/* Get the path to the executable. */
char path [RTPATH_MAX];
int rc = 0;
# ifdef RT_OS_WINDOWS
# else
# endif
if (RT_FAILURE (rc))
}
/**
* Tries to install the tray icon using the current instance (singleton).
* Returns true if this instance is the tray icon, false if not.
*/
bool VBoxGlobal::trayIconInstall()
{
int rc = 0;
if (false == strTrayWinID.isEmpty())
{
/* Check if current tray icon is alive by writing some bogus value. */
{
/* Current tray icon died - clean up. */
}
}
/* Is there already a tray icon or is tray icon not active? */
if ( (mIsTrayMenu == false)
&& (QSystemTrayIcon::isSystemTrayAvailable())
&& (strTrayWinID.isEmpty()))
{
/* Get the path to the executable. */
char path [RTPATH_MAX];
# ifdef RT_OS_WINDOWS /** @todo drop this once the RTProcCreate bug has been fixed */
# else
# endif
if (RT_FAILURE (rc))
{
return false;
}
}
if (mIsTrayMenu)
{
// Use this selector for displaying the tray icon
/* The first process which can grab this "mutex" will win ->
* It will be the tray icon menu then. */
{
return true;
}
}
return false;
}
#endif
#ifdef Q_WS_X11
{
/* Prepare empty resulting list: */
/* Get current display: */
/* If thats 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 thats virtual desktop: */
if (pDesktopWidget->isVirtualDesktop())
{
/* If thats 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();
}
}
/**
* Returns a string representation of the given channel number on the given storage bus.
* Complementary to #toStorageChannel (KStorageBus, const QString &) const.
*/
{
switch (aBus)
{
case KStorageBus_IDE:
{
{
break;
}
break;
}
case KStorageBus_SATA:
case KStorageBus_SCSI:
{
break;
}
case KStorageBus_Floppy:
{
AssertMsgFailed (("Floppy have no channels, only devices\n"));
break;
}
default:
{
break;
}
}
return channel;
}
/**
* Returns a channel number on the given storage bus corresponding to the given string representation.
* Complementary to #toString (KStorageBus, LONG) const.
*/
{
switch (aBus)
{
case KStorageBus_IDE:
{
QLongStringHash::const_iterator it = qFind (mStorageBusChannels.begin(), mStorageBusChannels.end(), aChannel);
AssertMsgBreak (it != mStorageBusChannels.end(), ("No value for {%s}\n", aChannel.toLatin1().constData()));
break;
}
case KStorageBus_SATA:
case KStorageBus_SCSI:
{
{
break;
}
break;
}
case KStorageBus_Floppy:
{
channel = 0;
break;
}
default:
{
break;
}
}
return channel;
}
/**
* Returns a string representation of the given device number of the given channel on the given storage bus.
* Complementary to #toStorageDevice (KStorageBus, LONG, const QString &) const.
*/
{
switch (aBus)
{
case KStorageBus_IDE:
{
{
break;
}
break;
}
case KStorageBus_SATA:
case KStorageBus_SCSI:
{
AssertMsgFailed (("SATA & SCSI have no devices, only channels\n"));
break;
}
case KStorageBus_Floppy:
{
break;
}
default:
{
break;
}
}
return device;
}
/**
* Returns a device number of the given channel on the given storage bus corresponding to the given string representation.
* Complementary to #toString (KStorageBus, LONG, LONG) const.
*/
{
switch (aBus)
{
case KStorageBus_IDE:
{
QLongStringHash::const_iterator it = qFind (mStorageBusDevices.begin(), mStorageBusDevices.end(), aDevice);
AssertMsgBreak (it != mStorageBusDevices.end(), ("No value for {%s}", aDevice.toLatin1().constData()));
break;
}
case KStorageBus_SATA:
case KStorageBus_SCSI:
{
device = 0;
break;
}
case KStorageBus_Floppy:
{
{
break;
}
break;
}
default:
{
break;
}
}
return device;
}
/**
* Returns a full string representation of the given device of the given channel on the given storage bus.
* This method does not uses any separate string tags related to bus, channel, device, it has own
* separately translated string tags allowing to translate a full slot name into human readable format
* to be consistent with i18n.
* Complementary to #toStorageSlot (const QString &) const.
*/
{
{
case KStorageBus_IDE:
case KStorageBus_SATA:
case KStorageBus_SCSI:
case KStorageBus_Floppy:
case KStorageBus_SAS:
break;
default:
{
break;
}
}
{
case KStorageBus_IDE:
{
break;
}
case KStorageBus_SATA:
{
break;
}
case KStorageBus_SCSI:
{
break;
}
case KStorageBus_Floppy:
{
break;
}
case KStorageBus_SAS:
{
break;
}
default:
{
break;
}
}
return result;
}
/**
* Returns a StorageSlot based on the given device of the given channel on the given storage bus.
* Complementary to #toFullString (StorageSlot) const.
*/
{
int index = -1;
for (int i = 0; i < mSlotTemplates.size(); ++ i)
{
{
index = i;
break;
}
}
switch (index)
{
case 0:
case 1:
case 2:
case 3:
{
break;
}
case 4:
{
break;
}
case 5:
{
break;
}
case 6:
{
break;
}
default:
break;
}
return result;
}
/**
* Returns the list of all device types (VirtualBox::DeviceType COM enum).
*/
{
static QStringList list;
return list;
}
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, 0x3BC },
{ "LPT2", 5, 0x378 },
{ "LPT3", 5, 0x278 },
/* must not contain an element with IRQ=0 and IOBase=0 used to cause
* toLPTPortName() to return the "User-defined" string for these values. */
};
/**
* 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;
}
/**
* Searches for the given hard disk in the list of known media descriptors and
* calls VBoxMedium::details() on the found desriptor.
*
* If the requeststed hard disk is not found (for example, it's a new hard disk
* for a new VM created outside our UI), then media enumeration is requested and
* the search is repeated. We assume that the secont attempt always succeeds and
* assert otherwise.
*
* @note Technically, the second attempt may fail if, for example, the new hard
* passed to this method disk gets removed before #startEnumeratingMedia()
* succeeds. This (unexpected object uninitialization) is a generic
* problem though and needs to be addressed using exceptions (see also the
* @todo in VBoxMedium::details()).
*/
{
{
/* Medium may be new and not already in the media list, request refresh */
/* Medium might be deleted already, return null string */
return QString();
}
}
/**
* Returns the details of the given USB device as a single-line string.
*/
{
{
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 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 */
/* IO 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;
{
++ rows;
CMediumAttachmentVector attachments = aMachine.GetMediumAttachmentsOfController (controller.GetName());
{
if (attachment.isOk())
{
attachment.GetDevice())) +
++ 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)
#ifdef VBOX_WITH_VDE
else if (type == KNetworkAttachmentType_VDE)
#endif
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 */
{
&& ctl.GetProxyAvailable())
{
/* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
if (ctl.GetEnabled())
{
active ++;
}
else
report += sectionTpl
"#usb", /* link */
item); /* items */
}
}
/* Shared Folders */
{
if (count > 0)
{
}
else
report += sectionTpl
"#sfolders", /* link */
item); /* items */
}
}
{
#if defined (Q_OS_WIN)
platform = "win";
#elif defined (Q_OS_LINUX)
platform = "linux";
platform = "macosx";
platform = "os2";
#elif defined (Q_OS_FREEBSD)
platform = "freebsd";
#elif defined (Q_OS_SOLARIS)
platform = "solaris";
#else
platform = "unknown";
#endif
/* The format is <system>.<bitness> */
/* Add more system information */
#if defined (Q_OS_WIN)
if (major == 6)
else if (major == 5)
{
if (minor == 2)
else if (minor == 1)
else if (minor == 0)
else
}
else if (major == 4)
{
if (minor == 90)
else if (minor == 10)
else if (minor == 0)
else
}
else /** @todo Windows Server 2008 == vista? Probably not... */
#elif defined (Q_OS_LINUX)
/* Get script path */
char szAppPrivPath [RTPATH_MAX];
/* Run script */
#else
/* Use RTSystemQueryOSInfo. */
char szTmp[256];
if (!components.isEmpty())
#endif
return platform;
}
double VBoxGlobal::findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const
{
double maxVersionNumber = 0;
aLicenseFile = "";
{
{
}
}
return maxVersionNumber;
}
bool VBoxGlobal::showVirtualBoxLicense()
{
/* get the apps doc path */
int size = 256;
/* 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. */
/* First try to find a localized version of the license file. */
double versionNumber = findLicenseFile (filesList, QRegExp (QString ("License-([\\d\\.]+)-%1.html").arg (lang.name())), licenseFile);
/* If there wasn't a localized version of the currently selected language,
* search for the generic one. */
if (versionNumber == 0)
/* Check the version again. */
if (!versionNumber)
{
return false;
}
/* compose the latest license file full path */
/* check for the agreed license version */
if (licenseAgreed == latestVersion)
return true;
if (result)
return result;
}
#endif /* defined(Q_WS_X11) && !defined(VBOX_OSE) */
/**
* Opens a direct session for a machine with the given ID.
* This method does user-friendly error handling (display error messages, etc.).
* and returns a null CSession object in case of any error.
* If this method succeeds, don't forget to close the returned session when
* it is no more necessary.
*
* @param aId Machine ID.
* @param aExisting @c true to open an existing session with the machine
* which is already running, @c false to open a new direct
* session.
*/
{
{
return session;
}
if (aExisting)
else
{
/* 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. */
}
{
}
return session;
}
/**
* Starts a machine with the given ID.
*/
{
AssertReturn(mValid, false);
return false;
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
return createVirtualMachine(session);
# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
else
# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
}
/**
* Appends the NULL medium to the media list.
* For using with VBoxGlobal::startEnumeratingMedia() only.
*/
{
}
/**
* Appends the given list of mediums to the media list.
* For using with VBoxGlobal::startEnumeratingMedia() only.
*/
VBoxMedium *aParent = 0)
{
{
/* Search for a proper alphabetic position */
break;
/* Adjust the first item if inserted before it */
-- first;
}
}
/**
* Appends the given list of hard disks and all their children to the media list.
* For using with VBoxGlobal::startEnumeratingMedia() only.
*/
VBoxMedium *aParent = 0)
{
/* First pass: Add siblings sorted */
{
/* Search for a proper alphabetic position */
break;
/* Adjust the first item if inserted before it */
-- first;
}
/* Second pass: Add children */
{
++ it; /* go to the next sibling before inserting children */
}
}
/**
* Starts a thread that asynchronously enumerates all currently registered
* media.
*
* Before the enumeration is started, the current media list (a list returned by
* #currentMediaList()) is populated with all registered media and the
* #mediumEnumStarted() signal is emitted. The enumeration thread then walks this
* list, checks for media acessiblity and emits #mediumEnumerated() signals of
* each checked medium. When all media are checked, the enumeration thread is
* stopped and the #mediumEnumFinished() signal is emitted.
*
* If the enumeration is already in progress, no new thread is started.
*
* The media list returned by #currentMediaList() is always sorted
* alphabetically by the location attribute and comes in the following order:
* <ol>
* <li>All hard disks. If a hard disk has children, these children
* (alphabetically sorted) immediately follow their parent and terefore
* appear before its next sibling hard disk.</li>
* <li>All Floppy images.</li>
* </ol>
*
* Note that #mediumEnumerated() signals are emitted in the same order as
* described above.
*
* @sa #currentMediaList()
* @sa #isMediaEnumerationStarted()
*/
void VBoxGlobal::startEnumeratingMedia()
{
/* check if already started but not yet finished */
if (mMediaEnumThread != NULL)
return;
/* ignore the request during application termination */
if (sVBoxGlobalInCleanup)
return;
/* composes a list of all currently known media & their children */
mMediaList.clear();
addMediumsToList (mVBox.GetHost().GetDVDDrives(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_DVD);
addMediumsToList (mVBox.GetHost().GetFloppyDrives(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_Floppy);
addMediumsToList (mVBox.GetFloppyImages(), mMediaList, mMediaList.end(), VBoxDefs::MediumType_Floppy);
/* enumeration thread class */
class MediaEnumThread : public QThread
{
public:
{
int i = 0;
}
virtual void run()
{
LogFlow (("MediaEnumThread started.\n"));
COMBase::InitializeCOM();
/* Enumerate the list */
{
mVector [i].blockAndQueryState();
}
/* Post the end-of-enumeration event */
if (!sVBoxGlobalInCleanup)
COMBase::CleanupCOM();
LogFlow (("MediaEnumThread finished.\n"));
}
private:
};
/* emit mediumEnumStarted() after we set mMediaEnumThread to != NULL
* to cause isMediaEnumerationStarted() to return TRUE from slots */
}
/**
* Adds a new medium to the current media list and emits the #mediumAdded()
* signal.
*
* @sa #currentMediaList()
*/
{
/* Note that we maitain the same order here as #startEnumeratingMedia() */
{
{
/* skip null medium that come first */
break;
{
}
else
{
/* break if met a parent's sibling (will insert before it) */
break;
/* compare to aMedium's siblings */
break;
}
}
}
else
{
{
/* skip null medium that come first */
/* skip HardDisks that come first */
continue;
/* skip DVD when inserting Floppy */
continue;
break;
}
}
}
/**
* Updates the medium in the current media list and emits the #mediumUpdated()
* signal.
*
* @sa #currentMediaList()
*/
{
break;
}
/**
* Removes the medium from the current media list and emits the #mediumRemoved()
* signal.
*
* @sa #currentMediaList()
*/
{
break;
#if DEBUG
/* sanity: must be no children */
{
++ jt;
}
#endif
/* remove the medium from the list to keep it in sync with the server "for
* free" when the medium is deleted from one of our UIs */
/* also emit the parent update signal because some attributes like
* isReadOnly() may have been changed after child removal */
{
}
}
/**
* Searches for a VBoxMedum object representing the given COM medium object.
*
* @return true if found and false otherwise.
*/
{
{
{
return true;
}
}
return false;
}
/**
* Searches for a VBoxMedum object with the given medium id attribute.
*
* @return VBoxMedum if found which is invalid otherwise.
*/
{
return *it;
return VBoxMedium();
}
#ifdef VBOX_GUI_WITH_SYSTRAY
/**
*
* @return Number of running main windows.
*/
int VBoxGlobal::mainWindowCount ()
{
}
#endif
/**
* 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 "Sun Microsystems, Inc." if no translation is installed or if the
* translation file is invalid, or if the translation is supplied by Sun
* Microsystems, inc.
*/
{
"Comma-separated list of translators");
}
/**
* Changes the language of all global string constants according to the
* currently installed translations tables.
*/
void VBoxGlobal::retranslateUi()
{
#ifdef VBOX_WITH_VIRTIO
#endif /* VBOX_WITH_VIRTIO */
#ifdef VBOX_WITH_VDE
#endif
/* refresh media properties since they contain some translations too */
/* As PM and X11 do not (to my knowledge) have functionality for providing
* human readable key names, we keep a table of them, which must be
* updated when the language is changed. */
#endif
}
// 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 Sun 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 Sun version may not fully support it. We don't do it on
* Win32 because we supply a Qt library there and therefore the
* Sun 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";
}
{
#if defined (Q_WS_WIN32)
#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;
}
{
return iconSet;
}
/* static */
const char *aDisabled /* = NULL */,
const char *aActive /* = NULL */)
{
return iconSet;
}
/* static */
const char *aDisabled /* = NULL */,
const char *aDisabledOff /* = NULL */,
const char *aActive /* = NULL */,
const char *aActiveOff /* = NULL */)
{
if (aNormalOff != NULL)
if (aDisabledOff != NULL)
if (aActiveOff != NULL)
return iconSet;
}
/* static */
const char *aNormal, const char *aSmallNormal,
const char *aDisabled /* = NULL */,
const char *aSmallDisabled /* = NULL */,
const char *aActive /* = NULL */,
const char *aSmallActive /* = NULL */)
{
if (aSmallDisabled != NULL)
{
}
if (aSmallActive != NULL)
{
}
return iconSet;
}
{
if (!style)
return QIcon();
#ifdef Q_WS_MAC
/* At least in Qt 4.3.4/4.4 RC1 SP_MessageBoxWarning is the application
* icon. So change this to the critical icon. (Maybe this would be
* fixed in a later Qt version) */
#endif /* Q_WS_MAC */
}
/**
* 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|KB|KiB|MB|MiB|GB|GiB|TB|TiB|PB|PiB</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 */
{
tr ("^(?:(?:(\\d+)(?:\\s?(B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB|PB|PiB))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?(kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB|PB|PiB))))$", "regexp for matching ####[.##] B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB|PB|PiB, %1=decimal point")
.arg (decimalSep());
return regexp;
}
/**
* Parses the given size string that should be in form of
* <tt>####[.##] B|kB|KB|KiB|MB|MiB|GB|GiB|TB|TiB|PB|PiB</tt> and returns
* the size value in bytes. Zero is returned on error.
*/
/* static */
{
if (pos != -1)
{
{
}
denom = 1;
denom = 1000;
denom = 1000000;
denom = 1000000000;
denom = 1000000000000ULL;
denom = 1000000000000000ULL;
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|KiB|MiB|GiB|TiB|PiB</tt>.
*
* The @a aMode and @a aDecimal parameters are used for rounding the resulting
* number when converting the size value to KiB, MiB, 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 */
/* not less */
/* nearest */
}
/* check for the fractional part overflow due to rounding */
{
decm = 0;
++ intg;
/* check if we've got 1024 XiB 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. */
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 beginnign 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 beginnign 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 propery 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 acceletartor 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 occurense of the accelerator
* mark.
*
* @param aText Menu item's text to remove the acceletaror mark from.
*
* @return The resulting string.
*/
/* static */
{
if (pos >= 0)
else
{
if (pos >= 0)
}
return result;
}
/* static */
{
#ifdef Q_WS_MAC
#else
#endif
}
/* 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 */)
{
{
{
break;
if (aRecursive)
{
if (w)
break;
}
}
return w;
}
/* Find the first children of aParent with the appropriate properties.
* Please note that this call is recursivly. */
{
break;
}
return child;
}
/**
* 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 */
{
for (int i = 0; i < mediumFormats.size(); ++ i)
{
/* File extensions */
QStringList f;
for (int a = 0; a < fileExtensions.size(); ++ a)
/* Create a pair out of the backend description and all suffix's. */
if (!f.isEmpty())
}
return backendPropList;
}
/* static */
{
#if QT_VERSION < 0x040400
#else
#endif
/* Make sure the path exists */
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
// 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;
}
/**
* Shows the VirtualBox registration dialog.
*
* @note that this method is not part of VBoxProblemReporter (like e.g.
* VBoxProblemReporter::showHelpAboutDialog()) because it is tied to
* VBoxCallback::OnExtraDataChange() handling performed by VBoxGlobal.
*
* @param aForce
*/
{
#ifdef VBOX_WITH_REGISTRATION
return;
if (mRegDlg)
{
/* Show the already opened registration dialog */
}
else
{
/* Store the ID of the main window to ensure that only one
* registration dialog is shown at a time. Due to manipulations with
* OnExtraDataCanChange() and OnExtraDataChange() signals, this extra
* data item acts like an inter-process mutex, so the first process
* that attempts to set it will win, the rest will get a failure from
* the SetExtraData() call. */
{
/* We've got the "mutex", create a new registration dialog */
}
}
#endif
}
/**
* Shows the VirtualBox version check & update dialog.
*
* @note that this method is not part of VBoxProblemReporter (like e.g.
* VBoxProblemReporter::showHelpAboutDialog()) because it is tied to
* VBoxCallback::OnExtraDataChange() handling performed by VBoxGlobal.
*
* @param aForce
*/
{
/* Silently check in one day after current time-stamp */
60 /* seconds */ * 1000 /* milliseconds */,
this, SLOT (perDayNewVersionNotifier()));
if (!aForce && !isNecessary)
return;
if (mUpdDlg)
{
{
}
}
else
{
/* Store the ID of the main window to ensure that only one
* update dialog is shown at a time. Due to manipulations with
* OnExtraDataCanChange() and OnExtraDataChange() signals, this extra
* data item acts like an inter-process mutex, so the first process
* that attempts to set it will win, the rest will get a failure from
* the SetExtraData() call. */
{
/* We've got the "mutex", create a new update dialog */
/* Update dialog always in background mode for now.
* if (!aForce && isAutomatic) */
/* else mUpdDlg->show(); */
}
}
}
void VBoxGlobal::perDayNewVersionNotifier()
{
showUpdateDialog (false /* force show? */);
}
// Protected members
////////////////////////////////////////////////////////////////////////////////
{
switch (e->type())
{
case VBoxDefs::AsyncEventType:
{
return true;
}
case VBoxDefs::MediaEnumEventType:
{
{
}
else
{
/* the thread has posted the last message, wait for termination */
mMediaEnumThread->wait();
delete mMediaEnumThread;
mMediaEnumThread = 0;
}
return true;
}
/* VirtualBox callback events */
{
return true;
}
{
return true;
}
{
return true;
}
{
return true;
}
case VBoxDefs::SnapshotEventType:
{
return true;
}
case VBoxDefs::CanShowRegDlgEventType:
{
return true;
}
case VBoxDefs::CanShowUpdDlgEventType:
{
return true;
}
{
return true;
}
#ifdef VBOX_GUI_WITH_SYSTRAY
return true;
case VBoxDefs::CanShowTrayIconEventType:
{
return true;
}
case VBoxDefs::ShowTrayIconEventType:
{
return true;
}
case VBoxDefs::TrayIconChangeEventType:
{
return true;
}
#endif
#if defined(Q_WS_MAC)
{
return true;
}
{
return true;
}
#endif
default:
break;
}
}
{
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) */
}
}
}
// Private members
////////////////////////////////////////////////////////////////////////////////
void VBoxGlobal::init()
{
#ifdef DEBUG
mVerString += " [DEBUG]";
#endif
#ifdef Q_WS_WIN
/* COM for the main thread is initialized in main() */
#else
{
return;
}
#endif
{
return;
}
/* create default non-null global settings */
gset = VBoxGlobalSettings (false);
/* try to load global settings */
{
return;
}
/* Load the customized language as early as possible to get possible error
* messages translated */
if (!sLanguageId.isNull())
#ifdef VBOX_GUI_WITH_SYSTRAY
{
("Something went wrong with the window reference count!"));
}
#endif
/* Initialize guest OS Type list. */
if (osTypeCount > 0)
{
/* Here we assume the 'Other' type is always the first, so we
* remember it and will append it to the list when finished. */
/* Fill the lists with all the available OS Types except
* the 'Other' type, which will be appended. */
{
{
mFamilyIDs << familyId;
}
}
/* Append the 'Other' OS Type to the end of list. */
{
}
}
/* Fill in OS type icon dictionary. */
static const char *kOSTypeIcons [][2] =
{
{"Other", ":/os_other.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"},
{"WindowsNT", ":/os_win_other.png"},
{"OS2Warp3", ":/os_os2warp3.png"},
{"OS2Warp4", ":/os_os2warp4.png"},
{"OS2Warp45", ":/os_os2warp45.png"},
{"OS2eCS", ":/os_os2ecs.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"},
{"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_opensolaris.png"},
{"OpenSolaris_64", ":/os_opensolaris_64.png"},
{"QNX", ":/os_qnx.png"},
{"MacOS", ":/os_macosx.png"},
{"MacOS_64", ":/os_macosx_64.png"},
};
{
}
/* fill in VM state icon map */
static const struct
{
const char *name;
}
kVMStateIcons[] =
{
{KMachineState_PoweredOff, ":/state_powered_off_16px.png"},
{KMachineState_Saved, ":/state_saved_16px.png"},
{KMachineState_Aborted, ":/state_aborted_16px.png"},
{KMachineState_Teleported, ":/state_saved_16px.png"}, /** @todo Live Migration: New icon? (not really important) */
{KMachineState_Running, ":/state_running_16px.png"},
{KMachineState_Paused, ":/state_paused_16px.png"},
{KMachineState_Teleporting, ":/state_running_16px.png"}, /** @todo Live Migration: New icon? (not really important) */
{KMachineState_LiveSnapshotting, ":/state_running_16px.png"}, /** @todo Live Migration: New icon? (not really important) */
{KMachineState_Stuck, ":/state_stuck_16px.png"},
{KMachineState_Saving, ":/state_saving_16px.png"},
{KMachineState_Restoring, ":/state_restoring_16px.png"},
{KMachineState_TeleportingPausedVM, ":/state_saving_16px.png"}, /** @todo Live Migration: New icon? (not really important) */
{KMachineState_TeleportingIn, ":/state_restoring_16px.png"}, /** @todo Live Migration: New icon? (not really important) */
{KMachineState_RestoringSnapshot, ":/state_discarding_16px.png"},
{KMachineState_DeletingSnapshot, ":/state_discarding_16px.png"},
{KMachineState_SettingUp, ":/settings_16px.png"},
};
{
}
/* initialize state colors map */
qApp->installEventFilter (this);
/* process command line */
bool bForceSeamless = false;
#ifdef Q_WS_X11
#endif
#ifdef VBOX_WITH_DEBUGGER_GUI
# ifdef VBOX_WITH_DEBUGGER_GUI_MENU
mDbgEnabled = true;
# else
# endif
= RTEnvExist("VBOX_GUI_DBG_AUTO_SHOW");
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;
}
}
{
bForceSeamless = true;
}
#ifdef VBOX_GUI_WITH_SYSTRAY
{
mIsTrayMenu = true;
}
#endif
{
++i;
}
{
if (++i < argc)
}
#ifdef VBOX_WITH_DEBUGGER_GUI
{
mDbgEnabled = true;
}
{
mDbgEnabled = true;
mStartPaused = true;
}
{
mDbgEnabled = true;
mDbgAutoShow = mDbgAutoShowCommandLine = true;
mStartPaused = true;
}
{
mDbgEnabled = true;
mDbgAutoShow = mDbgAutoShowStatistics = true;
mStartPaused = true;
}
{
mDbgEnabled = false;
mDbgAutoShow = false;
mDbgAutoShowCommandLine = false;
mDbgAutoShowStatistics = false;
}
/* Not quite debug options, but they're only useful with the debugger bits. */
{
mStartPaused = true;
}
{
mStartPaused = false;
}
{
mShowStartVMErrors = false;
}
#endif
/** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */
i++;
}
if (startVM)
{
{
}
else
{
if (m.isNull())
{
if (showStartVMErrors())
return;
}
}
}
{
}
/* setup the callback */
return;
#ifdef VBOX_WITH_DEBUGGER_GUI
/* setup the debugger gui. */
if (RTEnvExist("VBOX_GUI_NO_DEBUGGER"))
if (mDbgEnabled)
{
if (RT_FAILURE(vrc))
{
}
}
#endif
mValid = true;
}
/** @internal
*
* This method should be never called directly. It is called automatically
* when the application terminates.
*/
void VBoxGlobal::cleanup()
{
/* sanity check */
if (!sVBoxGlobalInCleanup)
{
AssertMsgFailed (("Should never be called directly\n"));
return;
}
#ifdef VBOX_GUI_WITH_SYSTRAY
{
("Something went wrong with the window reference count!"));
if (c < 0)
c = 0; /* Clean up the mess. */
if (c == 0)
{
}
}
#endif
{
}
if (mMediaEnumThread)
{
/* sVBoxGlobalInCleanup is true here, so just wait for the thread */
mMediaEnumThread->wait();
delete mMediaEnumThread;
mMediaEnumThread = 0;
}
#ifdef VBOX_WITH_REGISTRATION
if (mRegDlg)
#endif
if (mConsoleWnd)
delete mConsoleWnd;
if (mSelectorWnd)
delete mSelectorWnd;
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
if (m_pVirtualMachine)
delete m_pVirtualMachine;
#endif
/* ensure CGuestOSType objects are no longer used */
mFamilyIDs.clear();
/* media list contains a lot of CUUnknown, release them */
mMediaList.clear();
/* the last step to ensure we don't use COM any more */
/* There may be VBoxMediaEnumEvent instances still in the message
* queue which reference COM objects. Remove them to release those objects
* before uninitializing the COM subsystem. */
QApplication::removePostedEvents (this);
#ifdef Q_WS_WIN
/* COM for the main thread is shutdown in main() */
#else
COMBase::CleanupCOM();
#endif
mValid = false;
}
/** @fn vboxGlobal
*
* Shortcut to the static VBoxGlobal::instance() method, for convenience.
*/
/**
* USB Popup Menu class methods
* This class provides the list of USB devices attached to the host.
*/
{
this, SLOT (processAboutToShow()));
// connect (this, SIGNAL (hovered (QAction *)),
// this, SLOT (processHighlighted (QAction *)));
}
{
return mUSBDevicesMap [aAction];
}
{
}
void VBoxUSBMenu::processAboutToShow()
{
clear();
if (isUSBEmpty)
{
action->setEnabled (false);
"USB device tooltip"));
}
else
{
{
action->setCheckable (true);
/* check if created item was alread attached to this session */
{
}
}
}
}
{
/* We provide dynamic tooltips for the usb devices */
{
if (action)
{
{
return true;
}
}
}
}
/**
*/
bool aInverted)
{
/* this menu works only with toggle action */
this, SLOT (processAboutToShow()));
}
{
}
void VBoxSwitchMenu::processAboutToShow()
{
}