ConsoleImpl.h revision bdf9c5cdef552197f95ae3f6f2ff2b6c7caa8d98
ece9652d971886b99a269656ea4782319637e75avboxsync/** @file
ece9652d971886b99a269656ea4782319637e75avboxsync *
ece9652d971886b99a269656ea4782319637e75avboxsync * VBox Console COM Class definition
ece9652d971886b99a269656ea4782319637e75avboxsync */
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync/*
ece9652d971886b99a269656ea4782319637e75avboxsync * Copyright (C) 2006-2007 innotek GmbH
ece9652d971886b99a269656ea4782319637e75avboxsync *
ece9652d971886b99a269656ea4782319637e75avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ece9652d971886b99a269656ea4782319637e75avboxsync * available from http://www.virtualbox.org. This file is free software;
ece9652d971886b99a269656ea4782319637e75avboxsync * you can redistribute it and/or modify it under the terms of the GNU
ece9652d971886b99a269656ea4782319637e75avboxsync * General Public License (GPL) as published by the Free Software
ece9652d971886b99a269656ea4782319637e75avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
ece9652d971886b99a269656ea4782319637e75avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ece9652d971886b99a269656ea4782319637e75avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ece9652d971886b99a269656ea4782319637e75avboxsync */
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync#ifndef ____H_CONSOLEIMPL
ece9652d971886b99a269656ea4782319637e75avboxsync#define ____H_CONSOLEIMPL
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync#include "VirtualBoxBase.h"
ece9652d971886b99a269656ea4782319637e75avboxsync#include "ProgressImpl.h"
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsyncclass Guest;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass Keyboard;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass Mouse;
e7f5b62e52275099a4d14501306063e23876b771vboxsyncclass Display;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass MachineDebugger;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass OUSBDevice;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass RemoteUSBDevice;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass SharedFolder;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass RemoteDisplayInfo;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass AudioSniffer;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass ConsoleVRDPServer;
ece9652d971886b99a269656ea4782319637e75avboxsyncclass VMMDev;
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync#include <VBox/vrdpapi.h>
e7f5b62e52275099a4d14501306063e23876b771vboxsync#include <VBox/pdmdrv.h>
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsyncstruct VUSBIRHCONFIG;
e7f5b62e52275099a4d14501306063e23876b771vboxsynctypedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync#include <list>
e7f5b62e52275099a4d14501306063e23876b771vboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync// defines
e7f5b62e52275099a4d14501306063e23876b771vboxsync///////////////////////////////////////////////////////////////////////////////
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync/**
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Checks the availability of the underlying VM device driver corresponding
e7f5b62e52275099a4d14501306063e23876b771vboxsync * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
e7f5b62e52275099a4d14501306063e23876b771vboxsync * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * The translatable error message is defined in null context.
e7f5b62e52275099a4d14501306063e23876b771vboxsync *
ece9652d971886b99a269656ea4782319637e75avboxsync * Intended to used only within Console children (i,e. Keyboard, Mouse,
ece9652d971886b99a269656ea4782319637e75avboxsync * Display, etc.).
ece9652d971886b99a269656ea4782319637e75avboxsync *
ece9652d971886b99a269656ea4782319637e75avboxsync * @param drv driver pointer to check (compare it with NULL)
ece9652d971886b99a269656ea4782319637e75avboxsync */
ece9652d971886b99a269656ea4782319637e75avboxsync#define CHECK_CONSOLE_DRV(drv) \
ece9652d971886b99a269656ea4782319637e75avboxsync do { \
ece9652d971886b99a269656ea4782319637e75avboxsync if (!(drv)) \
ece9652d971886b99a269656ea4782319637e75avboxsync return setError (E_ACCESSDENIED, tr ("The console is not powered up")); \
ece9652d971886b99a269656ea4782319637e75avboxsync } while (0)
ece9652d971886b99a269656ea4782319637e75avboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync/** @def VBOX_WITH_UNIXY_TAP_NETWORKING
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Unixy style TAP networking. This is defined in the Makefile since it's also
ece9652d971886b99a269656ea4782319637e75avboxsync * used by NetworkAdapterImpl.h/cpp.
ece9652d971886b99a269656ea4782319637e75avboxsync */
ece9652d971886b99a269656ea4782319637e75avboxsync#ifdef __DOXYGEN__
ece9652d971886b99a269656ea4782319637e75avboxsync# define VBOX_WITH_UNIXY_TAP_NETWORKING
ece9652d971886b99a269656ea4782319637e75avboxsync#endif
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync// Console
ece9652d971886b99a269656ea4782319637e75avboxsync///////////////////////////////////////////////////////////////////////////////
ece9652d971886b99a269656ea4782319637e75avboxsync
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync/** IConsole implementation class */
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsyncclass ATL_NO_VTABLE Console :
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync public VirtualBoxBaseWithChildrenNEXT,
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync public VirtualBoxSupportErrorInfoImpl <Console, IConsole>,
e7f5b62e52275099a4d14501306063e23876b771vboxsync public VirtualBoxSupportTranslation <Console>,
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync public IConsole
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync{
e7f5b62e52275099a4d14501306063e23876b771vboxsync Q_OBJECT
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsyncpublic:
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync DECLARE_NOT_AGGREGATABLE(Console)
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
e7f5b62e52275099a4d14501306063e23876b771vboxsync
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync BEGIN_COM_MAP(Console)
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync COM_INTERFACE_ENTRY(ISupportErrorInfo)
e7f5b62e52275099a4d14501306063e23876b771vboxsync COM_INTERFACE_ENTRY(IConsole)
e7f5b62e52275099a4d14501306063e23876b771vboxsync END_COM_MAP()
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync NS_DECL_ISUPPORTS
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync Console();
e7f5b62e52275099a4d14501306063e23876b771vboxsync ~Console();
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT FinalConstruct();
e7f5b62e52275099a4d14501306063e23876b771vboxsync void FinalRelease();
e7f5b62e52275099a4d14501306063e23876b771vboxsync
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync // public initializers/uninitializers for internal purposes only
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT init (IMachine *aMachine, IInternalMachineControl *aControl);
e7f5b62e52275099a4d14501306063e23876b771vboxsync void uninit();
e7f5b62e52275099a4d14501306063e23876b771vboxsync
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync // IConsole properties
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
0be1c98f1388ddc063a7e830f53e2018f658b348vboxsync STDMETHOD(COMGETTER(State)) (MachineState_T *aMachineState);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Guest)) (IGuest **aGuest);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Keyboard)) (IKeyboard **aKeyboard);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Mouse)) (IMouse **aMouse);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Display)) (IDisplay **aDisplay);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(Debugger)) (IMachineDebugger **aDebugger);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(USBDevices)) (IUSBDeviceCollection **aUSBDevices);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(COMGETTER(RemoteUSBDevices)) (IHostUSBDeviceCollection **aRemoteUSBDevices);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(COMGETTER(RemoteDisplayInfo)) (IRemoteDisplayInfo **aRemoteDisplayInfo);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(COMGETTER(SharedFolders)) (ISharedFolderCollection **aSharedFolders);
ece9652d971886b99a269656ea4782319637e75avboxsync
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync // IConsole methods
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync STDMETHOD(PowerUp) (IProgress **aProgress);
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync STDMETHOD(PowerDown)();
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync STDMETHOD(Reset)();
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(Pause)();
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(Resume)();
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(PowerButton)();
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(SleepButton)();
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(SaveState) (IProgress **aProgress);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(DiscardSavedState)();
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(GetDeviceActivity) (DeviceType_T aDeviceType,
ece9652d971886b99a269656ea4782319637e75avboxsync DeviceActivity_T *aDeviceActivity);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(AttachUSBDevice) (INPTR GUIDPARAM aId);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(DetachUSBDevice) (INPTR GUIDPARAM aId, IUSBDevice **aDevice);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath);
ece9652d971886b99a269656ea4782319637e75avboxsync STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(TakeSnapshot) (INPTR BSTR aName, INPTR BSTR aDescription,
e7f5b62e52275099a4d14501306063e23876b771vboxsync IProgress **aProgress);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(DiscardSnapshot) (INPTR GUIDPARAM aId, IProgress **aProgress);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(DiscardCurrentState) (IProgress **aProgress);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(DiscardCurrentSnapshotAndState) (IProgress **aProgress);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(RegisterCallback) (IConsoleCallback *aCallback);
e7f5b62e52275099a4d14501306063e23876b771vboxsync STDMETHOD(UnregisterCallback)(IConsoleCallback *aCallback);
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync // public methods for internal purposes only
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync /*
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Note: the following methods do not increase refcount. intended to be
e7f5b62e52275099a4d14501306063e23876b771vboxsync * called only by the VM execution thread.
e7f5b62e52275099a4d14501306063e23876b771vboxsync */
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync Guest *getGuest() { return mGuest; }
ece9652d971886b99a269656ea4782319637e75avboxsync Keyboard *getKeyboard() { return mKeyboard; }
ece9652d971886b99a269656ea4782319637e75avboxsync Mouse *getMouse() { return mMouse; }
ece9652d971886b99a269656ea4782319637e75avboxsync Display *getDisplay() { return mDisplay; }
ece9652d971886b99a269656ea4782319637e75avboxsync MachineDebugger *getMachineDebugger() { return mDebugger; }
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync const ComPtr <IMachine> &machine() { return mMachine; }
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync /** Method is called only from ConsoleVRDPServer */
ece9652d971886b99a269656ea4782319637e75avboxsync IVRDPServer *getVRDPServer() { return mVRDPServer; }
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync ConsoleVRDPServer *consoleVRDPServer() { return mConsoleVRDPServer; }
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync HRESULT updateMachineState (MachineState_T aMachineState);
ece9652d971886b99a269656ea4782319637e75avboxsync
ece9652d971886b99a269656ea4782319637e75avboxsync // events from IInternalSessionControl
ece9652d971886b99a269656ea4782319637e75avboxsync HRESULT onDVDDriveChange();
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onFloppyDriveChange();
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter);
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onSerialPortChange (ISerialPort *aSerialPort);
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onParallelPortChange (IParallelPort *aParallelPort);
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onVRDPServerChange();
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onUSBControllerChange();
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onSharedFolderChange (BOOL aGlobal);
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onUSBDeviceAttach (IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
e7f5b62e52275099a4d14501306063e23876b771vboxsync HRESULT onUSBDeviceDetach (INPTR GUIDPARAM aId, IVirtualBoxErrorInfo *aError);
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync VMMDev *getVMMDev() { return mVMMDev; }
e7f5b62e52275099a4d14501306063e23876b771vboxsync AudioSniffer *getAudioSniffer () { return mAudioSniffer; }
e7f5b62e52275099a4d14501306063e23876b771vboxsync
e7f5b62e52275099a4d14501306063e23876b771vboxsync int VRDPClientLogon (uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
e7f5b62e52275099a4d14501306063e23876b771vboxsync void VRDPClientConnect (uint32_t u32ClientId);
e7f5b62e52275099a4d14501306063e23876b771vboxsync void VRDPClientDisconnect (uint32_t u32ClientId, uint32_t fu32Intercepted);
e7f5b62e52275099a4d14501306063e23876b771vboxsync void VRDPInterceptAudio (uint32_t u32ClientId);
ece9652d971886b99a269656ea4782319637e75avboxsync void VRDPInterceptUSB (uint32_t u32ClientId, void **ppvIntercept);
void VRDPInterceptClipboard (uint32_t u32ClientId);
void processRemoteUSBDevices (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList);
// callback callers (partly; for some events console callbacks are notified
// directly from IInternalSessionControl event handlers declared above)
void onMousePointerShapeChange(bool fVisible, bool fAlpha,
uint32_t xHot, uint32_t yHot,
uint32_t width, uint32_t height,
void *pShape);
void onMouseCapabilityChange (BOOL supportsAbsolute, BOOL needsHostCursor);
void onStateChange (MachineState_T aMachineState);
void onAdditionsStateChange();
void onAdditionsOutdated();
void onKeyboardLedsChange (bool fNumLock, bool fCapsLock, bool fScrollLock);
void onUSBDeviceStateChange (IUSBDevice *aDevice, bool aAttached,
IVirtualBoxErrorInfo *aError);
void onRuntimeError (BOOL aFatal, INPTR BSTR aErrorID, INPTR BSTR aMessage);
HRESULT onShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId);
static const PDMDRVREG DrvStatusReg;
void reportAuthLibraryError (const char *filename, int rc)
{
setError (E_FAIL, tr("Could not load the external authentication library '%s' (%Vrc)"), filename, rc);
}
// for VirtualBoxSupportErrorInfoImpl
static const wchar_t *getComponentName() { return L"Console"; }
private:
/**
* Base template for AutoVMCaller and SaveVMPtr. Template arguments
* have the same meaning as arguments of Console::addVMCaller().
*/
template <bool taQuiet = false, bool taAllowNullVM = false>
class AutoVMCallerBase
{
public:
AutoVMCallerBase (Console *aThat) : mThat (aThat), mRC (S_OK)
{
Assert (aThat);
mRC = aThat->addVMCaller (taQuiet, taAllowNullVM);
}
~AutoVMCallerBase()
{
if (SUCCEEDED (mRC))
mThat->releaseVMCaller();
}
/** Decreases the number of callers before the instance is destroyed. */
void release()
{
AssertReturnVoid (SUCCEEDED (mRC));
mThat->releaseVMCaller();
mRC = E_FAIL;
}
/** Restores the number of callers after by #release(). #rc() must be
* rechecked to ensure the operation succeeded. */
void add()
{
AssertReturnVoid (!SUCCEEDED (mRC));
mRC = mThat->addVMCaller (taQuiet, taAllowNullVM);
}
/** Returns the result of Console::addVMCaller() */
HRESULT rc() const { return mRC; }
/** Shortcut to SUCCEEDED (rc()) */
bool isOk() const { return SUCCEEDED (mRC); }
protected:
Console *mThat;
HRESULT mRC;
private:
DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (AutoVMCallerBase)
DECLARE_CLS_NEW_DELETE_NOOP (AutoVMCallerBase)
};
/**
* Helper class that protects sections of code using the mpVM pointer by
* automatically calling addVMCaller() on construction and
* releaseVMCaller() on destruction. Intended for Console methods dealing
* with mpVM. The usage pattern is:
* <code>
* AutoVMCaller autoVMCaller (this);
* CheckComRCReturnRC (autoVMCaller.rc());
* ...
* VMR3ReqCall (mpVM, ...
* </code>
*
* @sa SafeVMPtr, SafeVMPtrQuiet
*/
typedef AutoVMCallerBase <false, false> AutoVMCaller;
/**
* Same as AutoVMCaller but doesn't set extended error info on failure.
*/
typedef AutoVMCallerBase <true, false> AutoVMCallerQuiet;
/**
* Same as AutoVMCaller but allows a null VM pointer (to trigger an error
* instead of assertion).
*/
typedef AutoVMCallerBase <false, true> AutoVMCallerWeak;
/**
* Same as AutoVMCaller but doesn't set extended error info on failure
* and allows a null VM pointer (to trigger an error instead of
* assertion).
*/
typedef AutoVMCallerBase <true, true> AutoVMCallerQuietWeak;
/**
* Base template for SaveVMPtr and SaveVMPtrQuiet.
*/
template <bool taQuiet = false>
class SafeVMPtrBase : public AutoVMCallerBase <taQuiet, true>
{
typedef AutoVMCallerBase <taQuiet, true> Base;
public:
SafeVMPtrBase (Console *aThat) : Base (aThat), mpVM (NULL)
{
if (SUCCEEDED (Base::mRC))
mpVM = aThat->mpVM;
}
/** Smart SaveVMPtr to PVM cast operator */
operator PVM() const { return mpVM; }
/** Direct PVM access for printf()-like functions */
PVM raw() const { return mpVM; }
private:
PVM mpVM;
DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (SafeVMPtrBase)
DECLARE_CLS_NEW_DELETE_NOOP (SafeVMPtrBase)
};
public:
/**
* Helper class that safely manages the Console::mpVM pointer
* by calling addVMCaller() on construction and releaseVMCaller() on
* destruction. Intended for Console children. The usage pattern is:
* <code>
* Console::SaveVMPtr pVM (mParent);
* CheckComRCReturnRC (pVM.rc());
* ...
* VMR3ReqCall (pVM, ...
* ...
* printf ("%p\n", pVM.raw());
* </code>
*
* @sa SafeVMPtrQuiet, AutoVMCaller
*/
typedef SafeVMPtrBase <false> SafeVMPtr;
/**
* A deviation of SaveVMPtr that doesn't set the error info on failure.
* Intenede for pieces of code that don't need to return the VM access
* failure to the caller. The usage pattern is:
* <code>
* Console::SaveVMPtrQuiet pVM (mParent);
* if (pVM.rc())
* VMR3ReqCall (pVM, ...
* return S_OK;
* </code>
*
* @sa SafeVMPtr, AutoVMCaller
*/
typedef SafeVMPtrBase <true> SafeVMPtrQuiet;
typedef std::map <Bstr, ComObjPtr <SharedFolder> > SharedFolderMap;
typedef std::map <Bstr, Bstr> SharedFolderDataMap;
private:
typedef std::list <ComObjPtr <OUSBDevice> > USBDeviceList;
typedef std::list <ComObjPtr <RemoteUSBDevice> > RemoteUSBDeviceList;
HRESULT addVMCaller (bool aQuiet = false, bool aAllowNullVM = false);
void releaseVMCaller();
HRESULT powerDown();
HRESULT callTapSetupApplication(bool isStatic, RTFILE tapFD, Bstr &tapDevice,
Bstr &tapSetupApplication);
HRESULT attachToHostInterface(INetworkAdapter *networkAdapter);
HRESULT detachFromHostInterface(INetworkAdapter *networkAdapter);
HRESULT powerDownHostInterfaces();
HRESULT setMachineState (MachineState_T aMachineState, bool aUpdateServer = true);
HRESULT setMachineStateLocally (MachineState_T aMachineState)
{
return setMachineState (aMachineState, false /* aUpdateServer */);
}
HRESULT findSharedFolder (const BSTR aName,
ComObjPtr <SharedFolder> &aSharedFolder,
bool aSetError = false);
HRESULT fetchSharedFolders (BOOL aGlobal);
bool findOtherSharedFolder (INPTR BSTR aName,
SharedFolderDataMap::const_iterator &aIt);
HRESULT createSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath);
HRESULT removeSharedFolder (INPTR BSTR aName);
static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole);
static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
VMSTATE aOldState, void *aUser);
HRESULT doDriveChange (const char *pszDevice, unsigned uInstance,
unsigned uLun, DriveState_T eState,
DriveState_T *peState, const char *pszPath,
bool fPassthrough);
static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice,
unsigned uInstance, unsigned uLun,
DriveState_T eState, DriveState_T *peState,
const char *pszPath, bool fPassthrough);
#ifdef VBOX_WITH_USB
HRESULT attachUSBDevice (IUSBDevice *aHostDevice, ULONG aMaskedIfs);
HRESULT detachUSBDevice (USBDeviceList::iterator &aIt);
static DECLCALLBACK(int)
usbAttachCallback (Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid,
bool aRemote, const char *aAddress, ULONG aMaskedIfs);
static DECLCALLBACK(int)
usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
#endif
static DECLCALLBACK (int)
stateProgressCallback (PVM pVM, unsigned uPercent, void *pvUser);
static DECLCALLBACK(void)
setVMErrorCallback (PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
const char *pszFormat, va_list args);
static DECLCALLBACK(void)
setVMRuntimeErrorCallback (PVM pVM, void *pvUser, bool fFatal,
const char *pszErrorID,
const char *pszFormat, va_list args);
HRESULT captureUSBDevices (PVM pVM);
void detachAllUSBDevices (bool aDone);
static DECLCALLBACK (int) powerUpThread (RTTHREAD Thread, void *pvUser);
static DECLCALLBACK (int) saveStateThread (RTTHREAD Thread, void *pvUser);
static DECLCALLBACK (int) powerDownThread (RTTHREAD Thread, void *pvUser);
static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
int mcAudioRefs;
volatile uint32_t mcVRDPClients;
static const char *sSSMConsoleUnit;
static uint32_t sSSMConsoleVer;
HRESULT loadDataFromSavedState();
static DECLCALLBACK(void) saveStateFileExec (PSSMHANDLE pSSM, void *pvUser);
static DECLCALLBACK(int) loadStateFileExec (PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version);
bool mSavedStateDataLoaded : 1;
const ComPtr <IMachine> mMachine;
const ComPtr <IInternalMachineControl> mControl;
const ComPtr <IVRDPServer> mVRDPServer;
const ComPtr <IDVDDrive> mDVDDrive;
const ComPtr <IFloppyDrive> mFloppyDrive;
ConsoleVRDPServer * const mConsoleVRDPServer;
const ComObjPtr <Guest> mGuest;
const ComObjPtr <Keyboard> mKeyboard;
const ComObjPtr <Mouse> mMouse;
const ComObjPtr <Display> mDisplay;
const ComObjPtr <MachineDebugger> mDebugger;
const ComObjPtr <RemoteDisplayInfo> mRemoteDisplayInfo;
USBDeviceList mUSBDevices;
RemoteUSBDeviceList mRemoteUSBDevices;
SharedFolderMap mSharedFolders;
SharedFolderDataMap mMachineSharedFolders;
SharedFolderDataMap mGlobalSharedFolders;
/** The VM instance handle. */
PVM mpVM;
/** Holds the number of "readonly" mpVM callers (users) */
uint32_t mVMCallers;
/** Semaphore posted when the number of mpVM callers drops to zero */
RTSEMEVENT mVMZeroCallersSem;
/** true when Console has entered the mpVM destruction phase */
bool mVMDestroying : 1;
/** The current DVD drive state in the VM.
* This does not have to match the state maintained in the DVD. */
DriveState_T meDVDState;
/** The current Floppy drive state in the VM.
* This does not have to match the state maintained in the Floppy. */
DriveState_T meFloppyState;
VMMDev * const mVMMDev;
AudioSniffer * const mAudioSniffer;
PPDMLED mapFDLeds[2];
PPDMLED mapIDELeds[4];
PPDMLED mapNetworkLeds[8];
PPDMLED mapSharedFolderLed;
PPDMLED mapUSBLed;
#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
Utf8Str maTAPDeviceName[8];
RTFILE maTapFD[8];
#endif
bool mVMStateChangeCallbackDisabled;
/* Local machine state value */
MachineState_T mMachineState;
typedef std::list <ComPtr <IConsoleCallback> > CallbackList;
CallbackList mCallbacks;
struct
{
/** OnMousePointerShapeChange() cache */
struct
{
bool valid;
bool visible;
bool alpha;
uint32_t xHot;
uint32_t yHot;
uint32_t width;
uint32_t height;
BYTE *shape;
size_t shapeSize;
}
mpsc;
/** OnMouseCapabilityChange() cache */
struct
{
bool valid;
BOOL supportsAbsolute;
BOOL needsHostCursor;
}
mcc;
/** OnKeyboardLedsChange() cache */
struct
{
bool valid;
bool numLock;
bool capsLock;
bool scrollLock;
}
klc;
}
mCallbackData;
friend struct VMTask;
};
#endif // ____H_CONSOLEIMPL