1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox Client Session COM Class definition
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_SESSIONIMPL
|
---|
19 | #define ____H_SESSIONIMPL
|
---|
20 |
|
---|
21 | #include "VirtualBoxBase.h"
|
---|
22 | #include "ConsoleImpl.h"
|
---|
23 |
|
---|
24 | #ifdef RT_OS_WINDOWS
|
---|
25 | #include "win32/resource.h"
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /** @def VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
|
---|
29 | * Use SYS V IPC for watching a session.
|
---|
30 | * This is defined in the Makefile since it's also used by MachineImpl.h/cpp.
|
---|
31 | *
|
---|
32 | * @todo Dmitry, feel free to completely change this (and/or write a better description).
|
---|
33 | * (The same goes for the other darwin changes.)
|
---|
34 | */
|
---|
35 | #ifdef __DOXYGEN__
|
---|
36 | # define VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | class ATL_NO_VTABLE Session :
|
---|
40 | public VirtualBoxBaseNEXT,
|
---|
41 | public VirtualBoxSupportErrorInfoImpl <Session, ISession>,
|
---|
42 | public VirtualBoxSupportTranslation <Session>,
|
---|
43 | #ifdef RT_OS_WINDOWS
|
---|
44 | public IDispatchImpl<ISession, &IID_ISession, &LIBID_VirtualBox,
|
---|
45 | kTypeLibraryMajorVersion, kTypeLibraryMinorVersion>,
|
---|
46 | public CComCoClass<Session, &CLSID_Session>,
|
---|
47 | #else
|
---|
48 | public ISession,
|
---|
49 | #endif
|
---|
50 | public IInternalSessionControl
|
---|
51 | {
|
---|
52 | public:
|
---|
53 |
|
---|
54 | DECLARE_CLASSFACTORY()
|
---|
55 |
|
---|
56 | DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
|
---|
57 | DECLARE_NOT_AGGREGATABLE(Session)
|
---|
58 |
|
---|
59 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
60 |
|
---|
61 | BEGIN_COM_MAP(Session)
|
---|
62 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
63 | COM_INTERFACE_ENTRY(IInternalSessionControl)
|
---|
64 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
65 | COM_INTERFACE_ENTRY(ISession)
|
---|
66 | END_COM_MAP()
|
---|
67 |
|
---|
68 | NS_DECL_ISUPPORTS
|
---|
69 |
|
---|
70 | HRESULT FinalConstruct();
|
---|
71 | void FinalRelease();
|
---|
72 |
|
---|
73 | // public initializers/uninitializers only for internal purposes
|
---|
74 | HRESULT init();
|
---|
75 | void uninit (bool aFinalRelease);
|
---|
76 |
|
---|
77 | // ISession properties
|
---|
78 | STDMETHOD(COMGETTER(State)) (SessionState_T *aState);
|
---|
79 | STDMETHOD(COMGETTER(Type)) (SessionType_T *aType);
|
---|
80 | STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
|
---|
81 | STDMETHOD(COMGETTER(Console)) (IConsole **aConsole);
|
---|
82 |
|
---|
83 | // ISession methods
|
---|
84 | STDMETHOD(Close)();
|
---|
85 |
|
---|
86 | // IInternalSessionControl methods
|
---|
87 | STDMETHOD(GetPID) (ULONG *aPid);
|
---|
88 | STDMETHOD(GetRemoteConsole) (IConsole **aConsole);
|
---|
89 | STDMETHOD(AssignMachine) (IMachine *aMachine);
|
---|
90 | STDMETHOD(AssignRemoteMachine) (IMachine *aMachine, IConsole *aConsole);
|
---|
91 | STDMETHOD(UpdateMachineState) (MachineState_T aMachineState);
|
---|
92 | STDMETHOD(Uninitialize)();
|
---|
93 | STDMETHOD(OnDVDDriveChange)();
|
---|
94 | STDMETHOD(OnFloppyDriveChange)();
|
---|
95 | STDMETHOD(OnNetworkAdapterChange)(INetworkAdapter *networkAdapter);
|
---|
96 | STDMETHOD(OnSerialPortChange)(ISerialPort *serialPort);
|
---|
97 | STDMETHOD(OnParallelPortChange)(IParallelPort *parallelPort);
|
---|
98 | STDMETHOD(OnVRDPServerChange)();
|
---|
99 | STDMETHOD(OnUSBControllerChange)();
|
---|
100 | STDMETHOD(OnSharedFolderChange) (BOOL aGlobal);
|
---|
101 | STDMETHOD(OnUSBDeviceAttach) (IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
|
---|
102 | STDMETHOD(OnUSBDeviceDetach) (INPTR GUIDPARAM aId, IVirtualBoxErrorInfo *aError);
|
---|
103 | STDMETHOD(OnShowWindow) (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId);
|
---|
104 |
|
---|
105 | // for VirtualBoxSupportErrorInfoImpl
|
---|
106 | static const wchar_t *getComponentName() { return L"Session"; }
|
---|
107 |
|
---|
108 | private:
|
---|
109 |
|
---|
110 | HRESULT close (bool aFinalRelease, bool aFromServer);
|
---|
111 | HRESULT grabIPCSemaphore();
|
---|
112 | void releaseIPCSemaphore();
|
---|
113 |
|
---|
114 | SessionState_T mState;
|
---|
115 | SessionType_T mType;
|
---|
116 |
|
---|
117 | ComPtr <IInternalMachineControl> mControl;
|
---|
118 |
|
---|
119 | ComObjPtr <Console> mConsole;
|
---|
120 |
|
---|
121 | ComPtr <IMachine> mRemoteMachine;
|
---|
122 | ComPtr <IConsole> mRemoteConsole;
|
---|
123 |
|
---|
124 | ComPtr <IVirtualBox> mVirtualBox;
|
---|
125 |
|
---|
126 | /* interprocess semaphore handle (id) for the opened machine */
|
---|
127 | #if defined(RT_OS_WINDOWS)
|
---|
128 | HANDLE mIPCSem;
|
---|
129 | HANDLE mIPCThreadSem;
|
---|
130 | #elif defined(RT_OS_OS2)
|
---|
131 | RTTHREAD mIPCThread;
|
---|
132 | RTSEMEVENT mIPCThreadSem;
|
---|
133 | #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
|
---|
134 | int mIPCSem;
|
---|
135 | #else
|
---|
136 | # error "Port me!"
|
---|
137 | #endif
|
---|
138 | };
|
---|
139 |
|
---|
140 | #endif // ____H_SESSIONIMPL
|
---|