UISession.h revision 5d96aa0d3ade93ae2970f61342432246c9842466
220N/A/** @file
220N/A *
220N/A * VBox frontends: Qt GUI ("VirtualBox"):
220N/A * UISession class declaration
220N/A */
220N/A
220N/A/*
220N/A * Copyright (C) 2010 Oracle Corporation
220N/A *
220N/A * This file is part of VirtualBox Open Source Edition (OSE), as
220N/A * available from http://www.virtualbox.org. This file is free software;
220N/A * you can redistribute it and/or modify it under the terms of the GNU
220N/A * General Public License (GPL) as published by the Free Software
220N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
220N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
220N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
220N/A */
220N/A
220N/A#ifndef ___UIConsole_h___
220N/A#define ___UIConsole_h___
220N/A
220N/A/* Global includes */
5680N/A#include <QObject>
220N/A#include <QCursor>
5680N/A
220N/A/* Local includes */
220N/A#include "COMDefs.h"
220N/A#include "UIMachineDefs.h"
220N/A
220N/A/* Global forwards */
220N/Aclass QMenu;
844N/Aclass QMenuBar;
844N/A#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
220N/A# ifdef Q_WS_MAC
220N/Astruct __siginfo;
2899N/Atypedef struct __siginfo siginfo_t;
2899N/A# else /* Q_WS_MAC */
5680N/Astruct siginfo;
5680N/Atypedef struct siginfo siginfo_t;
220N/A# endif /* !Q_WS_MAC */
514N/A#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
514N/A
514N/A/* Local forwards */
5123N/Aclass UIActionsPool;
5680N/Aclass UIFrameBuffer;
5680N/Aclass UIMachine;
5680N/Aclass UIMachineLogic;
5680N/Aclass UIMachineMenuBar;
5680N/A
5680N/A/* CConsole callback event types: */
5680N/Aenum UIConsoleEventType
5680N/A{
5123N/A UIConsoleEventType_MousePointerShapeChange = QEvent::User + 1,
220N/A UIConsoleEventType_MouseCapabilityChange,
220N/A UIConsoleEventType_KeyboardLedsChange,
5680N/A UIConsoleEventType_StateChange,
220N/A UIConsoleEventType_AdditionsStateChange,
5680N/A UIConsoleEventType_NetworkAdapterChange,
5680N/A /* Not used: UIConsoleEventType_SerialPortChange, */
5680N/A /* Not used: UIConsoleEventType_ParallelPortChange, */
5680N/A /* Not used: UIConsoleEventType_StorageControllerChange, */
220N/A UIConsoleEventType_MediumChange,
220N/A /* Not used: UIConsoleEventType_CPUChange, */
220N/A UIConsoleEventType_VRDEServerChange,
220N/A UIConsoleEventType_VRDEServerInfoChange,
220N/A UIConsoleEventType_USBControllerChange,
220N/A UIConsoleEventType_USBDeviceStateChange,
220N/A UIConsoleEventType_SharedFolderChange,
220N/A UIConsoleEventType_RuntimeError,
220N/A UIConsoleEventType_CanShowWindow,
220N/A UIConsoleEventType_ShowWindow,
1328N/A UIConsoleEventType_MAX
5074N/A};
220N/A
220N/Aclass UISession : public QObject
220N/A{
220N/A Q_OBJECT;
220N/A
220N/Apublic:
220N/A
220N/A /* Machine uisession constructor/destructor: */
220N/A UISession(UIMachine *pMachine, CSession &session);
220N/A virtual ~UISession();
220N/A
220N/A /* Common members: */
220N/A void powerUp();
220N/A
220N/A /* Common getters: */
220N/A CSession& session() { return m_session; }
220N/A KMachineState machineState() const { return m_machineState; }
220N/A UIActionsPool* actionsPool() const;
220N/A QWidget* mainMachineWindow() const;
220N/A UIMachineLogic* machineLogic() const;
3817N/A QMenu* newMenu(UIMainMenuType fOptions = UIMainMenuType_All);
3817N/A QMenuBar* newMenuBar(UIMainMenuType fOptions = UIMainMenuType_All);
3817N/A QCursor cursor() const { return m_cursor; }
3817N/A
3817N/A bool isSaved() const { return machineState() == KMachineState_Saved; }
3817N/A bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff ||
3817N/A machineState() == KMachineState_Saved ||
3817N/A machineState() == KMachineState_Teleported ||
3817N/A machineState() == KMachineState_Aborted; }
3817N/A bool isPaused() const { return machineState() == KMachineState_Paused ||
3817N/A machineState() == KMachineState_TeleportingPausedVM; }
3817N/A bool isRunning() const { return machineState() == KMachineState_Running ||
3817N/A machineState() == KMachineState_Teleporting ||
3817N/A machineState() == KMachineState_LiveSnapshotting; }
3817N/A bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
3817N/A bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRuntimeMediumsChanging; }
bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
bool isSeamlessModeRequested() const { return m_fIsSeamlessModeRequested; }
bool isAutoCaptureDisabled() const { return m_fIsAutoCaptureDisabled; }
/* Guest additions state getters: */
bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > AdditionsRunLevelType_None); }
bool isGuestSupportsGraphics() const { return isGuestAdditionsActive() && m_fIsGuestSupportsGraphics; }
bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
/* Keyboard getters: */
bool isNumLock() const { return m_fNumLock; }
bool isCapsLock() const { return m_fCapsLock; }
bool isScrollLock() const { return m_fScrollLock; }
uint numLockAdaptionCnt() const { return m_uNumLockAdaptionCnt; }
uint capsLockAdaptionCnt() const { return m_uCapsLockAdaptionCnt; }
/* Mouse getters: */
bool isMouseSupportsAbsolute() const { return m_fIsMouseSupportsAbsolute; }
bool isMouseSupportsRelative() const { return m_fIsMouseSupportsRelative; }
bool isMouseHostCursorNeeded() const { return m_fIsMouseHostCursorNeeded; }
bool isMouseCaptured() const { return m_fIsMouseCaptured; }
bool isMouseIntegrated() const { return m_fIsMouseIntegrated; }
bool isValidPointerShapePresent() const { return m_fIsValidPointerShapePresent; }
bool isHidingHostPointer() const { return m_fIsHidingHostPointer; }
/* Common setters: */
bool pause() { return setPause(true); }
bool unpause() { return setPause(false); }
bool setPause(bool fOn);
void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; }
void setSeamlessModeRequested(bool fIsSeamlessModeRequested) { m_fIsSeamlessModeRequested = fIsSeamlessModeRequested; }
void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled) { m_fIsAutoCaptureDisabled = fIsAutoCaptureDisabled; }
/* Keyboard setters: */
void setNumLockAdaptionCnt(uint uNumLockAdaptionCnt) { m_uNumLockAdaptionCnt = uNumLockAdaptionCnt; }
void setCapsLockAdaptionCnt(uint uCapsLockAdaptionCnt) { m_uCapsLockAdaptionCnt = uCapsLockAdaptionCnt; }
/* Mouse setters: */
void setMouseCaptured(bool fIsMouseCaptured) { m_fIsMouseCaptured = fIsMouseCaptured; }
void setMouseIntegrated(bool fIsMouseIntegrated) { m_fIsMouseIntegrated = fIsMouseIntegrated; }
#ifdef VBOX_WITH_VIDEOHWACCEL
/* return a persisted framebuffer for the given screen
* see comment below for the m_FrameBufferVector field */
UIFrameBuffer* frameBuffer(ulong screenId) const;
/* @return VINF_SUCCESS - on success
* VERR_INVALID_PARAMETER - if screenId is invalid */
int setFrameBuffer(ulong screenId, UIFrameBuffer* pFrameBuffer);
#endif
signals:
/* Console callback signals: */
void sigMousePointerShapeChange();
void sigMouseCapabilityChange();
void sigKeyboardLedsChange();
void sigMachineStateChange();
void sigAdditionsStateChange();
void sigNetworkAdapterChange(const CNetworkAdapter &networkAdapter);
void sigMediumChange(const CMediumAttachment &mediumAttachment);
void sigVRDEChange();
void sigUSBControllerChange();
void sigUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
void sigSharedFolderChange();
void sigRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
#ifdef RT_OS_DARWIN
void sigShowWindows();
#endif /* RT_OS_DARWIN */
/* Session signals: */
void sigMachineStarted();
public slots:
void sltInstallGuestAdditionsFrom(const QString &strSource);
private slots:
/* Close uisession handler: */
void sltCloseVirtualSession();
/* Console events slots */
void sltMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape);
void sltMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fNeedsHostCursor);
void sltKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock);
void sltStateChange(KMachineState state);
void sltAdditionsChange();
void sltVRDEChange();
private:
/* Private getters: */
UIMachine* uimachine() const { return m_pMachine; }
/* Prepare helpers: */
void prepareMenuPool();
void loadSessionSettings();
/* Cleanup helpers: */
void saveSessionSettings();
void cleanupMenuPool();
/* Common helpers: */
WId winId() const;
void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
void reinitMenuPool();
void preparePowerUp();
#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
static void signalHandlerSIGUSR1(int sig, siginfo_t *pInfo, void *pSecret);
#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
/* Private variables: */
UIMachine *m_pMachine;
CSession &m_session;
UIMachineMenuBar *m_pMenuPool;
#ifdef VBOX_WITH_VIDEOHWACCEL
/* When 2D is enabled we do not re-create Framebuffers. This is done
* 1. to avoid 2D command loss during the time slot when no framebuffer is
* assigned to the display
* 2. to make it easier to preserve the current 2D state */
QVector<UIFrameBuffer*> m_FrameBufferVector;
#endif
/* Common variables: */
KMachineState m_machineState;
QCursor m_cursor;
#if defined(Q_WS_WIN)
HCURSOR m_alphaCursor;
#endif
/* Common flags: */
bool m_fIsFirstTimeStarted : 1;
bool m_fIsIgnoreRuntimeMediumsChanging : 1;
bool m_fIsGuestResizeIgnored : 1;
bool m_fIsSeamlessModeRequested : 1;
bool m_fIsAutoCaptureDisabled : 1;
/* Guest additions flags: */
ULONG m_ulGuestAdditionsRunLevel;
bool m_fIsGuestSupportsGraphics : 1;
bool m_fIsGuestSupportsSeamless : 1;
/* Keyboard flags: */
bool m_fNumLock : 1;
bool m_fCapsLock : 1;
bool m_fScrollLock : 1;
uint m_uNumLockAdaptionCnt;
uint m_uCapsLockAdaptionCnt;
/* Mouse flags: */
bool m_fIsMouseSupportsAbsolute : 1;
bool m_fIsMouseSupportsRelative : 1;
bool m_fIsMouseHostCursorNeeded : 1;
bool m_fIsMouseCaptured : 1;
bool m_fIsMouseIntegrated : 1;
bool m_fIsValidPointerShapePresent : 1;
bool m_fIsHidingHostPointer : 1;
/* Friend classes: */
friend class UIConsoleEventHandler;
};
#endif // !___UIConsole_h___