VBoxGlobal.h revision 1a9aff24299a7252e97aacbc1f9bd42663380155
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * VBox frontends: Qt GUI ("VirtualBox"):
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * VBoxGlobal class declaration
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * available from http://www.virtualbox.org. This file is free software;
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * you can redistribute it and/or modify it under the terms of the GNU
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * General Public License (GPL) as published by the Free Software
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * additional information or have any questions.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync/* Qt includes */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync// Auxiliary types
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync////////////////////////////////////////////////////////////////////////////////
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Media descriptor for the GUI.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Maintains the results of the last state (accessibility) check and precomposes
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * string parameters such as location, size which can be used in various GUI
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * controls.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Many getter methods take the boolean @a aNoDiffs argument. Unless explicitly
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * stated otherwise, this argument, when set to @c true, will cause the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * corresponding property of this object's root medium to be returned instead of
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * its own one. This is useful when hard disk media is represented in the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * user-friendly "don't show diffs" mode. For non-hard disk media, the value of
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * this argument is irrelevant because the root object for such medium is
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * the medium itself.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Note that this class "abuses" the KMediaState_NotCreated state value to
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * indicate that the accessibility check of the given medium (see
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * #blockAndQueryState()) has not been done yet and therefore some parameters
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * such as #size() are meaningless because they can be read only from the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * accessible medium. The real KMediaState_NotCreated state is not necessary
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * because this class is only used with created (existing) media.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Creates a null medium descriptor which is not associated with any medium.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * The state field is set to KMediaState_NotCreated.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Creates a media descriptor associated with the given medium.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * The state field remain KMediaState_NotCreated until #blockAndQueryState()
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * is called. All precomposed strings are filled up by implicitly calling
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * #refresh(), see the #refresh() details for more info.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * One of the hardDisk, dvdImage, or floppyImage members is assigned from
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * aMedium according to aType. @a aParent must be always NULL for non-hard
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * disk media.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Similar to the other non-null constructor but sets the media state to
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * @a aState. Suitable when the media state is known such as right after
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * creation.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Media state. In "don't show diffs" mode, this is the worst state (in
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * terms of inaccessibility) detected on the given hard disk chain.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString lastAccessError() const { return mLastAccessError; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Result of the last blockAndQueryState() call. Will indicate an error and
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * contain a proper error info if the last state check fails. In "don't show
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * diffs" mode, this is the worst result (in terms of inaccessibility)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * detected on the given hard disk chain.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync const COMResult &result (bool aNoDiffs = false) const
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync const CHardDisk2 &hardDisk() const { return mHardDisk; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync const CDVDImage &dvdImage() const { return mDVDImage; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync const CFloppyImage2 &floppyImage() const { return mFloppyImage; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync { return aNoDiffs ? root().mLocation : mLocation; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString hardDiskFormat (bool aNoDiffs = false) const
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync { return aNoDiffs ? root().mHardDiskType : mHardDiskType; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync { return aNoDiffs ? root().mLogicalSize : mLogicalSize; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns @c true if this medium is read-only (either because it is
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Immutable or because it has child hard disks). Read-only media can only
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * be attached indirectly.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns @c true if this medium is attached to any VM (in the current
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * state or in a snapshot) in which case #usage() will contain a string with
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * comma-sparated VM names (with snapshot names, if any, in parenthesis).
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns @c true if this medium is attached to any VM in any snapshot.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * which case #usage() will contain a string with comma-sparated VM names.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync bool isUsedInSnapshots() const { return mIsUsedInSnapshots; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns @c true if this medium is attached to the given machine in the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * current state.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync bool isAttachedInCurStateTo (const QUuid &aMachineId) const
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync { return mCurStateMachineIds.indexOf (aMachineId) >= 0; }
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns a vector of IDs of all machines this medium is attached
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * to in their current state (i.e. excluding snapshots).
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Returns a parent medium. For non-hard disk media, this is always NULL.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString toolTip(bool aNoDiffs = false, bool aCheckRO = false) const;
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QPixmap icon (bool aNoDiffs = false, bool aCheckRO = false) const;
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Shortcut to <tt>#toolTip (aNoDiffs, true)</tt>. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString toolTipCheckRO (bool aNoDiffs = false) const
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Shortcut to <tt>#icon (aNoDiffs, true)</tt>. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString details (bool aNoDiffs = false, bool aPredictDiff = false,
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync bool aUseHTML = false) const;
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Shortcut to <tt>#details (aNoDiffs, aPredictDiff, true)</tt>. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Returns @c true if this media descriptor is a null object. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Used to override some attributes in the user-friendly "don't show diffs"
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync NoDiffs() : isSet (false), state (KMediaState_NotCreated) {}
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync// VirtualBox callback events
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync////////////////////////////////////////////////////////////////////////////////
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxMachineStateChangeEvent (const QUuid &aId, KMachineState aState)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxMachineRegisteredEvent (const QUuid &aId, bool aRegistered)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineRegisteredEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxSessionStateChangeEvent (const QUuid &aId, KSessionState aState)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::SessionStateChangeEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync VBoxSnapshotEvent (const QUuid &aMachineId, const QUuid &aSnapshotId,
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::SnapshotEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::CanShowRegDlgEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::CanShowUpdDlgEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::ChangeGUILanguageEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsyncclass VBoxMainWindowCountChangeEvent : public QEvent
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::MainWindowCountChangeEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::CanShowTrayIconEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::ShowTrayIconEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::TrayIconChangeEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync : QEvent ((QEvent::Type) VBoxDefs::ChangeDockIconUpdateEventType)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync static QByteArray singleShot (const QString &aProcessName,
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /* wait for data maximum 5 seconds */)
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /* Why is it really needed is because of Qt4.3 bug with QProcess.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * This bug is about QProcess sometimes (~70%) do not receive
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * notification about process was finished, so this makes
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * 'bool QProcess::waitForFinished (int)' block the GUI thread and
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * never dismissed with 'true' result even if process was really
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * started&finished. So we just waiting for some information
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * on process output and destroy the process with force. Due to
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * we have to change process state to QProcess::NotRunning. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync bool firstShotReady = process.waitForReadyRead (aTimeout);
#ifdef VBOX_GUI_WITH_SYSTRAY
bool isTrayMenu() const;
void trayIconShowSelector();
bool trayIconInstall();
#ifdef VBOX_WITH_DEBUGGER_GUI
bool isDebuggerAutoShowEnabled() const { return false; }
return mDiskTypes_Differencing;
bool aWithLinks);
double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
bool showVirtualBoxLicense();
{ checkForAutoConvertedSettings (true); }
void startEnumeratingMedia();
AssertFailed();
return medium;
int mainWindowCount();
void retranslateUi();
void cleanup();
bool aCanResize = true);
bool aCanResize = true);
bool aCanResize = true);
static QString getOpenFileName (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
bool aResolveSymLinks = true);
static QStringList getOpenFileNames (const QString &aStartWith, const QString &aFilters, QWidget *aParent,
bool aResolveSymLinks = true,
bool aSingleFile = false);
bool aRecursive = false);
void mediumEnumStarted();
#ifdef VBOX_GUI_WITH_SYSTRAY
void perDayNewVersionNotifier();
VBoxGlobal();
~VBoxGlobal();
void init();
bool mValid;
#ifdef VBOX_WITH_REGISTRATION
#ifdef VBOX_GUI_WITH_SYSTRAY
const char * vm_render_mode_str;
#ifdef VBOX_WITH_DEBUGGER_GUI
bool mDbgEnabled;
bool mDbgAutoShow;
#if defined (Q_WS_WIN32)
void post()
void processAboutToShow();
void processAboutToShow();
bool mInverted;