VirtualBox

Ignore:
Timestamp:
Feb 2, 2023 9:56:43 AM (2 years ago)
Author:
vboxsync
Message:

Merging r155576 and r155577 from gui4 branch: FE/Qt: Runtime UI: Reordering for UISession code; A bit of doxy fixes for UISession.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3:79645-79692
        21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572
         21/branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572,155576-155577
        2222/trunk/src:92342,154921
  • trunk/src/VBox

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3/src/VBox:79645-79692
        21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572
         21/branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572,155576-155577
  • trunk/src/VBox/Frontends

    • Property svn:mergeinfo
      •  

        old new  
        1616/branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        1717/branches/dsen/gui3/src/VBox/Frontends:79645-79692
        18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572
         18/branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438,155441,155443,155488,155509-155513,155526-155527,155559,155572,155576-155577
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r98422 r98426  
    208208protected:
    209209
    210     /** Constructs a logic passing @a pMachine and @a pSession to the base class.
     210    /** Constructs a logic passing @a pMachine and @a pSession to the base-class.
    211211      * @param  pMachine  Brings the machine this logic belongs to.
    212212      * @param  pSession  Brings the session this logic is created for. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98425 r98426  
    3535
    3636/* GUI includes: */
     37#include "UIActionPoolRuntime.h"
    3738#include "UICommon.h"
     39#include "UIConsoleEventHandler.h"
    3840#include "UIExtraDataManager.h"
    39 #include "UISession.h"
     41#include "UIFrameBuffer.h"
    4042#include "UIMachine.h"
    41 #include "UIMedium.h"
    42 #include "UIActionPoolRuntime.h"
    4343#include "UIMachineLogic.h"
    4444#include "UIMachineView.h"
    4545#include "UIMachineWindow.h"
     46#include "UIMedium.h"
    4647#include "UIMessageCenter.h"
    4748#include "UIMousePointerShapeData.h"
    4849#include "UINotificationCenter.h"
    49 #include "UIConsoleEventHandler.h"
    50 #include "UIFrameBuffer.h"
     50#include "UISession.h"
    5151#include "UISettingsDialogSpecific.h"
    5252#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
     
    246246}
    247247
     248bool UISession::setPause(bool fPause)
     249{
     250    if (fPause)
     251        console().Pause();
     252    else
     253        console().Resume();
     254
     255    const bool fOk = console().isOk();
     256    if (!fOk)
     257    {
     258        if (fPause)
     259            UINotificationMessage::cannotPauseMachine(console());
     260        else
     261            UINotificationMessage::cannotResumeMachine(console());
     262    }
     263
     264    return fOk;
     265}
     266
    248267bool UISession::guestAdditionsUpgradable()
    249268{
     
    269288}
    270289
    271 bool UISession::setPause(bool fOn)
    272 {
    273     if (fOn)
    274         console().Pause();
    275     else
    276         console().Resume();
    277 
    278     bool ok = console().isOk();
    279     if (!ok)
    280     {
    281         if (fOn)
    282             UINotificationMessage::cannotPauseMachine(console());
    283         else
    284             UINotificationMessage::cannotResumeMachine(console());
    285     }
    286 
    287     return ok;
     290UIFrameBuffer *UISession::frameBuffer(ulong uScreenId) const
     291{
     292    Assert(uScreenId < (ulong)m_frameBufferVector.size());
     293    return m_frameBufferVector.value((int)uScreenId, 0);
     294}
     295
     296void UISession::setFrameBuffer(ulong uScreenId, UIFrameBuffer *pFrameBuffer)
     297{
     298    Assert(uScreenId < (ulong)m_frameBufferVector.size());
     299    if (uScreenId < (ulong)m_frameBufferVector.size())
     300        m_frameBufferVector[(int)uScreenId] = pFrameBuffer;
     301}
     302
     303bool UISession::prepareToBeSaved()
     304{
     305    return    isPaused()
     306           || (isRunning() && pause());
     307}
     308
     309bool UISession::prepareToBeShutdowned()
     310{
     311    const bool fValidMode = console().GetGuestEnteredACPIMode();
     312    if (!fValidMode)
     313        UINotificationMessage::cannotSendACPIToMachine();
     314    return fValidMode;
    288315}
    289316
     
    377404UISession::~UISession()
    378405{
    379 }
    380 
    381 UIMachineLogic *UISession::machineLogic() const
    382 {
    383     return uimachine() ? uimachine()->machineLogic() : 0;
    384 }
    385 
    386 UIMachineWindow *UISession::activeMachineWindow() const
    387 {
    388     return machineLogic() ? machineLogic()->activeMachineWindow() : 0;
    389 }
    390 
    391 QWidget *UISession::mainMachineWindow() const
    392 {
    393     return machineLogic() ? machineLogic()->mainMachineWindow() : 0;
    394406}
    395407
     
    624636}
    625637
     638UIMachineLogic *UISession::machineLogic() const
     639{
     640    return uimachine() ? uimachine()->machineLogic() : 0;
     641}
     642
     643UIMachineWindow *UISession::activeMachineWindow() const
     644{
     645    return machineLogic() ? machineLogic()->activeMachineWindow() : 0;
     646}
     647
     648QWidget *UISession::mainMachineWindow() const
     649{
     650    return machineLogic() ? machineLogic()->mainMachineWindow() : 0;
     651}
     652
    626653bool UISession::preprocessInitialization()
    627654{
     
    831858}
    832859
    833 bool UISession::prepareToBeSaved()
    834 {
    835     return    isPaused()
    836            || (isRunning() && pause());
    837 }
    838 
    839 bool UISession::prepareToBeShutdowned()
    840 {
    841     const bool fValidMode = console().GetGuestEnteredACPIMode();
    842     if (!fValidMode)
    843         UINotificationMessage::cannotSendACPIToMachine();
    844     return fValidMode;
    845 }
    846 
    847 UIFrameBuffer* UISession::frameBuffer(ulong uScreenId) const
    848 {
    849     Assert(uScreenId < (ulong)m_frameBufferVector.size());
    850     return m_frameBufferVector.value((int)uScreenId, 0);
    851 }
    852 
    853 void UISession::setFrameBuffer(ulong uScreenId, UIFrameBuffer* pFrameBuffer)
    854 {
    855     Assert(uScreenId < (ulong)m_frameBufferVector.size());
    856     if (uScreenId < (ulong)m_frameBufferVector.size())
    857         m_frameBufferVector[(int)uScreenId] = pFrameBuffer;
    858 }
    859 
    860860#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
    861861/**
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98425 r98426  
    3333
    3434/* Qt includes: */
    35 #include <QObject>
    3635#include <QCursor>
    3736#include <QEvent>
    3837#include <QMap>
     38#include <QObject>
    3939
    4040/* GUI includes: */
     
    4545/* COM includes: */
    4646#include "COMEnums.h"
    47 #include "CSession.h"
    48 #include "CMachine.h"
    4947#include "CConsole.h"
    5048#include "CDisplay.h"
    5149#include "CGuest.h"
     50#include "CKeyboard.h"
     51#include "CMachine.h"
     52#include "CMachineDebugger.h"
    5253#include "CMouse.h"
    53 #include "CKeyboard.h"
    54 #include "CMachineDebugger.h"
     54#include "CSession.h"
    5555
    5656/* Forward declarations: */
     
    6565class CNetworkAdapter;
    6666class CMediumAttachment;
    67 #ifdef VBOX_WS_MAC
    68 class QMenuBar;
    69 #else /* !VBOX_WS_MAC */
    70 class QIcon;
    71 #endif /* !VBOX_WS_MAC */
    72 
     67
     68/** QObject subclass implementing
     69  * COM related functionality for Runtime UI. */
    7370class UISession : public QObject
    7471{
     
    7774signals:
    7875
    79     /** Notifies about additions state change. */
    80     void sigAdditionsStateChange();
    81     /** Notifies about additions state actually change. */
    82     void sigAdditionsStateActualChange();
    83     /** Notifies about additions state actually change. */
    84     void sigAudioAdapterChange();
    85     /** Notifies about clipboard mode change. */
    86     void sigClipboardModeChange(KClipboardMode enmMode);
    87     /** Notifies about CPU execution cap change. */
    88     void sigCPUExecutionCapChange();
    89     /** Notifies about DnD mode change. */
    90     void sigDnDModeChange(KDnDMode enmMode);
    91     /** Notifies about guest monitor change. */
    92     void sigGuestMonitorChange(KGuestMonitorChangedEventType enmChangeType, ulong uScreenId, QRect screenGeo);
    93     /** Notifies about machine change. */
    94     void sigMachineStateChange();
    95     /** Notifies about medium change. */
    96     void sigMediumChange(const CMediumAttachment &comMediumAttachment);
    97     /** Notifies about network adapter change. */
    98     void sigNetworkAdapterChange(const CNetworkAdapter &comNetworkAdapter);
    99     /** Notifies about recording change. */
    100     void sigRecordingChange();
    101     /** Notifies about shared folder change. */
    102     void sigSharedFolderChange();
    103     /** Notifies about storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */
    104     void sigStorageDeviceChange(const CMediumAttachment &comAttachment, bool fRemoved, bool fSilent);
    105     /** Handles USB controller change signal. */
    106     void sigUSBControllerChange();
    107     /** Handles USB device state change signal. */
    108     void sigUSBDeviceStateChange(const CUSBDevice &comDevice, bool fAttached, const CVirtualBoxErrorInfo &comError);
    109     /** Notifies about VRDE change. */
    110     void sigVRDEChange();
    111 
    112     /** Notifies about runtime error happened. */
    113     void sigRuntimeError(bool fFatal, const QString &strErrorId, const QString &strMessage);
     76    /** @name COM events stuff.
     77     ** @{ */
     78        /** Notifies about additions state change. */
     79        void sigAdditionsStateChange();
     80        /** Notifies about additions state actually change. */
     81        void sigAdditionsStateActualChange();
     82        /** Notifies about additions state actually change. */
     83        void sigAudioAdapterChange();
     84        /** Notifies about clipboard mode change. */
     85        void sigClipboardModeChange(KClipboardMode enmMode);
     86        /** Notifies about CPU execution cap change. */
     87        void sigCPUExecutionCapChange();
     88        /** Notifies about DnD mode change. */
     89        void sigDnDModeChange(KDnDMode enmMode);
     90        /** Notifies about guest monitor change. */
     91        void sigGuestMonitorChange(KGuestMonitorChangedEventType enmChangeType, ulong uScreenId, QRect screenGeo);
     92        /** Notifies about machine change. */
     93        void sigMachineStateChange();
     94        /** Notifies about medium change. */
     95        void sigMediumChange(const CMediumAttachment &comMediumAttachment);
     96        /** Notifies about network adapter change. */
     97        void sigNetworkAdapterChange(const CNetworkAdapter &comNetworkAdapter);
     98        /** Notifies about recording change. */
     99        void sigRecordingChange();
     100        /** Notifies about shared folder change. */
     101        void sigSharedFolderChange();
     102        /** Notifies about storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */
     103        void sigStorageDeviceChange(const CMediumAttachment &comAttachment, bool fRemoved, bool fSilent);
     104        /** Handles USB controller change signal. */
     105        void sigUSBControllerChange();
     106        /** Handles USB device state change signal. */
     107        void sigUSBDeviceStateChange(const CUSBDevice &comDevice, bool fAttached, const CVirtualBoxErrorInfo &comError);
     108        /** Notifies about VRDE change. */
     109        void sigVRDEChange();
     110
     111        /** Notifies about runtime error happened. */
     112        void sigRuntimeError(bool fFatal, const QString &strErrorId, const QString &strMessage);
    114113
    115114#ifdef VBOX_WS_MAC
    116     /** Notifies about VM window should be shown. */
    117     void sigShowWindows();
     115        /** Notifies about VM window should be shown. */
     116        void sigShowWindows();
    118117#endif
    119 
    120     /** Notifies about keyboard LEDs change. */
    121     void sigKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
    122 
    123     /** Notifies listeners about mouse pointer shape change. */
    124     void sigMousePointerShapeChange(const UIMousePointerShapeData &shapeData);
    125     /** Notifies listeners about mouse capability change. */
    126     void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative,
    127                                   bool fSupportsTouchScreen, bool fSupportsTouchPad,
    128                                   bool fNeedsHostCursor);
    129     /** Notifies listeners about cursor position change. */
    130     void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY);
    131 
    132     /** Notifies about frame-buffer resize. */
    133     void sigFrameBufferResize();
     118    /** @} */
     119
     120    /** @name Keyboard stuff.
     121     ** @{ */
     122        /** Notifies about keyboard LEDs change. */
     123        void sigKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
     124    /** @} */
     125
     126    /** @name Mouse stuff.
     127     ** @{ */
     128        /** Notifies listeners about mouse pointer shape change. */
     129        void sigMousePointerShapeChange(const UIMousePointerShapeData &shapeData);
     130        /** Notifies listeners about mouse capability change. */
     131        void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative,
     132                                      bool fSupportsTouchScreen, bool fSupportsTouchPad,
     133                                      bool fNeedsHostCursor);
     134        /** Notifies listeners about cursor position change. */
     135        void sigCursorPositionChange(bool fContainsData, unsigned long uX, unsigned long uY);
     136    /** @} */
     137
     138    /** @name Graphics stuff.
     139     ** @{ */
     140        /** Notifies about frame-buffer resize. */
     141        void sigFrameBufferResize();
     142    /** @} */
    134143
    135144public:
    136145
    137     /** Factory constructor. */
     146    /** Constructs session UI passing @a pMachine to the constructor.
     147      * @param  pSession  Brings the pointer to the session UI being constructed.
     148      * @param  pMachine  Brings the machine UI reference. */
    138149    static bool create(UISession *&pSession, UIMachine *pMachine);
    139     /** Factory destructor. */
     150    /** Destructs session UI.
     151      * @param  pSession  Brings the pointer to the session UI being destructed. */
    140152    static void destroy(UISession *&pSession);
    141153
    142     /* API: Runtime UI stuff: */
    143     bool initialize();
    144     /** Powers VM up. */
    145     bool powerUp();
    146 
    147     /** Returns the session instance. */
    148     CSession &session() { return m_session; }
    149     /** Returns the session's machine instance. */
    150     CMachine &machine() { return m_machine; }
    151     /** Returns the session's console instance. */
    152     CConsole &console() { return m_console; }
    153     /** Returns the console's display instance. */
    154     CDisplay &display() { return m_display; }
    155     /** Returns the console's guest instance. */
    156     CGuest &guest() { return m_guest; }
    157     /** Returns the console's mouse instance. */
    158     CMouse &mouse() { return m_mouse; }
    159     /** Returns the console's keyboard instance. */
    160     CKeyboard &keyboard() { return m_keyboard; }
    161     /** Returns the console's debugger instance. */
    162     CMachineDebugger &debugger() { return m_debugger; }
    163 
    164     /** Returns the machine name. */
    165     QString machineName() const { return m_strMachineName; }
    166 
    167     /** Returns main machine-widget id. */
    168     WId mainMachineWindowId() const;
    169 
    170     /** Returns previous machine state. */
    171     KMachineState machineStatePrevious() const { return m_machineStatePrevious; }
    172     /** Returns machine state. */
    173     KMachineState machineState() const { return m_machineState; }
    174 
    175     bool isSaved() const { return machineState() == KMachineState_Saved ||
    176                                   machineState() == KMachineState_AbortedSaved; }
    177     bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff ||
    178                                       machineState() == KMachineState_Saved ||
    179                                       machineState() == KMachineState_Teleported ||
    180                                       machineState() == KMachineState_Aborted ||
    181                                       machineState() == KMachineState_AbortedSaved; }
    182     bool isPaused() const { return machineState() == KMachineState_Paused ||
    183                                    machineState() == KMachineState_TeleportingPausedVM; }
    184     bool isRunning() const { return machineState() == KMachineState_Running ||
    185                                     machineState() == KMachineState_Teleporting ||
    186                                     machineState() == KMachineState_LiveSnapshotting; }
    187     bool isStuck() const { return machineState() == KMachineState_Stuck; }
    188     bool wasPaused() const { return machineStatePrevious() == KMachineState_Paused ||
    189                                     machineStatePrevious() == KMachineState_TeleportingPausedVM; }
    190     /** Returns whether guest-screen is undrawable.
    191      *  @todo: extend this method to all the states when guest-screen is undrawable. */
    192     bool isGuestScreenUnDrawable() const { return machineState() == KMachineState_Stopping ||
    193                                                   machineState() == KMachineState_Saving; }
    194 
    195 
    196     /* Guest additions state getters: */
    197     bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > KAdditionsRunLevelType_None); }
    198     bool isGuestSupportsGraphics() const { return m_fIsGuestSupportsGraphics; }
    199     /* The double check below is correct, even though it is an implementation
    200      * detail of the Additions which the GUI should not ideally have to know. */
    201     bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
    202     /** Returns whether GA can be upgraded. */
    203     bool guestAdditionsUpgradable();
    204 
    205     /* Common setters: */
    206     bool pause() { return setPause(true); }
    207     bool unpause() { return setPause(false); }
    208     bool setPause(bool fOn);
    209     void forgetPreviousMachineState() { m_machineStatePrevious = m_machineState; }
    210 
    211     /* Returns existing framebuffer for the given screen-number;
    212      * Returns 0 (asserts) if screen-number attribute is out of bounds: */
    213     UIFrameBuffer* frameBuffer(ulong uScreenId) const;
    214     /* Sets framebuffer for the given screen-number;
    215      * Ignores (asserts) if screen-number attribute is out of bounds: */
    216     void setFrameBuffer(ulong uScreenId, UIFrameBuffer* pFrameBuffer);
    217     /** Returns existing frame-buffer vector. */
    218     const QVector<UIFrameBuffer*>& frameBuffers() const { return m_frameBufferVector; }
    219 
    220     /** Prepares VM to be saved. */
    221     bool prepareToBeSaved();
    222     /** Returns whether VM can be shutdowned. */
    223     bool prepareToBeShutdowned();
     154    /** @name General stuff.
     155     ** @{ */
     156        /** Performs session UI intialization. */
     157        bool initialize();
     158        /** Powers VM up. */
     159        bool powerUp();
     160    /** @} */
     161
     162    /** @name COM stuff.
     163     ** @{ */
     164        /** Returns the session instance. */
     165        CSession &session() { return m_session; }
     166        /** Returns the session's machine instance. */
     167        CMachine &machine() { return m_machine; }
     168        /** Returns the session's console instance. */
     169        CConsole &console() { return m_console; }
     170        /** Returns the console's display instance. */
     171        CDisplay &display() { return m_display; }
     172        /** Returns the console's guest instance. */
     173        CGuest &guest() { return m_guest; }
     174        /** Returns the console's mouse instance. */
     175        CMouse &mouse() { return m_mouse; }
     176        /** Returns the console's keyboard instance. */
     177        CKeyboard &keyboard() { return m_keyboard; }
     178        /** Returns the console's debugger instance. */
     179        CMachineDebugger &debugger() { return m_debugger; }
     180    /** @} */
     181
     182    /** @name General stuff.
     183     ** @{ */
     184        /** Returns the machine name. */
     185        QString machineName() const { return m_strMachineName; }
     186
     187        /** Returns main machine-widget id. */
     188        WId mainMachineWindowId() const;
     189    /** @} */
     190
     191    /** @name Machine-state stuff.
     192     ** @{ */
     193        /** Returns previous machine state. */
     194        KMachineState machineStatePrevious() const { return m_machineStatePrevious; }
     195        /** Returns machine state. */
     196        KMachineState machineState() const { return m_machineState; }
     197
     198        /** Resets previous state to be the same as current one. */
     199        void forgetPreviousMachineState() { m_machineStatePrevious = m_machineState; }
     200
     201        /** Returns whether VM is in one of saved states. */
     202        bool isSaved() const { return    machineState() == KMachineState_Saved
     203                                      || machineState() == KMachineState_AbortedSaved; }
     204        /** Returns whether VM is in one of turned off states. */
     205        bool isTurnedOff() const { return    machineState() == KMachineState_PoweredOff
     206                                          || machineState() == KMachineState_Saved
     207                                          || machineState() == KMachineState_Teleported
     208                                          || machineState() == KMachineState_Aborted
     209                                          || machineState() == KMachineState_AbortedSaved; }
     210        /** Returns whether VM is in one of paused states. */
     211        bool isPaused() const { return    machineState() == KMachineState_Paused
     212                                       || machineState() == KMachineState_TeleportingPausedVM; }
     213        /** Returns whether VM was in one of paused states. */
     214        bool wasPaused() const { return    machineStatePrevious() == KMachineState_Paused
     215                                        || machineStatePrevious() == KMachineState_TeleportingPausedVM; }
     216        /** Returns whether VM is in one of running states. */
     217        bool isRunning() const { return    machineState() == KMachineState_Running
     218                                        || machineState() == KMachineState_Teleporting
     219                                        || machineState() == KMachineState_LiveSnapshotting; }
     220        /** Returns whether VM is in one of stuck states. */
     221        bool isStuck() const { return machineState() == KMachineState_Stuck; }
     222        /** Returns whether VM is one of states where guest-screen is undrawable. */
     223        bool isGuestScreenUnDrawable() const { return    machineState() == KMachineState_Stopping
     224                                                      || machineState() == KMachineState_Saving; }
     225
     226        /** Performes VM pausing. */
     227        bool pause() { return setPause(true); }
     228        /** Performes VM resuming. */
     229        bool unpause() { return setPause(false); }
     230        /** Performes VM pausing/resuming depending on @a fPause state. */
     231        bool setPause(bool fPause);
     232    /** @} */
     233
     234    /** @name Guest additions stuff.
     235     ** @{ */
     236        /** Returns whether guest additions is active. */
     237        bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > KAdditionsRunLevelType_None); }
     238        /** Returns whether guest additions supports graphics. */
     239        bool isGuestSupportsGraphics() const { return m_fIsGuestSupportsGraphics; }
     240        /** Returns whether guest additions supports seamless.
     241          * @note The double check below is correct, even though it is an implementation
     242          *       detail of the Additions which the GUI should not ideally have to know. */
     243        bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
     244        /** Returns whether GA can be upgraded. */
     245        bool guestAdditionsUpgradable();
     246    /** @} */
     247
     248    /** @name Graphics stuff.
     249     ** @{ */
     250        /** Returns existing framebuffer for the screen with given @a uScreenId;
     251          * @returns 0 (asserts) if uScreenId attribute is out of bounds. */
     252        UIFrameBuffer *frameBuffer(ulong uScreenId) const;
     253        /** Sets framebuffer for the screen with given @a uScreenId;
     254          * Ignores (asserts) if screen-number attribute is out of bounds. */
     255        void setFrameBuffer(ulong uScreenId, UIFrameBuffer *pFrameBuffer);
     256        /** Returns existing frame-buffer vector. */
     257        const QVector<UIFrameBuffer*> &frameBuffers() const { return m_frameBufferVector; }
     258    /** @} */
     259
     260    /** @name Close stuff.
     261     ** @{ */
     262        /** Prepares VM to be saved. */
     263        bool prepareToBeSaved();
     264        /** Returns whether VM can be shutdowned. */
     265        bool prepareToBeShutdowned();
     266    /** @} */
    224267
    225268public slots:
    226269
    227     /** Handles request to install guest additions image.
    228       * @param  strSource  Brings the source of image being installed. */
    229     void sltInstallGuestAdditionsFrom(const QString &strSource);
    230     /** Mounts DVD adhoc.
    231       * @param  strSource  Brings the source of image being mounted. */
    232     void sltMountDVDAdHoc(const QString &strSource);
     270    /** @name Guest additions stuff.
     271     ** @{ */
     272        /** Handles request to install guest additions image.
     273          * @param  strSource  Brings the source of image being installed. */
     274        void sltInstallGuestAdditionsFrom(const QString &strSource);
     275        /** Mounts DVD adhoc.
     276          * @param  strSource  Brings the source of image being mounted. */
     277        void sltMountDVDAdHoc(const QString &strSource);
     278    /** @} */
    233279
    234280private slots:
    235281
    236     /** Detaches COM. */
    237     void sltDetachCOM();
    238 
    239     /* Console events slots */
    240     void sltStateChange(KMachineState state);
    241     void sltAdditionsChange();
     282    /** @name COM stuff.
     283     ** @{ */
     284        /** Detaches COM. */
     285        void sltDetachCOM();
     286    /** @} */
     287
     288    /** @name Machine-state stuff.
     289     ** @{ */
     290        /** Handles event about VM @a enmState change. */
     291        void sltStateChange(KMachineState enmState);
     292    /** @} */
     293
     294    /** @name Guest additions stuff.
     295     ** @{ */
     296        /** Handles event about guest additions change. */
     297        void sltAdditionsChange();
     298    /** @} */
    242299
    243300private:
    244301
    245     /** Constructor. */
     302    /** Constructs session UI passing @a pMachine to the base-class.
     303      * @param  pMachine  Brings the machine UI reference. */
    246304    UISession(UIMachine *pMachine);
    247     /** Destructor. */
    248     ~UISession();
    249 
    250     /** Returns machine UI reference. */
    251     UIMachine *uimachine() const { return m_pMachine; }
    252     /** Returns machine-logic reference. */
    253     UIMachineLogic *machineLogic() const;
    254     /** Returns main machine-window reference. */
    255     UIMachineWindow *activeMachineWindow() const;
    256     /** Returns main machine-widget reference. */
    257     QWidget *mainMachineWindow() const;
    258 
    259     /* Prepare helpers: */
    260     bool prepare();
    261     bool prepareSession();
    262     void prepareNotificationCenter();
    263     void prepareConsoleEventHandlers();
    264     void prepareFramebuffers();
    265     void prepareConnections();
    266     void prepareSignalHandling();
    267 
    268     /* Cleanup helpers: */
    269     void cleanupFramebuffers();
    270     void cleanupConsoleEventHandlers();
    271     void cleanupNotificationCenter();
    272     void cleanupSession();
    273 
    274     /* Common helpers: */
    275     bool preprocessInitialization();
    276     bool mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName);
    277 
    278     /** Recaches media attached to the machine. */
    279     void recacheMachineMedia();
    280 
    281     /* Private variables: */
    282     UIMachine *m_pMachine;
    283 
    284     /** Holds the CConsole event handler instance. */
    285     UIConsoleEventHandler *m_pConsoleEventhandler;
    286 
    287     /** Holds the session instance. */
    288     CSession m_session;
    289     /** Holds the session's machine instance. */
    290     CMachine m_machine;
    291     /** Holds the session's console instance. */
    292     CConsole m_console;
    293     /** Holds the console's display instance. */
    294     CDisplay m_display;
    295     /** Holds the console's guest instance. */
    296     CGuest m_guest;
    297     /** Holds the console's mouse instance. */
    298     CMouse m_mouse;
    299     /** Holds the console's keyboard instance. */
    300     CKeyboard m_keyboard;
    301     /** Holds the console's debugger instance. */
    302     CMachineDebugger m_debugger;
    303 
    304     /** Holds the machine name. */
    305     QString m_strMachineName;
    306     /** Holds the previous machine state. */
    307     KMachineState m_machineStatePrevious;
    308     /** Holds the actual machine state. */
    309     KMachineState m_machineState;
    310 
    311     /* Frame-buffers vector: */
    312     QVector<UIFrameBuffer*> m_frameBufferVector;
    313 
    314     /* Guest additions flags: */
    315     ULONG m_ulGuestAdditionsRunLevel;
    316     bool  m_fIsGuestSupportsGraphics : 1;
    317     bool  m_fIsGuestSupportsSeamless : 1;
     305    /** Destructs session UI. */
     306    virtual ~UISession() RT_OVERRIDE;
     307
     308    /** @name Prepare/cleanup cascade.
     309     ** @{ */
     310        /** Prepares everything. */
     311        bool prepare();
     312        /** Prepares COM session. */
     313        bool prepareSession();
     314        /** Prepares notification-center. */
     315        void prepareNotificationCenter();
     316        /** Prepares console event-handler. */
     317        void prepareConsoleEventHandlers();
     318        /** Prepares frame-buffers. */
     319        void prepareFramebuffers();
     320        /** Prepares connections. */
     321        void prepareConnections();
     322        /** Prepares signal handling. */
     323        void prepareSignalHandling();
     324
     325        /** Cleanups frame-buffers. */
     326        void cleanupFramebuffers();
     327        /** Cleanups console event-handler. */
     328        void cleanupConsoleEventHandlers();
     329        /** Cleanups notification-center. */
     330        void cleanupNotificationCenter();
     331        /** Cleanups COM session. */
     332        void cleanupSession();
     333    /** @} */
     334
     335    /** @name General stuff.
     336     ** @{ */
     337        /** Returns the machine UI reference. */
     338        UIMachine *uimachine() const { return m_pMachine; }
     339        /** Returns the machine-logic reference. */
     340        UIMachineLogic *machineLogic() const;
     341        /** Returns main machine-window reference. */
     342        UIMachineWindow *activeMachineWindow() const;
     343        /** Returns main machine-widget reference. */
     344        QWidget *mainMachineWindow() const;
     345
     346        /** Preprocess initialization. */
     347        bool preprocessInitialization();
     348
     349        /** Mounts medium adhoc.
     350          * @param  enmDeviceType  Brings device type.
     351          * @param  enmMediumType  Brings medium type.
     352          * @param  strMediumName  Brings medium name. */
     353        bool mountAdHocImage(KDeviceType enmDeviceType, UIMediumDeviceType enmMediumType, const QString &strMediumName);
     354
     355        /** Recaches media attached to the machine. */
     356        void recacheMachineMedia();
     357    /** @} */
     358
     359    /** @name General stuff.
     360     ** @{ */
     361        /** Holds the machine UI reference. */
     362        UIMachine *m_pMachine;
     363
     364        /** Holds the machine name. */
     365        QString  m_strMachineName;
     366    /** @} */
     367
     368    /** @name COM stuff.
     369     ** @{ */
     370        /** Holds the CConsole event handler instance. */
     371        UIConsoleEventHandler *m_pConsoleEventhandler;
     372
     373        /** Holds the session instance. */
     374        CSession         m_session;
     375        /** Holds the session's machine instance. */
     376        CMachine         m_machine;
     377        /** Holds the session's console instance. */
     378        CConsole         m_console;
     379        /** Holds the console's display instance. */
     380        CDisplay         m_display;
     381        /** Holds the console's guest instance. */
     382        CGuest           m_guest;
     383        /** Holds the console's mouse instance. */
     384        CMouse           m_mouse;
     385        /** Holds the console's keyboard instance. */
     386        CKeyboard        m_keyboard;
     387        /** Holds the console's debugger instance. */
     388        CMachineDebugger m_debugger;
     389    /** @} */
     390
     391    /** @name Machine-state stuff.
     392     ** @{ */
     393        /** Holds the previous machine state. */
     394        KMachineState  m_machineStatePrevious;
     395        /** Holds the actual machine state. */
     396        KMachineState  m_machineState;
     397    /** @} */
     398
     399    /** @name Guest additions stuff.
     400     ** @{ */
     401        /** Holds the guest-additions run level. */
     402        ULONG  m_ulGuestAdditionsRunLevel;
     403        /** Holds whether guest-additions supports graphics. */
     404        bool   m_fIsGuestSupportsGraphics;
     405        /** Holds whether guest-additions supports seamless. */
     406        bool   m_fIsGuestSupportsSeamless;
     407    /** @} */
     408
     409    /** @name Machine-state stuff.
     410     ** @{ */
     411        /** Holds the frame-buffer vector. */
     412        QVector<UIFrameBuffer*>  m_frameBufferVector;
     413    /** @} */
    318414};
    319415
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette