/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
C++ | 5033 lines | 3403 code | 611 blank | 1019 comment | 712 complexity | ccdf44c93e8f2b6eba376c330d717811 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- /* $Id$ */
- /** @file
- * VBox Qt GUI - VBoxGlobal class implementation.
- */
- /*
- * Copyright (C) 2006-2011 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
- /* Qt includes: */
- #include <QProgressDialog>
- #include <QLibraryInfo>
- #include <QFileDialog>
- #include <QToolTip>
- #include <QTranslator>
- #include <QDesktopWidget>
- #include <QDesktopServices>
- #include <QMutex>
- #include <QToolButton>
- #include <QProcess>
- #include <QThread>
- #include <QPainter>
- #include <QSettings>
- #include <QTimer>
- #include <QDir>
- #include <QLocale>
- #include <QNetworkProxy>
- #ifdef Q_WS_WIN
- # include <QEventLoop>
- #endif /* Q_WS_WIN */
- #ifdef Q_WS_X11
- # include <QTextBrowser>
- # include <QScrollBar>
- # include <QX11Info>
- #endif /* Q_WS_X11 */
- #ifdef VBOX_GUI_WITH_PIDFILE
- # include <QTextStream>
- #endif /* VBOX_GUI_WITH_PIDFILE */
- /* GUI includes: */
- #include "VBoxGlobal.h"
- #include "VBoxUtils.h"
- #include "UISelectorWindow.h"
- #include "UIMessageCenter.h"
- #include "QIMessageBox.h"
- #include "QIDialogButtonBox.h"
- #include "UIIconPool.h"
- #include "UIActionPoolSelector.h"
- #include "UIActionPoolRuntime.h"
- #include "UIExtraDataEventHandler.h"
- #include "QIFileDialog.h"
- #include "UINetworkManager.h"
- #include "UIUpdateManager.h"
- #include "UIMachine.h"
- #include "UISession.h"
- #include "UIConverter.h"
- #ifdef Q_WS_X11
- # include "UIHotKeyEditor.h"
- # ifndef VBOX_OSE
- # include "VBoxLicenseViewer.h"
- # endif /* VBOX_OSE */
- # include "VBoxX11Helper.h"
- #endif /* Q_WS_X11 */
- #ifdef Q_WS_MAC
- # include "VBoxUtils-darwin.h"
- # include "UIMachineWindowFullscreen.h"
- # include "UIMachineWindowSeamless.h"
- #endif /* Q_WS_MAC */
- #ifdef VBOX_WITH_VIDEOHWACCEL
- # include "VBoxFBOverlay.h"
- #endif /* VBOX_WITH_VIDEOHWACCEL */
- #ifdef VBOX_WITH_REGISTRATION
- # include "UIRegistrationWzd.h"
- #endif /* VBOX_WITH_REGISTRATION */
- #ifdef VBOX_GUI_WITH_SYSTRAY
- #include <iprt/process.h>
- #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 /* VBOX_GUI_WITH_SYSTRAY */
- /* COM includes: */
- #include "CMachine.h"
- #include "CSystemProperties.h"
- #include "CUSBDevice.h"
- #include "CUSBDeviceFilter.h"
- #include "CBIOSSettings.h"
- #include "CVRDEServer.h"
- #include "CStorageController.h"
- #include "CMediumAttachment.h"
- #include "CAudioAdapter.h"
- #include "CNetworkAdapter.h"
- #include "CSerialPort.h"
- #include "CParallelPort.h"
- #include "CUSBController.h"
- #include "CHostUSBDevice.h"
- #include "CMediumFormat.h"
- #include "CSharedFolder.h"
- /* Other VBox includes: */
- #include <iprt/asm.h>
- #include <iprt/ctype.h>
- #include <iprt/err.h>
- #include <iprt/param.h>
- #include <iprt/path.h>
- #include <iprt/env.h>
- #include <iprt/file.h>
- #include <iprt/ldr.h>
- #include <iprt/system.h>
- #include <iprt/stream.h>
- #include <VBox/vd.h>
- #include <VBox/sup.h>
- #include <VBox/com/Guid.h>
- #include <VBox/VBoxOGLTest.h>
- #ifdef Q_WS_X11
- #include <iprt/mem.h>
- #endif /* Q_WS_X11 */
- /* External includes: */
- #include <math.h>
- #ifdef Q_WS_WIN
- #include "shlobj.h"
- #endif /* Q_WS_WIN */
- #ifdef Q_WS_X11
- #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. */
- #include <X11/X.h>
- #include <X11/Xmd.h>
- #include <X11/Xlib.h>
- #include <X11/Xatom.h>
- #include <X11/extensions/Xinerama.h>
- #define BOOL PRBool
- #endif /* Q_WS_X11 */
- //#define VBOX_WITH_FULL_DETAILS_REPORT /* hidden for now */
- //#warning "port me: check this"
- /// @todo bird: Use (U)INT_PTR, (U)LONG_PTR, DWORD_PTR, or (u)intptr_t.
- #if defined(Q_OS_WIN64)
- typedef __int64 Q_LONG; /* word up to 64 bit signed */
- typedef unsigned __int64 Q_ULONG; /* word up to 64 bit unsigned */
- #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 */
- VBoxMediaEnumEvent (const UIMedium &aMedium,
- const VBoxMediaList::iterator &aIterator)
- : QEvent ((QEvent::Type) MediaEnumEventType)
- , mMedium (aMedium), mIterator (aIterator), mLast (false)
- {}
- /** Constructs the last enum event */
- VBoxMediaEnumEvent (const VBoxMediaList::iterator &aIterator)
- : QEvent ((QEvent::Type) MediaEnumEventType)
- , mIterator (aIterator), mLast (true)
- {}
- /** Last enumerated medium (not valid when #last is true) */
- const UIMedium mMedium;
- /* Iterator which points to the corresponding item in the GUI thread: */
- const VBoxMediaList::iterator mIterator;
- /** Whether this is the last event for the given enumeration or not */
- const bool mLast;
- };
- // 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()
- {
- Assert (!sVBoxGlobalInCleanup);
- sVBoxGlobalInCleanup = true;
- vboxGlobal().cleanup();
- }
- /** @internal
- *
- * Determines the rendering mode from the argument. Sets the appropriate
- * default rendering mode if the argument is NULL.
- */
- static RenderMode vboxGetRenderMode (const char *aModeStr)
- {
- RenderMode mode = InvalidRenderMode;
- #if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)
- mode = Quartz2DMode;
- # 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 = QImageMode;
- # endif
- #elif (defined (Q_WS_WIN32) || defined (Q_WS_PM) || defined (Q_WS_X11)) && defined (VBOX_GUI_USE_QIMAGE)
- mode = QImageMode;
- #elif defined (Q_WS_X11) && defined (VBOX_GUI_USE_SDL)
- mode = SDLMode;
- #elif defined (VBOX_GUI_USE_QIMAGE)
- mode = QImageMode;
- #else
- # error "Cannot determine the default render mode!"
- #endif
- if (aModeStr)
- {
- if (0) ;
- #if defined (VBOX_GUI_USE_QIMAGE)
- else if (::strcmp (aModeStr, "image") == 0)
- mode = QImageMode;
- #endif
- #if defined (VBOX_GUI_USE_SDL)
- else if (::strcmp (aModeStr, "sdl") == 0)
- mode = SDLMode;
- #endif
- #if defined (VBOX_GUI_USE_DDRAW)
- else if (::strcmp (aModeStr, "ddraw") == 0)
- mode = DDRAWMode;
- #endif
- #if defined (VBOX_GUI_USE_QUARTZ2D)
- else if (::strcmp (aModeStr, "quartz2d") == 0)
- mode = Quartz2DMode;
- #endif
- #if defined (VBOX_GUI_USE_QGLFB)
- else if (::strcmp (aModeStr, "qgl") == 0)
- mode = QGLMode;
- #endif
- //#if defined (VBOX_GUI_USE_QGL)
- // else if (::strcmp (aModeStr, "qgloverlay") == 0)
- // mode = QGLOverlayMode;
- //#endif
- }
- return mode;
- }
- /** @class VBoxGlobal
- *
- * The VBoxGlobal class encapsulates 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.
- */
- VBoxGlobal::VBoxGlobal()
- : mValid (false)
- , mSelectorWnd (NULL)
- , m_pVirtualMachine(0)
- , mMainWindow (NULL)
- #ifdef VBOX_WITH_REGISTRATION
- , mRegDlg (NULL)
- #endif
- #ifdef VBOX_GUI_WITH_SYSTRAY
- , mIsTrayMenu (false)
- , mIncreasedWindowCounter (false)
- #endif
- , mMediaEnumThread (NULL)
- , mIsKWinManaged (false)
- , mDisablePatm(false)
- , mDisableCsam(false)
- , mRecompileSupervisor(false)
- , mRecompileUser(false)
- , mWarpPct(100)
- , mVerString("1.0")
- , m3DAvailable(false)
- , mSettingsPwSet(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
- */
- VBoxGlobal &VBoxGlobal::instance()
- {
- static VBoxGlobal vboxGlobal_instance;
- if (!sVBoxGlobalInited)
- {
- /* check that a QApplication instance is created */
- if (qApp)
- {
- sVBoxGlobalInited = true;
- vboxGlobal_instance.init();
- /* add our cleanup handler to the list of Qt post routines */
- qAddPostRoutine (vboxGlobalCleanup);
- }
- else
- AssertMsgFailed (("Must construct a QApplication first!"));
- }
- return vboxGlobal_instance;
- }
- VBoxGlobal::~VBoxGlobal()
- {
- qDeleteAll (mOsTypeIcons);
- }
- /* static */
- QString VBoxGlobal::qtRTVersionString()
- {
- return QString::fromLatin1 (qVersion());
- }
- /* static */
- uint VBoxGlobal::qtRTVersion()
- {
- QString rt_ver_str = VBoxGlobal::qtRTVersionString();
- return (rt_ver_str.section ('.', 0, 0).toInt() << 16) +
- (rt_ver_str.section ('.', 1, 1).toInt() << 8) +
- rt_ver_str.section ('.', 2, 2).toInt();
- }
- /* static */
- QString VBoxGlobal::qtCTVersionString()
- {
- return QString::fromLatin1 (QT_VERSION_STR);
- }
- /* static */
- uint VBoxGlobal::qtCTVersion()
- {
- QString ct_ver_str = VBoxGlobal::qtCTVersionString();
- return (ct_ver_str.section ('.', 0, 0).toInt() << 16) +
- (ct_ver_str.section ('.', 1, 1).toInt() << 8) +
- ct_ver_str.section ('.', 2, 2).toInt();
- }
- QString VBoxGlobal::vboxVersionString() const
- {
- return mVBox.GetVersion();
- }
- QString VBoxGlobal::vboxVersionStringNormalized() const
- {
- return mVBox.GetVersionNormalized();
- }
- bool VBoxGlobal::isBeta() const
- {
- return mVBox.GetVersion().contains("BETA", Qt::CaseInsensitive);
- }
- /**
- * Sets the new global settings and saves them to the VirtualBox server.
- */
- bool VBoxGlobal::setSettings (VBoxGlobalSettings &gs)
- {
- gs.save (mVBox);
- if (!mVBox.isOk())
- {
- msgCenter().cannotSaveGlobalConfig (mVBox);
- return false;
- }
- /* We don't assign gs to our gset member here, because VBoxCallback
- * will update gset as necessary when new settings are successfully
- * sent to the VirtualBox server by gs.save(). */
- return true;
- }
- /**
- * Returns a reference to the main VBox VM Selector window.
- * The reference is valid until application termination.
- *
- * There is only one such a window per VirtualBox application.
- */
- UISelectorWindow &VBoxGlobal::selectorWnd()
- {
- AssertMsg (!vboxGlobal().isVMConsoleProcess(),
- ("Must NOT be a VM console process"));
- Assert (mValid);
- 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.
- */
- UISelectorWindow *w = new UISelectorWindow (&mSelectorWnd, 0);
- Assert (w == mSelectorWnd);
- NOREF(w);
- }
- return *mSelectorWnd;
- }
- bool VBoxGlobal::startMachine(const QString &strMachineId)
- {
- /* Some restrictions: */
- AssertMsg(mValid, ("VBoxGlobal is invalid"));
- AssertMsg(!m_pVirtualMachine, ("Machine already started"));
- /* Create VM session: */
- CSession session = vboxGlobal().openSession(strMachineId, KLockType_VM);
- if (session.isNull())
- return false;
- /* Start virtual machine: */
- UIMachine *pVirtualMachine = new UIMachine(&m_pVirtualMachine, session);
- Assert(pVirtualMachine == m_pVirtualMachine);
- Q_UNUSED(pVirtualMachine);
- return true;
- }
- UIMachine* VBoxGlobal::virtualMachine()
- {
- return m_pVirtualMachine;
- }
- QWidget* VBoxGlobal::vmWindow()
- {
- if (isVMConsoleProcess() && m_pVirtualMachine)
- return m_pVirtualMachine->mainWindow();
- return 0;
- }
- #ifdef VBOX_GUI_WITH_PIDFILE
- void VBoxGlobal::createPidfile()
- {
- if (!m_strPidfile.isEmpty())
- {
- qint64 pid = qApp->applicationPid();
- QFile file(m_strPidfile);
- if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
- {
- QTextStream out(&file);
- out << pid << endl;
- }
- else
- LogRel(("Failed to create pid file %s\n", m_strPidfile.toUtf8().constData()));
- }
- }
- void VBoxGlobal::deletePidfile()
- {
- if ( !m_strPidfile.isEmpty()
- && QFile::exists(m_strPidfile))
- QFile::remove(m_strPidfile);
- }
- #endif
- bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
- {
- if (aForce)
- return true;
- if (mBrandingConfig.isEmpty())
- {
- mBrandingConfig = QDir(QApplication::applicationDirPath()).absolutePath();
- mBrandingConfig += "/custom/custom.ini";
- }
- return QFile::exists (mBrandingConfig);
- }
- /**
- * Gets a value from the custom .ini file
- */
- QString VBoxGlobal::brandingGetKey (QString aKey)
- {
- QSettings s(mBrandingConfig, QSettings::IniFormat);
- return s.value(QString("%1").arg(aKey)).toString();
- }
- #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;
- }
- void VBoxGlobal::setTrayMenu(bool aIsTrayMenu)
- {
- mIsTrayMenu = aIsTrayMenu;
- }
- /**
- * Spawns a new selector window (process).
- */
- void VBoxGlobal::trayIconShowSelector()
- {
- /* Get the path to the executable. */
- char path[RTPATH_MAX];
- RTPathAppPrivateArch(path, RTPATH_MAX);
- size_t sz = strlen(path);
- path[sz++] = RTPATH_DELIMITER;
- path[sz] = 0;
- char *cmd = path + sz;
- sz = RTPATH_MAX - sz;
- int rc = 0;
- const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
- Assert(sz >= sizeof(VirtualBox_exe));
- strcpy(cmd, VirtualBox_exe);
- const char * args[] = {path, 0 };
- rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
- if (RT_FAILURE(rc))
- 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.
- */
- bool VBoxGlobal::trayIconInstall()
- {
- int rc = 0;
- QString strTrayWinID = mVBox.GetExtraData(GUI_TrayIconWinID);
- if (false == strTrayWinID.isEmpty())
- {
- /* Check if current tray icon is alive by writing some bogus value. */
- mVBox.SetExtraData(GUI_TrayIconWinID, "0");
- if (mVBox.isOk())
- {
- /* Current tray icon died - clean up. */
- mVBox.SetExtraData(GUI_TrayIconWinID, NULL);
- strTrayWinID.clear();
- }
- }
- /* Is there already a tray icon or is tray icon not active? */
- if ( (mIsTrayMenu == false)
- && (vboxGlobal().settings().trayIconEnabled())
- && (QSystemTrayIcon::isSystemTrayAvailable())
- && (strTrayWinID.isEmpty()))
- {
- /* Get the path to the executable. */
- char path[RTPATH_MAX];
- RTPathAppPrivateArch(path, RTPATH_MAX);
- size_t sz = strlen(path);
- path[sz++] = RTPATH_DELIMITER;
- path[sz] = 0;
- char *cmd = path + sz;
- sz = RTPATH_MAX - sz;
- const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
- Assert(sz >= sizeof(VirtualBox_exe));
- strcpy(cmd, VirtualBox_exe);
- const char * args[] = {path, "-systray", 0 };
- rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);
- if (RT_FAILURE(rc))
- {
- LogRel(("Systray: Failed to start systray window! Path=%s, rc=%Rrc\n", path, rc));
- return false;
- }
- }
- if (mIsTrayMenu)
- {
- // Use this selector for displaying the tray icon
- mVBox.SetExtraData(GUI_TrayIconWinID,
- QString("%1").arg((qulonglong)vboxGlobal().mainWindow()->winId()));
- /* The first process which can grab this "mutex" will win ->
- * It will be the tray icon menu then. */
- if (mVBox.isOk())
- {
- emit sigTrayIconShow(true);
- return true;
- }
- }
- return false;
- }
- #endif
- #ifdef Q_WS_X11
- QList<QRect> XGetDesktopList()
- {
- /* Prepare empty resulting list: */
- QList<QRect> result;
- /* Get current display: */
- Display* pDisplay = QX11Info::display();
- /* If it's a Xinerama desktop: */
- if (XineramaIsActive(pDisplay))
- {
- /* Reading Xinerama data: */
- int iScreens = 0;
- XineramaScreenInfo *pScreensData = XineramaQueryScreens(pDisplay, &iScreens);
- /* Fill resulting list: */
- for (int i = 0; i < iScreens; ++ i)
- result << QRect(pScreensData[i].x_org, pScreensData[i].y_org,
- pScreensData[i].width, pScreensData[i].height);
- /* Free screens data: */
- XFree(pScreensData);
- }
- /* Return resulting list: */
- return result;
- }
- QList<Window> XGetWindowIDList()
- {
- /* Get current display: */
- Display *pDisplay = QX11Info::display();
- /* Get virtual desktop window: */
- Window window = QX11Info::appRootWindow();
- /* Get 'client list' atom: */
- Atom propNameAtom = XInternAtom(pDisplay, "_NET_CLIENT_LIST", True /* only if exists */);
- /* Prepare empty resulting list: */
- QList<Window> result;
- /* If atom does not exists return empty list: */
- if (propNameAtom == None)
- return result;
- /* Get atom value: */
- Atom realAtomType = None;
- int iRealFormat = 0;
- unsigned long uItemsCount = 0;
- unsigned long uBytesAfter = 0;
- unsigned char *pData = 0;
- int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
- 0, 0x7fffffff /*LONG_MAX*/, False /* delete */,
- XA_WINDOW, &realAtomType, &iRealFormat,
- &uItemsCount, &uBytesAfter, &pData);
- /* If get property is failed return empty list: */
- if (rc != Success)
- return result;
- /* Fill resulting list with win ids: */
- Window *pWindowData = reinterpret_cast<Window*>(pData);
- for (ulong i = 0; i < uItemsCount; ++ i)
- result << pWindowData[i];
- /* Releasing resources: */
- XFree(pData);
- /* Return resulting list: */
- return result;
- }
- QList<ulong> XGetStrut(Window window)
- {
- /* Get current display: */
- Display *pDisplay = QX11Info::display();
- /* Get 'strut' atom: */
- Atom propNameAtom = XInternAtom(pDisplay, "_NET_WM_STRUT_PARTIAL", True /* only if exists */);
- /* Prepare empty resulting list: */
- QList<ulong> result;
- /* If atom does not exists return empty list: */
- if (propNameAtom == None)
- return result;
- /* Get atom value: */
- Atom realAtomType = None;
- int iRealFormat = 0;
- ulong uItemsCount = 0;
- ulong uBytesAfter = 0;
- unsigned char *pData = 0;
- int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
- 0, LONG_MAX, False /* delete */,
- XA_CARDINAL, &realAtomType, &iRealFormat,
- &uItemsCount, &uBytesAfter, &pData);
- /* If get property is failed return empty list: */
- if (rc != Success)
- return result;
- /* Fill resulting list with strut shifts: */
- ulong *pStrutsData = reinterpret_cast<ulong*>(pData);
- for (ulong i = 0; i < uItemsCount; ++ i)
- result << pStrutsData[i];
- /* Releasing resources: */
- XFree(pData);
- /* Return resulting list: */
- return result;
- }
- #endif /* ifdef Q_WS_X11 */
- const QRect VBoxGlobal::availableGeometry(int iScreen) const
- {
- /* Prepare empty result: */
- QRect result;
- #ifdef Q_WS_X11
- /* Get current display: */
- Display* pDisplay = QX11Info::display();
- /* Get current application desktop: */
- QDesktopWidget *pDesktopWidget = QApplication::desktop();
- /* If it's a virtual desktop: */
- if (pDesktopWidget->isVirtualDesktop())
- {
- /* If it's a Xinerama desktop: */
- if (XineramaIsActive(pDisplay))
- {
- /* Get desktops list: */
- QList<QRect> desktops = XGetDesktopList();
- /* Combine to get full virtual region: */
- QRegion virtualRegion;
- foreach (QRect desktop, desktops)
- virtualRegion += desktop;
- virtualRegion = virtualRegion.boundingRect();
- /* Remember initial virtual desktop: */
- QRect virtualDesktop = virtualRegion.boundingRect();
- //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: */
- result = desktops[iScreen];
- /* Feat available geometry of virtual desktop to respect all the struts: */
- QList<Window> list = XGetWindowIDList();
- for (int i = 0; i < list.size(); ++ i)
- {
- /* Get window: */
- Window wid = list[i];
- QList<ulong> struts = XGetStrut(wid);
- /* If window has strut: */
- if (struts.size())
- {
- ulong uLeftShift = struts[0];
- ulong uLeftFromY = struts[4];
- ulong uLeftToY = struts[5];
- ulong uRightShift = struts[1];
- ulong uRightFromY = struts[6];
- ulong uRightToY = struts[7];
- ulong uTopShift = struts[2];
- ulong uTopFromX = struts[8];
- ulong uTopToX = struts[9];
- ulong uBottomShift = struts[3];
- ulong uBottomFromX = struts[10];
- ulong uBottomToX = struts[11];
- if (uLeftShift)
- {
- QRect sr(QPoint(0, uLeftFromY),
- QSize(uLeftShift, uLeftToY - uLeftFromY + 1));
- //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)
- {
- QRect sr(QPoint(virtualDesktop.x() + virtualDesktop.width() - uRightShift, uRightFromY),
- QSize(virtualDesktop.x() + virtualDesktop.width(), uRightToY - uRightFromY + 1));
- //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)
- {
- QRect sr(QPoint(uTopFromX, 0),
- QSize(uTopToX - uTopFromX + 1, 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)
- {
- QRect sr(QPoint(uBottomFromX, virtualDesktop.y() + virtualDesktop.height() - uBottomShift),
- QSize(uBottomToX - uBottomFromX + 1, 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: */
- result = (virtualRegion & result).boundingRect();
- }
- }
- /* If result is still NULL: */
- if (result.isNull())
- {
- /* Use QT default functionality: */
- result = pDesktopWidget->availableGeometry(iScreen);
- }
- //AssertMsgFailed(("LOG... Final geometry: %dx%dx%dx%d\n", result.x(), result.y(), result.width(), result.height()));
- #else /* ifdef Q_WS_X11 */
- result = QApplication::desktop()->availableGeometry(iScreen);
- #endif /* ifndef Q_WS_X11 */
- return result;
- }
- /**
- * Returns the list of few guest OS types, queried from
- * IVirtualBox corresponding to every family id.
- */
- QList <CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const
- {
- QList <CGuestOSType> result;
- for (int i = 0 ; i < mFamilyIDs.size(); ++ i)
- result << mTypes [i][0];
- return result;
- }
- /**
- * Returns the list of all guest OS types, queried from
- * IVirtualBox corresponding to passed family id.
- */
- QList <CGuestOSType> VBoxGlobal::vmGuestOSTypeList (const QString &aFamilyId) const
- {
- AssertMsg (mFamilyIDs.contains (aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
- return mFamilyIDs.contains (aFamilyId) ?
- mTypes [mFamilyIDs.indexOf (aFamilyId)] : QList <CGuestOSType>();
- }
- /**
- * Returns the icon corresponding to the given guest OS type id.
- */
- QPixmap VBoxGlobal::vmGuestOSTypeIcon (const QString &aTypeId) const
- {
- static const QPixmap none;
- QPixmap *p = mOsTypeIcons.value (aTypeId);
- AssertMsg (p, ("Icon for type '%s' must be defined.", aTypeId.toLatin1().constData()));
- 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.
- */
- CGuestOSType VBoxGlobal::vmGuestOSType (const QString &aTypeId,
- const QString &aFamilyId /* = QString::null */) const
- {
- QList <CGuestOSType> list;
- if (mFamilyIDs.contains (aFamilyId))
- {
- list = mTypes [mFamilyIDs.indexOf (aFamilyId)];
- }
- else
- {
- for (int i = 0; i < mFamilyIDs.size(); ++ i)
- list += mTypes [i];
- }
- for (int j = 0; j < list.size(); ++ j)
- if (!list [j].GetId().compare (aTypeId))
- return list [j];
- AssertMsgFailed (("Type ID incorrect: '%s'.", aTypeId.toLatin1().constData()));
- return CGuestOSType();
- }
- /**
- * Returns the description corresponding to the given guest OS type id.
- */
- QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const
- {
- for (int i = 0; i < mFamilyIDs.size(); ++ i)
- {
- QList <CGuestOSType> list (mTypes [i]);
- for ( int j = 0; j < list.size(); ++ j)
- if (!list [j].GetId().compare (aTypeId))
- return list [j].GetDescription();
- }
- return QString::null;
- }
- struct PortConfig
- {
- const char *name;
- const ulong IRQ;
- const ulong IOBase;
- };
- static const PortConfig kComKnownPorts[] =
- {
- { "COM1", 4, 0x3F8 },
- { "COM2", 3, 0x2F8 },
- { "COM3", 4, 0x3E8 },
- { "COM4", 3, 0x2E8 },
- /* must not contain an element with IRQ=0 and IOBase=0 used to cause
- * toCOMPortName() to return the "User-defined" string for these values. */
- };
- static const PortConfig kLptKnownPorts[] =
- {
- { "LPT1", 7, 0x378 },
- { "LPT2", 5, 0x278 },
- { "LPT1", 2, 0x3BC },
- /* must not contain an element with IRQ=0 and IOBase=0 used to cause
- * toLPTPortName() to return the "User-defined" string for these values. */
- };
- /**
- * Similar to toString (KMediumType), but returns 'Differencing' for
- * normal hard disks that have a parent.
- */
- QString VBoxGlobal::mediumTypeString(const CMedium &medium) const
- {
- if (!medium.GetParent().isNull())
- {
- Assert(medium.GetType() == KMediumType_Normal);
- return mDiskTypes_Differencing;
- }
- return gpConverter->toString(medium.GetType());
- }
- /**
- * Returns the list of the standard COM port names (i.e. "COMx").
- */
- QStringList VBoxGlobal::COMPortNames() const
- {
- QStringList list;
- for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
- list << kComKnownPorts [i].name;
- return list;
- }
- /**
- * Returns the list of the standard LPT port names (i.e. "LPTx").
- */
- QStringList VBoxGlobal::LPTPortNames() const
- {
- QStringList list;
- for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
- list << kLptKnownPorts [i].name;
- 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).
- */
- QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const
- {
- for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
- if (kComKnownPorts [i].IRQ == aIRQ &&
- kComKnownPorts [i].IOBase == aIOBase)
- 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).
- */
- QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const
- {
- for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
- if (kLptKnownPorts [i].IRQ == aIRQ &&
- kLptKnownPorts [i].IOBase == aIOBase)
- 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").
- */
- bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ,
- ulong &aIOBase) const
- {
- for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
- if (strcmp (kComKnownPorts [i].name, aName.toUtf8().data()) == 0)
- {
- aIRQ = kComKnownPorts [i].IRQ;
- aIOBase = kComKnownPorts [i].IOBase;
- 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").
- */
- bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ,
- ulong &aIOBase) const
- {
- for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
- if (strcmp (kLptKnownPorts [i].name, aName.toUtf8().data()) == 0)
- {
- aIRQ = kLptKnownPorts [i].IRQ;
- aIOBase = kLptKnownPorts [i].IOBase;
- return true;
- }
- return false;
- }
- /**
- * Searches for the given hard disk in the list of known media descriptors and
- * calls UIMedium::details() on the found descriptor.
- *
- * If the requested 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 second 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 UIMedium::details()).
- */
- QString VBoxGlobal::details (const CMedium &aMedium, bool aPredictDiff, bool fUseHtml /* = true */)
- {
- CMedium cmedium (aMedium);
- UIMedium medium;
- if (!findMedium (cmedium, medium))
- {
- /* Medium may be new and not already in the media list, request refresh */
- startEnumeratingMedia();
- if (!findMedium (cmedium, medium))
- /* Medium might be deleted already, return null string */
- return QString();
- }
- return fUseHtml ? medium.detailsHTML (true /* aNoDiffs */, aPredictDiff) :
- medium.details(true /* aNoDiffs */, aPredictDiff);
- }
- /**
- * Returns the details of the given USB device as a single-line string.
- */
- QString VBoxGlobal::details (const CUSBDevice &aDevice) const
- {
- QString sDetails;
- if (aDevice.isNull())
- sDetails = tr("Unknown device", "USB device details");
- else
- {
- QString m = aDevice.GetManufacturer().trimmed();
- QString p = aDevice.GetProduct().trimmed();
- if (m.isEmpty() && p.isEmpty())
- {
- sDetails =
- tr ("Unknown device %1:%2", "USB device details")
- .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
- .arg (QString().sprintf ("%04hX", aDevice.GetProductId()));
- }
- else
- {
- if (p.toUpper().startsWith (m.toUpper()))
- sDetails = p;
- else
- sDetails = m + " " + p;
- }
- ushort r = aDevice.GetRevision();
- if (r != 0)
- sDetails += QString().sprintf (" [%04hX]", r);
- }
- return sDetails.trimmed();
- }
- /**
- * Returns the multi-line description of the given USB device.
- */
- QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const
- {
- QString tip =
- tr ("<nobr>Vendor ID: %1</nobr><br>"
- "<nobr>Product ID: %2</nobr><br>"
- "<nobr>Revision: %3</nobr>", "USB device tooltip")
- .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
- .arg (QString().sprintf ("%04hX", aDevice.GetProductId()))
- .arg (QString().sprintf ("%04hX", aDevice.GetRevision()));
- QString ser = aDevice.GetSerialNumber();
- if (!ser.isEmpty())
- tip += QString (tr ("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))
- .arg (ser);
- /* add the state field if it's a host USB device */
- CHostUSBDevice hostDev (aDevice);
- if (!hostDev.isNull())
- {
- tip += QString (tr ("<br><nobr>State: %1</nobr>", "USB device tooltip"))
- .arg (gpConverter->toString (hostDev.GetState()));
- }
- return tip;
- }
- /**
- * Returns the multi-line description of the given USB filter
- */
- QString VBoxGlobal::toolTip (const CUSBDeviceFilter &aFilter) const
- {
- QString tip;
- QString vendorId = aFilter.GetVendorId();
- if (!vendorId.isEmpty())
- tip += tr ("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip")
- .arg (vendorId);
- QString productId = aFilter.GetProductId();
- if (!productId.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product ID: %2</nobr>", "USB filter tooltip")
- .arg (productId);
- QString revision = aFilter.GetRevision();
- if (!revision.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Revision: %3</nobr>", "USB filter tooltip")
- .arg (revision);
- QString product = aFilter.GetProduct();
- if (!product.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product: %4</nobr>", "USB filter tooltip")
- .arg (product);
- QString manufacturer = aFilter.GetManufacturer();
- if (!manufacturer.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip")
- .arg (manufacturer);
- QString serial = aFilter.GetSerialNumber();
- if (!serial.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Serial No.: %1</nobr>", "USB filter tooltip")
- .arg (serial);
- QString port = aFilter.GetPort();
- if (!port.isEmpty())
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Port: %1</nobr>", "USB filter tooltip")
- .arg (port);
- /* add the state field if it's a host USB device */
- CHostUSBDevice hostDev (aFilter);
- if (!hostDev.isNull())
- {
- tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>State: %1</nobr>", "USB filter tooltip")
- .arg (gpConverter->toString (hostDev.GetState()));
- }
- 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.
- */
- QString VBoxGlobal::detailsReport (const CMachine &aMachine, bool aWithLinks)
- {
- /* 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>";
- const QString §ionTpl = aWithLinks ? sSectionHrefTpl : sSectionBoldTpl;
- /* Compose details report */
- QString report;
- /* General */
- {
- QString item = QString (sSectionItemTpl2).arg (tr ("Name", "details report"),
- aMachine.GetName())
- + QString (sSectionItemTpl2).arg (tr ("OS Type", "details report"),
- vmGuestOSTypeDescription (aMachine.GetOSTypeId()));
- report += sectionTpl
- .arg (2 + 2) /* rows */
- .arg (":/machine_16px.png", /* icon */
- "#general", /* link */
- tr ("General", "details report"), /* title */
- item); /* items */
- }
- /* System */
- {
- /* BIOS Settings holder */
- CBIOSSettings biosSettings = aMachine.GetBIOSSettings();
- /* System details row count: */
- int iRowCount = 2; /* Memory & CPU details rows initially. */
- /* Boot order */
- QString bootOrder;
- for (ulong i = 1; i <= mVBox.GetSystemProperties().GetMaxBootPosition(); ++ i)
- {
- KDeviceType device = aMachine.GetBootOrder (i);
- if (device == KDeviceType_Null)
- continue;
- if (!bootOrder.isEmpty())
- bootOrder += ", ";
- bootOrder += gpConverter->toString (device);
- }
- if (bootOrder.isEmpty())
- bootOrder = gpConverter->toString (KDeviceType_Null);
- iRowCount += 1; /* Boot-order row. */
- #ifdef VBOX_WITH_FULL_DETAILS_REPORT
- /* ACPI */
- QString acpi = biosSettings.GetACPIEnabled()
- ? tr ("Enabled", "details report (ACPI)")
- : tr ("Disabled", "details report (ACPI)");
- /* IO APIC */
- QString ioapic = biosSettings.GetIOAPICEnabled()
- ? tr ("Enabled", "details report (IO APIC)")
- : tr ("Disabled", "details report (IO APIC)");
- /* PAE/NX */
- QString pae = aMachine.GetCpuProperty(KCpuPropertyType_PAE)
- ? tr ("Enabled", "details report (PAE/NX)")
- : tr ("Disabled", "details report (PAE/NX)");
- iRowCount += 3; /* Full report rows. */
- #endif /* VBOX_WITH_FULL_DETAILS_REPORT */
- /* VT-x/AMD-V */
- QString virt = aMachine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled)
- ? tr ("Enabled", "details report (VT-x/AMD-V)")
- : tr ("Disabled", "details report (VT-x/AMD-V)");
- /* Nested Paging */
- QString nested = aMachine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging)
- ? tr ("Enabled", "details report (Nested Paging)")
- : tr ("Disabled", "details report (Nested Paging)");
- /* VT-x/AMD-V availability: */
- bool fVTxAMDVSupported = host().GetProcessorFeature(KProcessorFeature_HWVirtEx);
- if (fVTxAMDVSupported)
- iRowCount += 2; /* VT-x/AMD-V items. */
- QString item = QString (sSectionItemTpl2).arg (tr ("Base Memory", "details report"),
- tr ("<nobr>%1 MB</nobr>", "details report"))
- .arg (aMachine.GetMemorySize())
- + QString (sSectionItemTpl2).arg (tr ("Processor(s)", "details report"),
- tr ("<nobr>%1</nobr>", "details report"))
- .arg (aMachine.GetCPUCount())
- + QString (sSectionItemTpl2).arg (tr ("Execution Cap", "details report"),
- tr ("<nobr>%1%</nobr>", "details report"))
- .arg (aMachine.GetCPUExecutionCap())
- + QString (sSectionItemTpl2).arg (tr ("Boot Order", "details report"), bootOrder)
- #ifdef VBOX_WITH_FULL_DETAILS_REPORT
- + QString (sSectionItemTpl2).arg (tr ("ACPI", "details report"), acpi)
- + QString (sSectionItemTpl2).arg (tr ("IO APIC", "details report"), ioapic)
- + QString (sSectionItemTpl2).arg (tr ("PAE/NX", "details report"), pae)
- #endif /* VBOX_WITH_FULL_DETAILS_REPORT */
- ;
- if (fVTxAMDVSupported)
- item += QString (sSectionItemTpl2).arg (tr ("VT-x/AMD-V", "details report"), virt)
- + QString (sSectionItemTpl2).arg (tr ("Nested Paging", "details report"), nested);
- report += sectionTpl
- .arg (2 + iRowCount) /* rows */
- .arg (":/chipset_16px.png", /* icon */
- "#system", /* link */
- tr ("System", "details report"), /* title */
- item); /* items */
- }
- /* Display */
- {
- /* Rows including section header and footer */
- int rows = 2;
- /* Video tab */
- QString item = QString(sSectionItemTpl2)
- .arg(tr ("Video Memory", "details report"),
- tr ("<nobr>%1 MB</nobr>", "details report"))
- .arg(aMachine.GetVRAMSize());
- ++rows;
- int cGuestScreens = aMachine.GetMonitorCount();
- if (cGuestScreens > 1)
- {
- item += QString(sSectionItemTpl2)
- .arg(tr("Screens", "details report"))
- .arg(cGuestScreens);
- ++rows;
- }
- QString acc3d = is3DAvailable() && aMachine.GetAccelerate3DEnabled()
- ? tr ("Enabled", "details report (3D Acceleration)")
- : tr ("Disabled", "details report (3D Acceleration)");
- item += QString(sSectionItemTpl2)
- .arg(tr("3D Acceleration", "details report"), acc3d);
- ++rows;
- #ifdef VBOX_WITH_VIDEOHWACCEL
- QString acc2dVideo = aMachine.GetAccelerate2DVideoEnabled()
- ? tr ("Enabled", "details report (2D Video Acceleration)")
- : tr ("Disabled", "details report (2D Video Acceleration)");
- item += QString (sSectionItemTpl2)
- .arg (tr ("2D Video Acceleration", "details report"), acc2dVideo);
- ++ rows;
- #endif
- /* VRDP tab */
- CVRDEServer srv = aMachine.GetVRDEServer();
- if (!srv.isNull())
- {
- if (srv.GetEnabled())
- item += QString (sSectionItemTpl2)
- .arg (tr ("Remote Desktop Server Port", "details report (VRDE Server)"))
- .arg (srv.GetVRDEProperty("TCP/Ports"));
- else
- item += QString (sSectionItemTpl2)
- .arg (tr ("Remote Desktop Server", "details report (VRDE Server)"))
- .arg (tr ("Disabled", "details report (VRDE Server)"));
- ++ rows;
- }
- report += sectionTpl
- .arg (rows) /* rows */
- .arg (":/vrdp_16px.png", /* icon */
- "#display", /* link */
- tr ("Display", "details report"), /* title */
- item); /* items */
- }
- /* Storage */
- {
- /* Rows including section header and footer */
- int rows = 2;
- QString item;
- /* Iterate over the all machine controllers: */
- CStorageControllerVector controllers = aMachine.GetStorageControllers();
- for (int i = 0; i < controllers.size(); ++i)
- {
- /* Get current controller: */
- const CStorageController &controller = controllers[i];
- /* Add controller information: */
- QString strControllerName = QApplication::translate("UIMachineSettingsStorage", "Controller: %1");
- item += QString(sSectionItemTpl3).arg(strControllerName.arg(controller.GetName()));
- ++ rows;
- /* Populate sorted map with attachments information: */
- QMap<StorageSlot,QString> attachmentsMap;
- CMediumAttachmentVector attachments = aMachine.GetMediumAttachmentsOfController(controller.GetName());
- for (int j = 0; j < attachments.size(); ++j)
- {
- /* Get current attachment: */
- const CMediumAttachment &attachment = attachments[j];
- /* Prepare current storage slot: */
- StorageSlot attachmentSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice());
- /* Append 'device slot name' with 'device type name' for CD/DVD devices only: */
- QString strDeviceType = attachment.GetType() == KDeviceType_DVD ? tr("(CD/DVD)") : QString();
- if (!strDeviceType.isNull())
- strDeviceType.prepend(' ');
- /* Prepare current medium object: */
- const CMedium &medium = attachment.GetMedium();
- /* Prepare information about current medium & attachment: */
- QString strAttachmentInfo = !attachment.isOk() ? QString() :
- QString(sSectionItemTpl2)
- .arg(QString(" ") +
- gpConverter->toString(StorageSlot(controller.GetBus(),
- attachment.GetPort(),
- attachment.GetDevice())) + strDeviceType)
- .arg(details(medium, false));
- /* Insert that attachment into map: */
- if (!strAttachmentInfo.isNull())
- attachmentsMap.insert(attachmentSlot, strAttachmentInfo);
- }
- /* Iterate over the sorted map with attachments information: */
- QMapIterator<StorageSlot,QString> it(attachmentsMap);
- while (it.hasNext())
- {
- /* Add controller information: */
- it.next();
- item += it.value();
- ++rows;
- }
- }
- if (item.isNull())
- {
- item = QString (sSectionItemTpl1)
- .arg (tr ("Not Attached", "details report (Storage)"));
- ++ rows;
- }
- report += sectionTpl
- .arg (rows) /* rows */
- .arg (":/attachment_16px.png", /* icon */
- "#storage", /* link */
- tr ("Storage", "details report"), /* title */
- item); /* items */
- }
- /* Audio */
- {
- QString item;
- CAudioAdapter audio = aMachine.GetAudioAdapter();
- int rows = audio.GetEnabled() ? 3 : 2;
- if (audio.GetEnabled())
- item = QString (sSectionItemTpl2)
- .arg (tr ("Host Driver", "details report (audio)"),
- gpConverter->toString (audio.GetAudioDriver())) +
- QString…
Large files files are truncated, but you can click here to view the full file