VBoxGlobal.h revision 7d608a79e87ea3c381c3179ad58d902ee0b1b7a2
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * VBox frontends: Qt GUI ("VirtualBox"):
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * VBoxGlobal class declaration
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * available from http://www.virtualbox.org. This file is free software;
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * you can redistribute it and/or modify it under the terms of the GNU
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * General Public License as published by the Free Software Foundation,
c1e935608e3d55b6e5465b48d26b99dca51d742fvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
c1e935608e3d55b6e5465b48d26b99dca51d742fvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
c1e935608e3d55b6e5465b48d26b99dca51d742fvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
c1e935608e3d55b6e5465b48d26b99dca51d742fvboxsync * If you received this file as part of a commercial VirtualBox
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * distribution, then only the terms of your commercial VirtualBox
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * license agreement apply instead of the previous paragraph.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync// Auxiliary types
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync////////////////////////////////////////////////////////////////////////////////
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync/** Simple media descriptor type. */
9894b4a01ed8e1a02faf20e1a2673c3d58fdbc4cvboxsync VBoxMedia() : type (VBoxDefs::InvalidType), status (Ok) {}
9894b4a01ed8e1a02faf20e1a2673c3d58fdbc4cvboxsync VBoxMedia (const CUnknown &d, VBoxDefs::DiskType t, Status s)
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync// VirtualBox callback events
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync////////////////////////////////////////////////////////////////////////////////
89835f64f799888da0c5a27d8cb1d29b9ddd78f4vboxsync VBoxMachineStateChangeEvent (const QUuid &aId, CEnums::MachineState aState)
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType)
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineDataChangeEventType)
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync VBoxMachineRegisteredEvent (const QUuid &aId, bool aRegistered)
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync : QEvent ((QEvent::Type) VBoxDefs::MachineRegisteredEventType)
3755b95fd0146c349e04e3ccbbf758967d4f57cdvboxsync VBoxSessionStateChangeEvent (const QUuid &aId, CEnums::SessionState aState)
f274d97ed83aeee7260c7f142230c310c411b197vboxsync : QEvent ((QEvent::Type) VBoxDefs::SessionStateChangeEventType)
b4ee030841e483516f370e864f794c63237afa61vboxsync VBoxSnapshotEvent (const QUuid &aMachineId, const QUuid &aSnapshotId,
5ab9cb7e6a2e3d7ef3523fee5c06deef41f3fb29vboxsync : QEvent ((QEvent::Type) VBoxDefs::SnapshotEventType)
74647afb83e15262e85f00a38b82cdf30b42a0e9vboxsync// VBoxGlobal
74647afb83e15262e85f00a38b82cdf30b42a0e9vboxsync////////////////////////////////////////////////////////////////////////////////
e7b0349acb19798b9ce339edfdf98c4c698d0b84vboxsync const VBoxGlobalSettings &settings() const { return gset; }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync const char *vmRenderModeStr() const { return vm_render_mode_str; }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync bool isDebuggerEnabled() const { return dbg_enabled; }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync bool isDebuggerVisibleAtStartup() const { return dbg_visible_at_startup; }
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync /* VBox enum to/from string/icon/color convertors */
3755b95fd0146c349e04e3ccbbf758967d4f57cdvboxsync int vmGuestOSTypeIndex (const CGuestOSType &type) const;
3755b95fd0146c349e04e3ccbbf758967d4f57cdvboxsync QPixmap vmGuestOSTypeIcon (const QString &type) const;
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync AssertMsg (pm, ("Icon for VM state %d must be defined", s));
d4da6b66b8ed77af031e028595fcea8fb1ed83advboxsync const QColor &toColor (CEnums::MachineState s) const
a7ff32e4a1fff63c1df8ce2bb11781e3f4d5cf0avboxsync AssertMsg (vm_state_color [s], ("No color for %d", s));
a7ff32e4a1fff63c1df8ce2bb11781e3f4d5cf0avboxsync return vm_state_color [s] ? *vm_state_color [s] : none;
2ae34fd3d9ff18cb1a73c19608637d31424ea17avboxsync AssertMsg (!machineStates [s].isNull(), ("No text for %d", s));
2ae34fd3d9ff18cb1a73c19608637d31424ea17avboxsync AssertMsg (!sessionStates [s].isNull(), ("No text for %d", s));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::DiskControllerType t) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!diskControllerTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!diskTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::HardDiskStorageType t) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!diskStorageTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!vrdpAuthTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::USBDeviceFilterAction t) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!usbFilterActionTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!clipboardTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::ClipboardMode toClipboardModeType (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync qFind (clipboardTypes.begin(), clipboardTypes.end(), s);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != clipboardTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::ClipboardMode (it - clipboardTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::VRDPAuthType toVRDPAuthType (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync qFind (vrdpAuthTypes.begin(), vrdpAuthTypes.end(), s);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::VRDPAuthType (it - vrdpAuthTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::USBDeviceFilterAction toUSBDevFilterAction (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync qFind (usbFilterActionTypes.begin(), usbFilterActionTypes.end(), s);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != usbFilterActionTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::USBDeviceFilterAction (it - usbFilterActionTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Similar to toString (CEnums::HardDiskType), but returns 'Differencing'
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * for normal hard disks that have a parent hard disk.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString hardDiskTypeString (const CHardDisk &aHD) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::DiskControllerType t, LONG d) const;
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!deviceTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::DeviceType toDeviceType (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != deviceTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::DeviceType (it - deviceTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!audioDriverTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::AudioDriverType toAudioDriverType (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync qFind (audioDriverTypes.begin(), audioDriverTypes.end(), s);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != audioDriverTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::AudioDriverType (it - audioDriverTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::NetworkAttachmentType t) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!networkAttachmentTypes [t].isNull(), ("No text for %d", t));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync CEnums::NetworkAttachmentType toNetworkAttachmentType (const QString &s) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync qFind (networkAttachmentTypes.begin(), networkAttachmentTypes.end(), s);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (it != networkAttachmentTypes.end(), ("No value for {%s}", s.latin1()));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return CEnums::NetworkAttachmentType (it - networkAttachmentTypes.begin());
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString toString (CEnums::USBDeviceState aState) const
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync AssertMsg (!USBDeviceStates [aState].isNull(), ("No text for %d", aState));
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /* details generators */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString details (const CHardDisk &aHD, bool aPredict = false);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString prepareFileNameForHTML (const QString &fn) const;
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /* VirtualBox helpers */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Returns a list of all currently registered media. This list is used
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * to globally track the accessiblity state of all media on a dedicated
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * thread. This the list is initially empty (before the first enumeration
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * process is started using #startEnumeratingMedia()).
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const VBoxMediaList ¤tMediaList() const { return media_list; }
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /** Returns true if the media enumeration is in progress. */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync bool isMediaEnumerationStarted() const { return media_enum_thread != NULL; }
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void removeMedia (VBoxDefs::DiskType, const QUuid &);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync bool findMedia (const CUnknown &, VBoxMedia &) const;
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /* various helpers */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /** @internal made public for internal purposes */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /* public static stuff */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static void loadLanguage (const QString &aLangId = QString::null);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char *aDisabled = 0,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char *aActive = 0);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QIconSet iconSetEx (const char *aNormal, const char *aSmallNormal,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char *aDisabled = 0, const char *aSmallDisabled = 0,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char *aActive = 0, const char *aSmallActive = 0);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QRect normalizeGeometry (const QRect &aRect, const QRect &aBoundRect,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync bool aCanResize = true);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static void centerWidget (QWidget *aWidget, QWidget *aRelative,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync bool aCanResize = true);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QString formatSize (Q_UINT64, int aMode = 0);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QString highlight (const QString &aStr, bool aToolTip = false);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QString getExistingDirectory (const QString &aDir, QWidget *aParent,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char *aName = 0,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QString getOpenFileName (const QString &, const QString &, QWidget*,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync const char*, const QString &,
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync static QString getFirstExistingDir (const QString &);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Emitted at the beginning of the enumeration process started
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * by #startEnumeratingMedia().
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Emitted when a new media item from the list has updated
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * its accessibility state.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void mediaEnumerated (const VBoxMedia &aMedia, int aIndex);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Emitted at the end of the enumeration process started
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * by #startEnumeratingMedia(). The @a aList argument is passed for
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * convenience, it is exactly the same as returned by #currentMediaList().
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void mediaEnumFinished (const VBoxMediaList &aList);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /** Emitted when a new media is added using #addMedia(). */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /** Emitted when the media is updated using #updateMedia(). */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /** Emitted when the media is removed using #removeMedia(). */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void mediaRemoved (VBoxDefs::DiskType, const QUuid &);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync /* signals emitted when the VirtualBox callback is called by the server
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * (not that currently these signals are emitted only when the application
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * is the in the VM selector mode) */
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void machineStateChanged (const VBoxMachineStateChangeEvent &e);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void machineDataChanged (const VBoxMachineDataChangeEvent &e);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void machineRegistered (const VBoxMachineRegisteredEvent &e);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync void sessionStateChanged (const VBoxSessionStateChangeEvent &e);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsyncinline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * USB Popup Menu class.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * This class provides the list of USB devices attached to the host.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * Enable/Disable Menu class.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync * This class provides enable/disable menu items.
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
f73d4f622845cf2471e94e6d1676a3e6ee1b9e68vboxsync#endif /* __VBoxGlobal_h__ */