VBoxGlobal.cpp revision 5585d4b0d8a07e6f59b79c557a3b65fa16f58588
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxGlobal class implementation
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#include "VBoxGlobal.h"
#include "VBoxDefs.h"
#include "VBoxSelectorWnd.h"
#include "VBoxConsoleWnd.h"
#include "VBoxProblemReporter.h"
#include <qapplication.h>
#include <qmessagebox.h>
#include <qpixmap.h>
#include <qiconset.h>
#include <qwidgetlist.h>
#include <qfileinfo.h>
#include <qdir.h>
#include <qmutex.h>
#include <qregexp.h>
#include <qlocale.h>
#if defined (VBOX_GUI_DEBUG)
#endif
// VBoxEnumerateMediaEvent
/////////////////////////////////////////////////////////////////////////////
class VBoxEnumerateMediaEvent : public QEvent
{
public:
/** Constructs a regular enum event */
{}
/** Constructs the last enum event */
{}
/** the last enumerated media (not valid when #last is true) */
/** whether this is the last event for the given enumeration or not */
const bool mLast;
/** last enumerated media index (-1 when #last is true) */
const int mIndex;
};
// VirtualBox callback class
/////////////////////////////////////////////////////////////////////////////
class VBoxCallback : public IVirtualBoxCallback
{
public:
{
#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;
}
{
if (riid == IID_IUnknown) {
*ppObj = this;
AddRef();
return S_OK;
}
if (riid == IID_IVirtualBoxCallback) {
*ppObj = this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
#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 examile, reading
// some property) directly from the callback method will definitely cause
// a deadlock.
{
return S_OK;
}
{
return S_OK;
}
{
if (!allowChange)
return E_INVALIDARG;
{
// it's a global extra data key someone wants to change
{
// try to set the global setting to check its syntax
{
/// @todo (dmik)
// report the error message to the server using
// IVurtualBoxError
return S_OK;
}
}
}
// not interested in this key -- never disagree
*allowChange = TRUE;
return S_OK;
}
{
{
{
}
}
return S_OK;
}
{
/** @todo */
return S_OK;
}
{
registered));
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
{
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 (!global.isVMConsoleProcess())
}
/** protects #OnExtraDataChange() */
#if defined (Q_OS_WIN32)
private:
long refcnt;
#endif
};
#if !defined (Q_OS_WIN32)
#endif
// VBoxGlobal
////////////////////////////////////////////////////////////////////////////////
static bool vboxGlobal_inited = false;
static bool vboxGlobal_cleanup = 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()
{
vboxGlobal_cleanup = 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_WIN32)
#else
#endif
if ( display ) {
}
}
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.
*/
: valid (false)
, selector_wnd (0), console_wnd (0)
, media_enum_thread (0)
, verString ("1.0")
, diskControllerDevices (3)
, detailReportTemplatesReady (false)
{
}
//
// 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 (!vboxGlobal_inited)
{
// check that the QApplication instance is created
if (qApp)
{
vboxGlobal_inited = true;
// add our cleanup handler to the list of Qt post routines
}
else
AssertMsgFailed (("Must construct a QApplication first!"));
}
return vboxGlobal_instance;
}
/**
* Sets the new global settings and saves them to the VirtualBox server.
*/
{
{
return false;
}
// @note
// 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 (!selector_wnd)
{
/*
* We pass the address of selector_wnd 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 == selector_wnd);
NOREF(w);
}
return *selector_wnd;
}
/**
* 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 ( !console_wnd )
{
/*
* We pass the address of console_wnd 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 == console_wnd);
NOREF(w);
}
return *console_wnd;
}
/**
* Returns the list of all guest OS type descriptions, queried from
* IVirtualBox.
*/
{
static QStringList list;
}
}
return list;
}
/**
* Returns the guest OS type object corresponding to a given index.
* The index argument corresponds to the index in the list of OS type
* descriptions as returnded by #vmGuestOSTypeDescriptions().
*
* If the index is invalid a null object is returned.
*/
{
return type;
}
/**
* Returns the index corresponding to a given guest OS type object.
* The returned index corresponds to the index in the list of OS type
* descriptions as returnded by #vmGuestOSTypeDescriptions().
*
* If the guest OS type is invalid, -1 is returned.
*/
{
for (int i = 0; i < (int) vm_os_types.count(); i++) {
return i;
}
return -1;
}
/**
* Returns the icon corresponding to a given guest OS type.
*/
{
return p ? *p : none;
}
{
switch (t)
{
case CEnums::IDE0Controller:
case CEnums::IDE1Controller:
{
if (d == 0 || d == 1)
{
dev = diskControllerDevices [d];
break;
}
// fall through
}
default:
}
return dev;
}
/**
* Returns the list of all device types (VurtialBox::DeviceType COM enum).
*/
{
static QStringList list;
list += deviceTypes [i];
return list;
}
/**
* Returns the details of the given hard disk as a single-line string
* to be used in the VM details view.
*
* The details include the type and the virtual size of the hard disk.
* Note that for differencing hard disks based on immutable hard disks,
* the Immutable hard disk type is returned.
*
* @param aHD hard disk image (when predict = true, must be a top-level image)
* @param aPredict when true, the function predicts the type of the resulting
* image after attaching the given image to the machine.
* Otherwise, a real type of the given image is returned
* (with the exception mentioned above).
*/
{
/// @todo (r=dmik) later: we need to keep *all* media (including all hard disk
// children) in the current media list in order for the following to work.
// VBoxMedia media;
// if (!findMedia (CUnknown (aHD), media))
// {
// /* media may be new and not alredy in the media list, request refresh */
// startEnumeratingMedia();
// if (!findMedia (CUnknown (aHD), media))
// AssertFailed();
// }
else
details += ", ";
// icon when not accessible
/// @todo (r=dmik) later: we need to keep *all* media (including all hard disk
// children) in the current media list in order for the following to work.
// switch (media.status)
// {
// case VBoxMedia::Unknown:
// details += tr ("<i>Checking...</i>", "hard disk");
// break;
// case VBoxMedia::Ok:
// break;
// case VBoxMedia::Error:
// case VBoxMedia::Inaccessible:
// details += tr ("Inaccessible", "hard disk");
// break;
// }
return details;
}
/**
* Returns the details of the given USB device as a single-line string.
*/
{
else
{
if (!m.isEmpty())
details += m;
if (!p.isEmpty())
details += " " + p;
}
if (r != 0)
return details;
}
/**
* Returns the multi-line description of the given USB device.
*/
{
tr ("<nobr>Vendor ID: %04hX</nobr><br>"
"<nobr>Product ID: %04hX</nobr><br>"
"<nobr>Revision: %04hX</nobr>", "USB device tooltip"),
aDevice.GetRevision());
/* add the state field if it's a host USB device */
{
}
return tip;
}
/**
* Puts soft hyphens after every path component in the given file name.
* @param fn file name (must be a full path name)
*/
{
/// @todo (dmik) remove?
// QString result = QDir::convertSeparators (fn);
//#ifdef Q_OS_LINUX
// result.replace ('/', "/<font color=red>­</font>");
//#else
// result.replace ('\\', "\\<font color=red>­</font>");
//#endif
// return result;
}
/**
* Returns a details report on a given VM enclosed in a HTML table.
*
* @param m machine to create a report for
* @param isNewVM true when called by the New VM Wizard
* @param withLinks true if section titles should be hypertext links
*/
bool withLinks)
{
static const char *sTableTpl =
"<table border=0 cellspacing=0 cellpadding=0 width=100%>%1</table>";
static const char *sSectionHrefTpl =
"<tr><td rowspan=%1 align=left><img src='%2'></td>"
"<td width=100% colspan=2><a href='%3'><nobr>%4</nobr></a></td></tr>"
"%5"
"<tr><td width=100% colspan=2><font size=1> </font></td></tr>";
static const char *sSectionBoldTpl =
"<tr><td rowspan=%1 align=left><img src='%2'></td>"
"<td width=100% colspan=2><!-- %3 --><b><nobr>%4</nobr></b></td></tr>"
"%5"
"<tr><td width=100% colspan=2><font size=1> </font></td></tr>";
static const char *sSectionItemTpl =
"<tr><td width=30%><nobr>%1</nobr></td><td width=70%>%2</td></tr>";
/* generate templates after every language change */
{
detailReportTemplatesReady = true;
"#general", /* link */
generalItems); /* items */
"#general", /* link */
generalItems); /* items */
"#general", /* link */
generalItems); /* items */
"#general", /* link */
generalItems); /* items */
}
/* common generated content */
{
{
++ rows;
}
{
++ rows;
}
"#hdds", /* link */
hardDisks); /* items */
}
/* compose details report */
if (isNewVM)
{
.arg (m.GetMemorySize())
+ hardDisks;
}
else
{
/* boot order */
{
continue;
if (bootOrder)
bootOrder += ", ";
}
if (!bootOrder)
/* ACPI */
/* IO APIC */
/* General + Hard Disks */
.arg (m.GetMemorySize())
.arg (m.GetVRAMSize())
+ hardDisks;
/* Floppy */
{
case CEnums::NotMounted:
break;
case CEnums::ImageMounted:
{
break;
}
case CEnums::HostDriveCaptured:
{
break;
}
default:
}
"#floppy", /* link */
item); /* items */
/* DVD */
{
case CEnums::NotMounted:
break;
case CEnums::ImageMounted:
{
break;
}
case CEnums::HostDriveCaptured:
{
break;
}
default:
}
"#dvd", /* link */
item); // items
/* audio */
{
if (audio.GetEnabled())
else
"#audio", /* link */
item); /* items */
}
/* network */
{
{
if (adapter.GetEnabled())
{
++ rows;
}
}
{
++ rows;
}
"#network", /* link */
item); /* items */
}
/* USB */
{
{
/* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
if (ctl.GetEnabled())
{
active ++;
}
else
"#usb", /* link */
item); /* items */
}
}
/* VRDP */
{
{
/* the VRDP server may be unavailable (i.e. in VirtualBox OSE) */
if (srv.GetEnabled())
{
}
else
"#vrdp", /* link */
item); /* items */
}
}
}
}
/**
* 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.
*/
{
{
return session;
}
{
}
return session;
}
/**
* Starts a machine with the given ID.
*/
{
if (!valid)
return false;
return false;
}
return false;
}
}
/**
* Starts a thread that asynchronously enumerates all currently registered
* media, checks for its accessibility and posts VBoxEnumerateMediaEvent
* events to the VBoxGlobal object until all media is enumerated.
*
* If the enumeration is already in progress, no new thread is started.
*
* @sa #currentMediaList()
* @sa #isMediaEnumerationStarted()
*/
void VBoxGlobal::startEnumeratingMedia()
{
/* check if already started but not yet finished */
if (media_enum_thread)
return;
/* ignore the request during application termination */
if (vboxGlobal_cleanup)
return;
/* composes a list of all currently known media */
media_list.clear();
{
{
}
{
}
{
}
}
/* enumeration thread class */
{
public:
virtual void run()
{
LogFlow (("MediaEnumThread started.\n"));
COMBase::initializeCOM();
/* enumerating list */
int index = 0;
{
{
{
{
{
}
}
break;
}
{
break;
}
{
break;
}
default:
{
AssertMsgFailed (("Invalid aMedia type\n"));
break;
}
}
}
/* post the last message to indicate the end of enumeration */
if (!vboxGlobal_cleanup)
COMBase::cleanupCOM();
LogFlow (("MediaEnumThread finished.\n"));
}
private:
const VBoxMediaList &mList;
};
/* emit mediaEnumStarted() after we set media_enum_thread to != NULL
* to cause isMediaEnumerationStarted() to return TRUE from slots */
}
/**
* Adds a new media to the current media list.
* @note Currently, this method does nothing but emits the mediaAdded() signal.
* Later, it will be used to synchronize the current media list with
* the actial media list on the server after a single media opetartion
* performed from within one of our UIs.
* @sa #currentMediaList()
*/
{
}
/**
* Updates the media in the current media list.
* @note Currently, this method does nothing but emits the mediaUpdated() signal.
* Later, it will be used to synchronize the current media list with
* the actial media list on the server after a single media opetartion
* performed from within one of our UIs.
* @sa #currentMediaList()
*/
{
}
/**
* Removes the media from the current media list.
* @note Currently, this method does nothing but emits the mediaRemoved() signal.
* Later, it will be used to synchronize the current media list with
* the actial media list on the server after a single media opetartion
* performed from within one of our UIs.
* @sa #currentMediaList()
*/
{
}
/**
* Searches for a VBoxMedia object representing the given COM media object.
*
* @return true if found and false otherwise.
*/
{
{
{
return true;
}
}
return false;
}
/**
* Changes the language of all global string constants according to the
* currently installed translations tables.
*/
void VBoxGlobal::languageChange()
{
detailReportTemplatesReady = false;
}
// public static stuff
////////////////////////////////////////////////////////////////////////////////
/* static */
const char *aDisabled /* = 0 */,
const char *aActive /* = 0 */)
{
if (aDisabled)
if (aActive)
return iconSet;
}
/* static */
{
if (aSmallDisabled)
{
}
if (aSmallActive)
{
}
return iconSet;
}
/**
* Ensures that the given rectangle \a aRect is fully contained within the
* rectangle \a aBoundRect by moving \a aRect if necessary. If \a aRect is
* larger than \a aBoundRect, its top left corner is simply aligned with the
* top left corner of \a aRect and, if \a aCanResize is true, \a aRect is
* shrinked to become fully visible.
*/
/* static */
bool aCanResize /* = true */)
{
/* make the bottom right corner visible */
/* ensure the top left corner is visible */
if (aCanResize)
{
/* adjust the size to make the rectangle fully contained */
if (rd < 0)
if (bd < 0)
}
return fr;
}
/**
* 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->topLevelWidget();
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(). */
{
++ it;
continue;
}
delete list;
/// @todo (r=dmik) not sure, 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 */
if (aCanResize &&
}
/**
* Returns the decimal separator for the current locale.
*/
/* static */
{
return n [1];
}
/**
* 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?([KMGTP]?B))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?([KMGTP]B))))$")
.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;
else if (suff == "KB")
else if (suff == "MB")
else if (suff == "GB")
else if (suff == "TB")
else if (suff == "PB")
if (denom == 1)
return intg;
return intg;
}
else
return 0;
}
/**
* Formats the given \a size value in bytes to a human readable string
* in form of <tt>####[.##] B|KB|MB|GB|TB|PB</tt>.
*
* The \a mode parameter is used for resulting numbers that get a fractional
* part after converting the \a size to KB, MB etc:
* <ul>
* <li>When \a mode is 0, the result is rounded to the closest number
* containing two decimal digits.
* </li>
* <li>When \a mode is -1, the result is rounded to the largest two decimal
* digit number 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 \a size parameter.
* </li>
* <li>When \a mode is 1, the result is rounded to the smallest two decimal
* digit number 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 \a size parameter.
* </li>
* </ul>
*
* @param aSize size value in bytes
* @param aMode convertion mode (-1, 0 or 1)
* @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 (hund)
{
hund *= 100;
/* not greater */
/* not less */
/* nearest */
}
/* check for the fractional part overflow due to rounding */
if (hund == 100)
{
hund = 0;
++ intg;
/* check if we've got 1024 XB after rounding and scale down if so */
{
intg /= 1024;
++ suffix;
}
}
}
else
{
}
}
/* static */
/**
* 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>.
*/
{
if (!aToolTip)
{
strFont = "<font color=#0000CC>";
uuidFont = "<font color=#008000>";
endFont = "</font>";
}
/* mark strings in single quotes with color */
rx.setMinimal (true);
QString ("\\1%1<nobr>'\\2'</nobr>%2")
/* 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|$))"),
QString ("\\1%1<nobr>\\2</nobr>%2")
/* split to paragraphs at \n chars */
if (!aToolTip)
else
return text;
}
// Protected members
////////////////////////////////////////////////////////////////////////////////
{
switch (e->type())
{
case VBoxDefs::EnumerateMediaEventType:
{
{
}
else
{
/* the thread has posted the last message, wait for termination */
delete media_enum_thread;
media_enum_thread = 0;
}
return true;
}
/* VirtualBox callback events */
{
return true;
}
{
return true;
}
{
return true;
}
{
return true;
}
case VBoxDefs::SnapshotEventType:
{
return true;
}
default:
break;
}
}
// Private members
////////////////////////////////////////////////////////////////////////////////
void VBoxGlobal::init()
{
#ifdef DEBUG
verString += " [DEBUG]";
#endif
{
return;
}
{
return;
}
// initialize guest OS type vector
if (osTypeCount > 0)
{
int i = 0;
}
// fill in OS type icon dictionary
static const char *osTypeIcons[][2] =
{
{"unknown", "os_other.png"},
{"dos", "os_dos.png"},
{"win31", "os_win31.png"},
{"win95", "os_win95.png"},
{"win98", "os_win98.png"},
{"winme", "os_winme.png"},
{"winnt4", "os_winnt.png"},
{"win2k", "os_win2000.png"},
{"winxp", "os_winxp.png"},
{"win2k3", "os_win2003.png"},
{"winvista", "os_winvista.png"},
{"os2warp3", "os_os2.png"},
{"os2warp4", "os_os2.png"},
{"os2warp45", "os_os2.png"},
{"linux22", "os_linux.png"},
{"linux24", "os_linux.png"},
{"linux26", "os_linux.png"},
{"freebsd", "os_freebsd.png"},
{"openbsd", "os_openbsd.png"},
{"netbsd", "os_netbsd.png"},
{"netware", "os_netware.png"},
{"solaris", "os_solaris.png"},
{"l4", "os_l4.png"},
};
{
}
// fill in VM state icon dictionary
static struct
{
const char *name;
}
vmStateIcons[] =
{
};
{
}
// initialize state colors vector
// no ownership of elements, we're passing pointers to existing objects
// create default non-null global settings
gset = VMGlobalSettings (false);
// try to load global settings
{
return;
}
// process command line
vm_render_mode_str = 0;
#ifdef VBOX_WITH_DEBUGGER_GUI
#ifdef VBOX_WITH_DEBUGGER_GUI_MENU
dbg_enabled = true;
#else
dbg_enabled = false;
#endif
dbg_visible_at_startup = false;
#endif
int i = 1;
while ( i < argc ) {
if ( ++i < argc ) {
} else {
if (m.isNull()) {
return;
}
}
}
if ( ++i < argc )
}
#ifdef VBOX_WITH_DEBUGGER_GUI
dbg_enabled = true;
}
#ifdef DEBUG
dbg_enabled = false;
dbg_visible_at_startup = false;
}
#else
dbg_enabled = true;
dbg_visible_at_startup = true;
}
#endif
#endif
i++;
}
// setup the callback
return;
/*
* Redefine default large and small icon sizes. In particular, it is
* necessary to consider both 32px and 22px icon sizes as Large when
* we explicitly define them as Large (seems to be a bug in
* QToolButton::sizeHint()).
*/
valid = true;
}
/** @internal
*
* This method should be never called directly. It is called automatically
* when the application terminates.
*/
void VBoxGlobal::cleanup()
{
/* sanity check */
if (!vboxGlobal_cleanup)
{
AssertMsgFailed (("Should never be called directly\n"));
return;
}
{
}
if (media_enum_thread)
{
/* vboxGlobal_cleanup is true here, so just wait for the thread */
delete media_enum_thread;
media_enum_thread = 0;
}
if (console_wnd)
delete console_wnd;
if (selector_wnd)
delete selector_wnd;
/* ensure CGuestOSType objects are no longer used */
vm_os_types.clear();
/* media list contains a lot of CUUnknown, release them */
media_list.clear();
/* the last step to ensure we don't use COM any more */
COMBase::cleanupCOM();
valid = 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()));
this, SLOT (processHighlighted (int)));
}
{
return mUSBDevicesMap [aIndex];
}
{
}
void VBoxUSBMenu::processAboutToShow()
{
clear();
if (isUSBEmpty)
{
setItemEnabled (USBDevicesMenuNoDevicesId, false);
}
else
{
{
/* check if created item was alread attached to this session */
{
}
}
}
}
{
/* the <no available devices> item is highlighted */
if (aIndex == USBDevicesMenuNoDevicesId)
{
tr ("No supported devices connected to the host PC",
"USB device tooltip"));
return;
}
/* if null then some other item but a USB device is highlighted */
{
return;
}
}
/**
*/
{
/* this menu works only with toggle action */
this, SLOT (processAboutToShow()));
this, SLOT (processActivated (int)));
}
void VBoxSwitchMenu::processAboutToShow()
{
clear();
}
{
}