UISession.h revision 45cc469795c8872b9a6e0200b624ec9740ea6093
131N/A/** @file
131N/A *
131N/A * VBox frontends: Qt GUI ("VirtualBox"):
131N/A * UISession class declaration
131N/A */
131N/A
131N/A/*
131N/A * Copyright (C) 2010 Sun Microsystems, Inc.
131N/A *
131N/A * This file is part of VirtualBox Open Source Edition (OSE), as
131N/A * available from http://www.virtualbox.org. This file is free software;
131N/A * you can redistribute it and/or modify it under the terms of the GNU
131N/A * General Public License (GPL) as published by the Free Software
131N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
131N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
131N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
131N/A *
131N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
131N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
131N/A * additional information or have any questions.
131N/A */
131N/A
131N/A#ifndef ___UIConsole_h___
131N/A#define ___UIConsole_h___
131N/A
131N/A/* Global includes */
131N/A#include <QObject>
131N/A#include <QCursor>
131N/A
131N/A/* Local includes */
131N/A#include "COMDefs.h"
131N/A
131N/A/* Local forwards */
131N/Aclass UIMachine;
131N/Aclass UIConsoleCallback;
131N/A
131N/A/* CConsole callback event types: */
131N/Aenum UIConsoleEventType
131N/A{
131N/A UIConsoleEventType_MousePointerShapeChange = QEvent::User + 1,
131N/A UIConsoleEventType_MouseCapabilityChange,
131N/A UIConsoleEventType_KeyboardLedsChange,
131N/A UIConsoleEventType_StateChange,
131N/A UIConsoleEventType_AdditionsStateChange,
131N/A UIConsoleEventType_NetworkAdapterChange,
131N/A UIConsoleEventType_SerialPortChange,
131N/A UIConsoleEventType_ParallelPortChange,
131N/A UIConsoleEventType_StorageControllerChange,
131N/A UIConsoleEventType_MediumChange,
131N/A UIConsoleEventType_CPUChange,
131N/A UIConsoleEventType_VRDPServerChange,
131N/A UIConsoleEventType_RemoteDisplayInfoChange,
131N/A UIConsoleEventType_USBControllerChange,
131N/A UIConsoleEventType_USBDeviceStateChange,
131N/A UIConsoleEventType_SharedFolderChange,
UIConsoleEventType_RuntimeError,
UIConsoleEventType_CanShowWindow,
UIConsoleEventType_ShowWindow,
UIConsoleEventType_MAX
};
class UISession : public QObject
{
Q_OBJECT;
public:
/* Machine session constructor/destructor: */
UISession(UIMachine *pMachine, const CSession &session);
virtual ~UISession();
/* Common getters: */
CSession& session() { return m_session; }
KMachineState machineState() const { return m_machineState; }
bool isSaved() const { return machineState() == KMachineState_Saved; }
bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff ||
machineState() == KMachineState_Saved ||
machineState() == KMachineState_Teleported ||
machineState() == KMachineState_Aborted; }
bool isPaused() const { return machineState() == KMachineState_Paused ||
machineState() == KMachineState_TeleportingPausedVM; }
bool isRunning() const { return machineState() == KMachineState_Running ||
machineState() == KMachineState_Teleporting ||
machineState() == KMachineState_LiveSnapshotting; }
bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
bool isIgnoreRuntimeMediumsChanging() const { return m_fIsIgnoreRutimeMediumsChanging; }
bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
QCursor cursor() const { return m_cursor; }
/* Guest additions state getters: */
bool isGuestAdditionsActive() const { return m_fIsGuestAdditionsActive; }
bool isGuestSupportsGraphics() const { return m_fIsGuestSupportsGraphics; }
bool isGuestSupportsSeamless() const { return 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 isHidingHostPointer() const { return m_fIsMouseCaptured || (m_fIsMouseSupportsAbsolute && m_fIsHideHostPointer); }
/* Common setters: */
bool pause() { return setPause(true); }
bool unpause() { return setPause(false); }
bool setPause(bool fOn);
void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; }
/* 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; }
signals:
/* Console callback signals: */
void sigMousePointerShapeChange();
void sigMouseCapabilityChange();
void sigKeyboardLedsChange();
void sigMachineStateChange();
void sigAdditionsStateChange();
void sigNetworkAdapterChange(const CNetworkAdapter &networkAdapter);
void sigSerialPortChange(const CSerialPort &serialPort);
void sigParallelPortChange(const CParallelPort &parallelPort);
void sigStorageControllerChange();
void sigMediumChange(const CMediumAttachment &mediumAttachment);
void sigCPUChange(ulong uCPU, bool bRemove);
void sigVRDPServerChange();
void sigRemoteDisplayInfoChange();
void sigUSBControllerChange();
void sigUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
void sigSharedFolderChange();
void sigRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
private:
/* Private getters: */
UIMachine* uimachine() const { return m_pMachine; }
/* Event handlers: */
bool event(QEvent *pEvent);
/* Prepare helpers: */
void loadSessionSettings();
/* Cleanup helpers: */
void saveSessionSettings();
/* Common helpers: */
qulonglong winId() const;
void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
/* Private variables: */
UIMachine *m_pMachine;
CSession m_session;
const CConsoleCallback m_callback;
/* 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_fIsIgnoreRutimeMediumsChanging : 1;
bool m_fIsGuestResizeIgnored : 1;
/* Guest additions flags: */
bool m_fIsGuestAdditionsActive : 1;
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_fIsHideHostPointer : 1;
/* Friend classes: */
friend class UIConsoleCallback;
};
#endif // !___UIConsole_h___