VBoxGlobal.h revision e2de40b4b54a8ea51348be768ddcd3ecd753d7b6
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxGlobal class declaration
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __VBoxGlobal_h__
#define __VBoxGlobal_h__
#include "COMDefs.h"
#include "VBoxGlobalSettings.h"
#include "VBoxMedium.h"
/* Qt includes */
#include <QApplication>
#include <QLayout>
#include <QMenu>
#include <QStyle>
#include <QProcess>
#include <QHash>
#ifdef Q_WS_X11
#endif
// VirtualBox callback events
////////////////////////////////////////////////////////////////////////////////
{
{}
const KMachineState state;
};
{
{}
};
{
{}
const bool registered;
};
{
{}
const KSessionState state;
};
{
{}
const QString snapshotId;
};
{
VBoxCanShowRegDlgEvent (bool aCanShow)
{}
const bool mCanShow;
};
{
VBoxCanShowUpdDlgEvent (bool aCanShow)
{}
const bool mCanShow;
};
{
{}
};
#ifdef VBOX_GUI_WITH_SYSTRAY
{
{}
const int mCount;
};
{
VBoxCanShowTrayIconEvent (bool aCanShow)
{}
const bool mCanShow;
};
{
VBoxShowTrayIconEvent (bool aShow)
{}
const bool mShow;
};
{
VBoxChangeTrayIconEvent (bool aChanged)
{}
const bool mChanged;
};
#endif
{
{}
const bool mChanged;
};
{
int aTimeout = 5000
/* wait for data maximum 5 seconds */)
{
/* Why is it really needed is because of Qt4.3 bug with QProcess.
* This bug is about QProcess sometimes (~70%) do not receive
* notification about process was finished, so this makes
* 'bool QProcess::waitForFinished (int)' block the GUI thread and
* never dismissed with 'true' result even if process was really
* started&finished. So we just waiting for some information
* on process output and destroy the process with force. Due to
* QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
* we have to change process state to QProcess::NotRunning. */
if (firstShotReady)
#ifdef Q_WS_X11
int status;
#endif
return result;
}
};
struct StorageSlot
{
StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {}
StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {}
StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; }
bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; }
bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; }
};
// VBoxGlobal class
////////////////////////////////////////////////////////////////////////////////
{
static VBoxGlobal &instance();
static QString qtRTVersionString();
static uint qtRTVersion();
static QString qtCTVersionString();
static uint qtCTVersion();
/* main window handle storage */
/* branding */
bool brandingIsActive (bool aForce = false);
#ifdef VBOX_GUI_WITH_SYSTRAY
bool isTrayMenu() const;
void setTrayMenu(bool aIsTrayMenu);
void trayIconShowSelector();
bool trayIconInstall();
#endif
const char *vmRenderModeStr() const { return vm_render_mode_str; }
#ifdef VBOX_WITH_DEBUGGER_GUI
bool isDebuggerEnabled() const { return mDbgEnabled; }
bool isDebuggerAutoShowEnabled() const { return mDbgAutoShow; }
bool isDebuggerAutoShowCommandLineEnabled() const { return mDbgAutoShowCommandLine; }
bool isDebuggerAutoShowStatisticsEnabled() const { return mDbgAutoShowStatistics; }
bool isStartPausedEnabled() const { return mStartPaused; }
#else
bool isDebuggerAutoShowEnabled() const { return false; }
bool isDebuggerAutoShowCommandLineEnabled() const { return false; }
bool isDebuggerAutoShowStatisticsEnabled() const { return false; }
bool isStartPausedEnabled() const { return false; }
#endif
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
return mMachineStates.value (s);
}
{
return mSessionStates.value (s);
}
/**
* Returns a string representation of the given KStorageBus enum value.
* Complementary to #toStorageBusType (const QString &) const.
*/
{
return mStorageBuses [aBus];
}
/**
* Returns a KStorageBus enum value corresponding to the given string
* representation. Complementary to #toString (KStorageBus) const.
*/
{
}
{
switch (aControllerType)
{
default:
}
return sb;
}
{
return mDiskTypes.value (t);
}
/**
* Similar to toString (KMediumType), but returns 'Differencing' for
* normal hard disks that have a parent.
*/
{
{
return mDiskTypes_Differencing;
}
}
{
return mVRDPAuthTypes.value (t);
}
{
return mPortModeTypes.value (t);
}
{
return mUSBFilterActionTypes.value (t);
}
{
return mClipboardTypes.value (t);
}
{
}
{
return mStorageControllerTypes.value (t);
}
{
}
{
}
{
}
{
}
{
return mDeviceTypes.value (t);
}
{
}
QStringList deviceTypeStrings() const;
{
return mAudioDriverTypes.value (t);
}
{
}
{
return mAudioControllerTypes.value (t);
}
{
}
{
return mNetworkAdapterTypes.value (t);
}
{
}
{
return mNetworkAttachmentTypes.value (t);
}
{
}
{
}
QStringList COMPortNames() const;
QStringList LPTPortNames() const;
{
}
/* details generators */
/* VirtualBox helpers */
double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;
bool showVirtualBoxLicense();
#endif
/** Shortcut to openSession (aId, true). */
void startEnumeratingMedia();
/**
* Returns a list of all currently registered media. This list is used to
* globally track the accessiblity state of all media on a dedicated thread.
*
* Note that the media list is initially empty (i.e. before the enumeration
* process is started for the first time using #startEnumeratingMedia()).
* See #startEnumeratingMedia() for more information about how meida are
* sorted in the returned list.
*/
/** Returns true if the media enumeration is in progress. */
void addMedium (const VBoxMedium &);
void updateMedium (const VBoxMedium &);
/** Compact version of #findMediumTo(). Asserts if not found. */
{
AssertFailed();
return medium;
}
int mainWindowCount();
/* various helpers */
QString languageName() const;
QString languageCountry() const;
QString languageNameEnglish() const;
QString languageCountryEnglish() const;
QString languageTranslators() const;
void retranslateUi();
/** @internal made public for internal purposes */
void cleanup();
/* public static stuff */
static void adoptLabelPixmap (QLabel *);
static QString languageId();
const char *aDisabledOff = NULL,
const char *aActiveOff = NULL);
const char *aNormal, const char *aSmallNormal,
const char *aSmallDisabled = NULL,
const char *aSmallActive = NULL);
bool aCanResize = true);
bool aCanResize = true);
bool aCanResize = true);
static QChar decimalSep();
static QString sizeRegexp();
static QString systemLanguageId();
const char *aClassName = NULL,
bool aRecursive = false);
/* Qt 4.2.0 support function */
{
#if QT_VERSION < 0x040300
/* Deprecated since > 4.2 */
#else
/* New since > 4.2 */
#endif
}
static QString documentsPath();
#ifdef VBOX_WITH_VIDEOHWACCEL
static bool isAcceleration2DVideoAvailable();
/** additional video memory required for the best 2D support performance
* total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
static quint64 required2DOffscreenVideoMemory();
#endif
/**
* Emitted at the beginning of the enumeration process started by
* #startEnumeratingMedia().
*/
void mediumEnumStarted();
/**
* Emitted when a new medium item from the list has updated its
* accessibility state.
*/
/**
* Emitted at the end of the enumeration process started by
* #startEnumeratingMedia(). The @a aList argument is passed for
* convenience, it is exactly the same as returned by #currentMediaList().
*/
/** Emitted when a new media is added using #addMedia(). */
void mediumAdded (const VBoxMedium &);
/** Emitted when the media is updated using #updateMedia(). */
void mediumUpdated (const VBoxMedium &);
/** Emitted when the media is removed using #removeMedia(). */
/* signals emitted when the VirtualBox callback is called by the server
* (note that currently these signals are emitted only when the application
* is the in the VM selector mode) */
void machineStateChanged (const VBoxMachineStateChangeEvent &e);
void machineDataChanged (const VBoxMachineDataChangeEvent &e);
void machineRegistered (const VBoxMachineRegisteredEvent &e);
void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
void snapshotChanged (const VBoxSnapshotEvent &e);
#ifdef VBOX_GUI_WITH_SYSTRAY
void mainWindowCountChanged (const VBoxMainWindowCountChangeEvent &e);
void trayIconCanShow (const VBoxCanShowTrayIconEvent &e);
void trayIconShow (const VBoxShowTrayIconEvent &e);
void trayIconChanged (const VBoxChangeTrayIconEvent &e);
#endif
void dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &e);
void canShowRegDlg (bool aCanShow);
void canShowUpdDlg (bool aCanShow);
void showRegistrationDialog (bool aForce = true);
void showUpdateDialog (bool aForce = true);
void perDayNewVersionNotifier();
VBoxGlobal();
~VBoxGlobal();
void init();
bool mValid;
#ifdef VBOX_WITH_REGISTRATION
#endif
#ifdef VBOX_GUI_WITH_SYSTRAY
bool mIncreasedWindowCounter : 1;
#endif
const char * vm_render_mode_str;
#ifdef VBOX_WITH_DEBUGGER_GUI
/** Whether the debugger should be accessible or not.
* Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.
* VBOX_GUI_DBG_AUTO_SHOW to enable. */
bool mDbgEnabled;
/** Whether to show the debugger automatically with the console.
* Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */
bool mDbgAutoShow;
/** Whether to show the command line window when mDbgAutoShow is set. */
bool mDbgAutoShowCommandLine;
/** Whether to show the statistics window when mDbgAutoShow is set. */
bool mDbgAutoShowStatistics;
/** VBoxDbg module handle. */
/** Whether to start the VM in paused state or not. */
bool mStartPaused;
#endif
#if defined (Q_WS_WIN32)
#endif
};
// Helper classes
////////////////////////////////////////////////////////////////////////////////
/**
* Generic asyncronous event.
*
* This abstract class is intended to provide a conveinent way to execute
* code on the main GUI thread asynchronously to the calling party. This is
* done by putting necessary actions to the #handle() function in a subclass
* and then posting an instance of the subclass using #post(). The instance
* must be allocated on the heap using the <tt>new</tt> operation and will be
* automatically deleted after processing. Note that if you don't call #post()
* on the created instance, you have to delete it yourself.
*/
{
/**
* Worker function. Gets executed on the GUI thread when the posted event
* is processed by the main event loop.
*/
/**
* Posts this event to the main event loop.
* The caller loses ownership of this object after this method returns
* and must not delete the object.
*/
void post()
{
}
};
/**
* USB Popup Menu class.
* This class provides the list of USB devices attached to the host.
*/
{
VBoxUSBMenu (QWidget *);
void setConsole (const CConsole &);
void processAboutToShow();
};
/**
*/
{
void setToolTip (const QString &);
void processAboutToShow();
bool mInverted;
};
#endif /* __VBoxGlobal_h__ */