VBoxGlobal.cpp revision 1910146bc46e3eee5b8668806da594107fe9aabf
#
undef BOOL /* typedef CARD8 BOOL in Xmd.h conflicts with #define BOOL PRBool * in COMDefs.h. A better fix would be to isolate X11-specific * stuff by placing XX* helpers below to a separate source file. */ #
else /* !RT_OS_WINDOWS */#
endif /* !RT_OS_WINDOWS *///#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. typedef long Q_LONG;
/* word up to 64 bit signed */ typedef unsigned long Q_ULONG;
/* word up to 64 bit unsigned */ ///////////////////////////////////////////////////////////////////////////// /** Constructs a regular enum event */ /** Constructs the last enum event */ /** Last enumerated medium (not valid when #last is true) */ /** 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 */ // VirtualBox callback class ///////////////////////////////////////////////////////////////////////////// // 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 /* it's a global extra data key someone wants to change */ /* try to set the global setting to check its syntax */ /* this is a known GUI property key */ /* disallow the change when there is an error*/ /* not interested in this key -- never disagree */ /* Default to true if it is an empty value */ /* Check for the currently running machine */ /* Default to true if it is an empty value */ #
endif /* VBOX_WITH_NEW_RUNTIME_CORE */ // 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) /** protects #OnExtraDataChange() */ //////////////////////////////////////////////////////////////////////////////// * 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. * Determines the rendering mode from the argument. Sets the appropriate * default rendering mode if the argumen is NULL. /* Quartz2DMode doesn't refresh correctly on 32-bit Snow Leopard, use image mode. */ // if ( RT_SUCCESS (RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szRelease, sizeof (szRelease))) // && !strncmp (szRelease, "10.", 3)) // mode = VBoxDefs::QImageMode; #
error "Cannot determine the default render mode!"//#if defined (VBOX_GUI_USE_QGL) // else if (::strcmp (aModeStr, "qgloverlay") == 0) // mode = VBoxDefs::QGLOverlayMode; * 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. ///////////////////////////////////////////////////////////////////////////// * 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: * if ( !VBoxGlobal::instance().isValid() ) * if ( !vboxGlobal().isValid() ) * @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 * #vmStateText, #vmTypeIcon, #vmTypeText, #vmTypeTextList, #vmTypeFromText. /* check that a QApplication instance is created */ /* add our cleanup handler to the list of Qt post routines */ * Sets the new global settings and saves them to the VirtualBox server. /* 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(). */ * Returns a reference to the main VBox VM Selector window. * The reference is valid until application termination. * There is only one such a window per VirtualBox application. (
"Must NOT be a VM console process"));
* 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 * 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. (
"Must be a VM console process"));
* 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 * Gets a value from the custom .ini file * Returns true if the current instance a systray menu only (started with * Spawns a new selector window (process). /* Get the path to the executable. */ LogRel((
"Systray: Failed to start new selector window! Path=%s, rc=%Rrc\n",
path,
rc));
* Tries to install the tray icon using the current instance (singleton). * Returns true if this instance is the tray icon, false if not. /* 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? */ /* Get the path to the executable. */ const char *
args[] = {
path,
"-systray", 0 };
#
ifdef RT_OS_WINDOWS /** @todo drop this once the RTProcCreate bug has been fixed */ LogRel((
"Systray: Failed to start systray window! Path=%s, rc=%Rrc\n",
path,
rc));
// 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. */ * Returns the list of few guest OS types, queried from * IVirtualBox corresponding to every family id. * Returns the list of all guest OS types, queried from * IVirtualBox corresponding to passed family id. * Returns the icon corresponding to the given guest OS type id. * 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. * Returns the description corresponding to the given guest OS type id. * Returns a string representation of the given channel number on the given storage bus. * Complementary to #toStorageChannel (KStorageBus, const QString &) const. * Returns a channel number on the given storage bus corresponding to the given string representation. * Complementary to #toString (KStorageBus, LONG) const. * 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. * 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. * 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. * Returns a StorageSlot based on the given device of the given channel on the given storage bus. * Complementary to #toFullString (StorageSlot) const. * Returns the list of all device types (VirtualBox::DeviceType COM enum). /* must not contain an element with IRQ=0 and IOBase=0 used to cause * toCOMPortName() to return the "User-defined" string for these values. */ /* 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"). * Returns the list of the standard LPT port names (i.e. "LPTx"). * 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). * 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). * 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"). * 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"). * 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 * @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 */ * Returns the details of the given USB device as a single-line string. tr (
"Unknown device %1:%2",
"USB device details")
* 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")
tip +=
QString (
tr (
"<br><nobr>Serial No. %1</nobr>",
"USB device tooltip"))
/* add the state field if it's a host USB device */ tip +=
QString (
tr (
"<br><nobr>State: %1</nobr>",
"USB device tooltip"))
* Returns the multi-line description of the given USB filter tip +=
tr (
"<nobr>Vendor ID: %1</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Product ID: %2</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Revision: %3</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Product: %4</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Manufacturer: %5</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Serial No.: %1</nobr>",
"USB filter tooltip")
tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>Port: %1</nobr>",
"USB filter tooltip")
/* add the state field if it's a host USB device */ tip +=
tip.
isEmpty() ?
"":
"<br/>" +
tr (
"<nobr>State: %1</nobr>",
"USB filter tooltip")
* 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. "<table border=0 cellspacing=1 cellpadding=0>%1</table>";
"<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>" "<tr><td colspan=3><font size=1> </font></td></tr>";
"<tr><td width=22 rowspan=%1 align=left><img src='%2'></td>" "<td colspan=3><!-- %3 --><b><nobr>%4</nobr></b></td></tr>" "<tr><td colspan=3><font size=1> </font></td></tr>";
"<tr><td width=40%><nobr><i>%1</i></nobr></td><td/><td/></tr>";
"<tr><td width=40%><nobr>%1:</nobr></td><td/><td>%2</td></tr>";
"<tr><td width=40%><nobr>%1</nobr></td><td/><td/></tr>";
/* Compose details report */ .
arg (
":/machine_16px.png",
/* icon */ tr (
"General",
"details report"),
/* title */ /* BIOS Settings holder */ ?
tr (
"Enabled",
"details report (ACPI)")
:
tr (
"Disabled",
"details report (ACPI)");
?
tr (
"Enabled",
"details report (IO APIC)")
:
tr (
"Disabled",
"details report (IO APIC)");
?
tr (
"Enabled",
"details report (PAE/NX)")
:
tr (
"Disabled",
"details report (PAE/NX)");
#
endif /* VBOX_WITH_FULL_DETAILS_REPORT */ ?
tr (
"Enabled",
"details report (Nested Paging)")
:
tr (
"Disabled",
"details report (Nested Paging)");
tr (
"<nobr>%1 MB</nobr>",
"details report"))
tr (
"<nobr>%1</nobr>",
"details report"))
#
endif /* VBOX_WITH_FULL_DETAILS_REPORT */#
endif /* VBOX_WITH_FULL_DETAILS_REPORT */ .
arg (
":/chipset_16px.png",
/* icon */ tr (
"System",
"details report"),
/* title */ /* Rows including section header and footer */ ?
tr (
"Enabled",
"details report (3D Acceleration)")
:
tr (
"Disabled",
"details report (3D Acceleration)");
.
arg (
tr (
"Video Memory",
"details report"),
tr (
"<nobr>%1 MB</nobr>",
"details report"))
.
arg (
tr (
"3D Acceleration",
"details report"),
acc3d);
?
tr (
"Enabled",
"details report (2D Video Acceleration)")
:
tr (
"Disabled",
"details report (2D Video Acceleration)");
.
arg (
tr (
"Remote Display Server Port",
"details report (VRDP Server)"))
.
arg (
tr (
"Remote Display Server",
"details report (VRDP Server)"))
.
arg (
tr (
"Disabled",
"details report (VRDP Server)"));
.
arg (
":/vrdp_16px.png",
/* icon */ tr (
"Display",
"details report"),
/* title */ /* Rows including section header and footer */ /* Append 'device slot name' with 'device type name' for CD/DVD devices only */ .
arg (
tr (
"Not Attached",
"details report (Storage)"));
.
arg (
":/attachment_16px.png",
/* icon */ tr (
"Storage",
"details report"),
/* title */ .
arg (
tr (
"Host Driver",
"details report (audio)"),
.
arg (
tr (
"Controller",
"details report (audio)"),
.
arg (
tr (
"Disabled",
"details report (audio)"));
.
arg (
":/sound_16px.png",
/* icon */ tr (
"Audio",
"details report"),
/* title */ int rows =
2;
/* including section header and footer */ /* don't use the adapter type string for types that have .
arg (
tr (
"Adapter %1",
"details report (network)")
.
arg (
tr (
"Disabled",
"details report (network)"));
.
arg (
":/nw_16px.png",
/* icon */ tr (
"Network",
"details report"),
/* title */ int rows =
2;
/* including section header and footer */ .
arg (
tr (
"Port %1",
"details report (serial ports)")
.
arg (
tr (
"Disabled",
"details report (serial ports)"));
.
arg (
":/serial_port_16px.png",
/* icon */ "#serialPorts",
/* link */ tr (
"Serial Ports",
"details report"),
/* title */ int rows =
2;
/* including section header and footer */ .
arg (
tr (
"Port %1",
"details report (parallel ports)")
.
arg (
tr (
"Disabled",
"details report (parallel ports)"));
.
arg (
":/parallel_port_16px.png",
/* icon */ "#parallelPorts",
/* link */ tr (
"Parallel Ports",
"details report"),
/* title */ /* the USB controller may be unavailable (i.e. in VirtualBox OSE) */ .
arg (
tr (
"Device Filters",
"details report (USB)"),
tr (
"%1 (%2 active)",
"details report (USB)")
.
arg (
tr (
"Disabled",
"details report (USB)"));
.
arg (
":/usb_16px.png",
/* icon */ tr (
"USB",
"details report"),
/* title */ .
arg (
tr (
"Shared Folders",
"details report (shared folders)"))
.
arg (
tr (
"None",
"details report (shared folders)"));
.
arg (
":/shared_folder_16px.png",
/* icon */ tr (
"Shared Folders",
"details report"),
/* title */ /* The format is <system>.<bitness> */ /* Add more system information */ else /** @todo Windows Server 2008 == vista? Probably not... */ /* Use RTSystemQueryOSInfo. */ /* get the apps doc path */ /* 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. */ /* If there wasn't a localized version of the currently selected language, * search for the generic one. */ /* Check the version again. */ /* compose the latest license file full path */ /* check for the agreed license version */ #
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 aExisting @c true to open an existing session with the machine * which is already running, @c false to open a new direct /* 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. */ * Starts a machine with the given ID. * 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. /* Search for a proper alphabetic position */ /* Adjust the first item if inserted before it */ * Appends the given list of hard disks and all their children to the media list. * For using with VBoxGlobal::startEnumeratingMedia() only. /* First pass: Add siblings sorted */ /* Search for a proper alphabetic position */ /* Adjust the first item if inserted before it */ /* Second pass: Add children */ ++
it;
/* go to the next sibling before inserting children */ * Starts a thread that asynchronously enumerates all currently registered * 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: * <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 CD/DVD images.</li> * <li>All Floppy images.</li> * Note that #mediumEnumerated() signals are emitted in the same order as * @sa #currentMediaList() * @sa #isMediaEnumerationStarted() /* check if already started but not yet finished */ /* ignore the request during application termination */ /* composes a list of all currently known media & their children */ /* enumeration thread class */ LogFlow ((
"MediaEnumThread started.\n"));
/* Post the end-of-enumeration event */ LogFlow ((
"MediaEnumThread finished.\n"));
/* 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() * @sa #currentMediaList() /* Note that we maitain the same order here as #startEnumeratingMedia() */ /* skip null medium that come first */ /* break if met a parent's sibling (will insert before it) */ /* compare to aMedium's siblings */ /* skip null medium that come first */ /* skip HardDisks that come first */ /* skip DVD when inserting Floppy */ * Updates the medium in the current media list and emits the #mediumUpdated() * @sa #currentMediaList() * Removes the medium from the current media list and emits the #mediumRemoved() * @sa #currentMediaList() /* sanity: must be no children */ /* 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. * Searches for a VBoxMedum object with the given medium id attribute. * @return VBoxMedum if found which is invalid otherwise. * Returns the number of current running Fe/Qt4 main windows. * @return Number of running main windows. * Native language name of the currently installed translation. * Returns "English" if no translation is installed * or if the translation file is invalid. * 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 "Comma-separated list of translators");
* Changes the language of all global string constants according to the * currently installed translations tables. tr (
"Ignore",
"USBFilterActionType");
tr (
"Hold",
"USBFilterActionType");
tr (
"Null Audio Driver",
"AudioDriverType");
tr (
"Windows Multimedia",
"AudioDriverType");
tr (
"Solaris Audio",
"AudioDriverType");
tr (
"OSS Audio Driver",
"AudioDriverType");
tr (
"ALSA Audio Driver",
"AudioDriverType");
tr (
"Windows DirectSound",
"AudioDriverType");
tr (
"CoreAudio",
"AudioDriverType");
tr (
"PulseAudio",
"AudioDriverType");
tr (
"ICH AC97",
"AudioControllerType");
tr (
"SoundBlaster 16",
"AudioControllerType");
tr (
"PCnet-PCI II (Am79C970A)",
"NetworkAdapterType");
tr (
"PCnet-FAST III (Am79C973)",
"NetworkAdapterType");
tr (
"Intel PRO/1000 MT Desktop (82540EM)",
"NetworkAdapterType");
tr (
"Intel PRO/1000 T Server (82543GC)",
"NetworkAdapterType");
tr (
"Intel PRO/1000 MT Server (82545EM)",
"NetworkAdapterType");
tr (
"Paravirtualized Network (virtio-net)",
"NetworkAdapterType");
#
endif /* VBOX_WITH_VIRTIO */ tr (
"Not attached",
"NetworkAttachmentType");
tr (
"NAT",
"NetworkAttachmentType");
tr (
"Bridged Adapter",
"NetworkAttachmentType");
tr (
"Internal Network",
"NetworkAttachmentType");
tr (
"Host-only Adapter",
"NetworkAttachmentType");
tr (
"Disabled",
"ClipboardType");
tr (
"Host To Guest",
"ClipboardType");
tr (
"Guest To Host",
"ClipboardType");
tr (
"Bidirectional",
"ClipboardType");
tr (
"PIIX3",
"StorageControllerType");
tr (
"PIIX4",
"StorageControllerType");
tr (
"ICH6",
"StorageControllerType");
tr (
"AHCI",
"StorageControllerType");
tr (
"Lsilogic",
"StorageControllerType");
tr (
"BusLogic",
"StorageControllerType");
tr (
"I82078",
"StorageControllerType");
tr (
"LsiLogic SAS",
"StorageControllerType");
tr (
"Not supported",
"USBDeviceState");
tr (
"Unavailable",
"USBDeviceState");
tr (
"Busy",
"USBDeviceState");
tr (
"Available",
"USBDeviceState");
tr (
"Held",
"USBDeviceState");
tr (
"Captured",
"USBDeviceState");
/* 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. */ //////////////////////////////////////////////////////////////////////////////// * 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) * Loads the language by language ID. * @param aLangId Language ID in in form of xx_YY. QString::null means the * system default language. /* 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. */ /* the language ID should match the regexp completely */ /* 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 */ /* 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. */ /* load new language files */ /* we install the translator in any case: on failure, this will * activate an empty translator that will give us English /* Try to load the corresponding Qt translation */ /* 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. */ /* 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) */ /* Where are the docs located? */ /* 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 */ /* Fall back to the standard */ /* 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) */ * 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. /* 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 /* 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. bool /* aCanResize = true */)
/* Storing available horizontal sub-rectangles & vertical shifts */ /* Trying to find the appropriate place for window */ /* Move to appropriate vertical */ /* Search horizontal shift */ /* Shift across the horizontal direction */ /* Check the translated rectangle to feat the rules */ /* Resize window to feat desirable size * using max of available rectangles */ * Returns the flipped (transposed) region. * 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. * widgets with parents, what a shame. Use mapToGlobal() to workaround. */ /* 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(). */ /// @todo (r=dmik) not sure if we really need this /* sanity check for decoration frames. With embedding, we * might get extraordinary values */ /* On non-X11 platforms, the following would be enough instead of the // QRect geo = frameGeometry(); /* ensure the widget is within the available desktop area */ /* 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 * Returns the decimal separator for the current locale. * 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 QString (
"^(?:(?:(\\d+)(?:\\s?([KMGTP]?B))?)|(?:(\\d*)%1(\\d{1,2})(?:\\s?([KMGTP]B))))$")
* 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. * Formats the given @a aSize value in bytes to a human readable string * in form of <tt>####[.##] B|KB|MB|GB|TB|PB</tt>. * The @a aMode and @a aDecimal parameters are used for rounding the resulting * number when converting the size value to KB, MB, etc gives a fractional part: * <li>When \a aMode is FormatSize_Round, the result is rounded to the * closest number containing \a aDecimal decimal digits. * <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>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 * @param aSize Size value in bytes. * @param aMode Conversion mode. * @param aDecimal Number of decimal digits in result. * @return Human-readable size string. static const char *
Suffixes [] = {
"B",
"KB",
"MB",
"GB",
"TB",
"PB",
NULL };
/* check for the fractional part overflow due to rounding */ /* check if we've got 1024 XB after rounding and scale down if so */ * Returns the required video memory in bytes for the current desktop * resolution at maximum possible screen depth in bpp. /* Calculate summary required memory amount in bits */ 32 /* we will take the maximum possible bpp for now */ +
8 *
_1M /* current cache per screen - may be changed in future */) *
8 *
4096 /* adapter info */;
/* Translate value into megabytes with rounding to highest side */ /* Windows guests need offscreen VRAM too for graphics acceleration features. */ * Puts soft hyphens after every path component in the given file name. * @param aFileName File name (must be a full path name). // QString result = QDir::toNativeSeparators (fn); // result.replace ('/', "/<font color=red>­</font>"); // result.replace ('\\', "\\<font color=red>­</font>"); * Reformats the input string @a aStr so that: * - strings in single quotes will be put inside <nobr> and marked * - UUIDs be put inside <nobr> and marked * - 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>. /* replace special entities, '&' -- first! */ /* mark strings in single quotes with color */ /* mark UUIDs with color */ "(\\{[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 */ * Reformats the input string @a aStr so that: * - strings in single quotes will be put inside <nobr> and marked * - UUIDs be put inside <nobr> and marked * - 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). /* replace special entities, '&' -- first! */ /* mark strings in single quotes with bold style */ /* mark UUIDs with italic style */ "(\\{[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 */ * 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. /* QLocale return the right id only if the user select the format of the * language also. So we use our own implementation */ True /* only_if_exists */);
return reinterpret_cast <
char *> (
propVal);
/* always send as 32 bit for now */ * 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 * @return @c true on success and @c false otherwise. /* try to find the desktop ID using the NetWM property */ /* if the NetWM propery is not supported try to find the desktop * ID using the GNOME WM property */ * 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 * @param aText Menu item's text to remove the acceletaror mark from. * @return The resulting string. * Joins two pixmaps horizontally with 2px space between them and returns the * @param aPM1 Left pixmap. * @param aPM2 Right pixmap. * 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. /* Find the first children of aParent with the appropriate properties. * Please note that this call is recursivly. */ * 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>. /* Create a pair out of the backend description and all suffix's. */ /* Make sure the path exists */ /** additional video memory required for the best 2D support performance * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */ //////////////////////////////////////////////////////////////////////////////// * Opens the specified URL using OS/Desktop capabilities. * @param aURL URL to open * @return true on success and false otherwise /* Service-Client object */ /* Service-Server object */ * 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. /* Show the already opened registration dialog */ /* 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 */ * 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. /* Silently check in one day after current time-stamp */ 60 /* seconds */ *
1000 /* milliseconds */,
/* 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(); */ //////////////////////////////////////////////////////////////////////////////// /* the thread has posted the last message, wait for termination */ /* VirtualBox callback events */ /* 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) */ //////////////////////////////////////////////////////////////////////////////// /* COM for the main thread is initialized in main() */ /* create default non-null global settings */ /* try to load global settings */ /* Load the customized language as early as possible to get possible error /* Increase open Fe/Qt4 windows reference count. */ (
"Something went wrong with the window reference count!"));
/* Initialize guest OS Type list. */ /* 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. */ /* Append the 'Other' OS Type to the end of list. */ /* Fill in OS type icon dictionary. */ {
"Other",
":/os_other.png"},
{
"Netware",
":/os_netware.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"},
{
"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"},
{
"MacOS",
":/os_macosx.png"},
{
"MacOS_64",
":/os_macosx_64.png"},
/* fill in VM state icon map */ /* initialize state colors map */ /* process command line */ /* NOTE: the check here must match the corresponding check for the * otherwise there will be weird error messages. */ else if (!::
strcmp (
arg,
"--debug-command-line"))
else if (!::
strcmp (
arg,
"--debug-statistics"))
/* Not quite debug options, but they're only useful with the debugger bits. */ /** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */ /* setup the debugger gui. */ LogRel((
"Failed to load VBoxDbg, rc=%Rrc\n",
vrc));
* This method should be never called directly. It is called automatically * when the application terminates. /* Decrease open Fe/Qt4 windows reference count. */ (
"Something went wrong with the window reference count!"));
c = 0;
/* Clean up the mess. */ /* sVBoxGlobalInCleanup is true here, so just wait for the thread */ /* ensure CGuestOSType objects are no longer used */ /* media list contains a lot of CUUnknown, release them */ /* 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. */ /* COM for the main thread is shutdown in main() */ * 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. // connect (this, SIGNAL (hovered (QAction *)), // this, SLOT (processHighlighted (QAction *))); /* check if created item was alread attached to this session */ /* We provide dynamic tooltips for the usb devices */ /* this menu works only with toggle action */