summaryrefslogtreecommitdiff
path: root/src/VBox/Main/include/SessionImpl.h
blob: e361fbfbd1a791cb172babad8ef1bf4a4a899aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* $Id$ */
/** @file
 * VBox Client Session COM Class definition
 */

/*
 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef MAIN_INCLUDED_SessionImpl_h
#define MAIN_INCLUDED_SessionImpl_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include "SessionWrap.h"
#include "ConsoleImpl.h"

#ifdef RT_OS_WINDOWS
# include "win/resource.h"
#endif

#if defined(RT_OS_WINDOWS) && !RT_MSC_PREREQ(RT_MSC_VER_VC140)
[threading(free)]
#endif
class ATL_NO_VTABLE Session :
    public SessionWrap
#ifdef RT_OS_WINDOWS
    , public ATL::CComCoClass<Session, &CLSID_Session>
#endif
{
public:

    DECLARE_CLASSFACTORY()

    // Do not use any ATL registry support.
    //DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)

    DECLARE_NOT_AGGREGATABLE(Session)

    DECLARE_COMMON_CLASS_METHODS(Session)

    HRESULT FinalConstruct();
    void FinalRelease();

    // public initializers/uninitializers only for internal purposes
    HRESULT init();
    void uninit();

private:

    // Wrapped ISession properties
    HRESULT getState(SessionState_T *aState);
    HRESULT getType(SessionType_T *aType);
    HRESULT getName(com::Utf8Str &aName);
    HRESULT setName(const com::Utf8Str &aName);
    HRESULT getMachine(ComPtr<IMachine> &aMachine);
    HRESULT getConsole(ComPtr<IConsole> &aConsole);

    // Wrapped ISession methods
    HRESULT unlockMachine();

    // Wrapped IInternalSessionControl properties
    HRESULT getPID(ULONG *aPid);
    HRESULT getRemoteConsole(ComPtr<IConsole> &aRemoteConsole);
    HRESULT getNominalState(MachineState_T *aNominalState);

    // Wrapped IInternalSessionControl methods
#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
    HRESULT assignMachine(const ComPtr<IMachine> &aMachine,
                          LockType_T aLockType,
                          const com::Utf8Str &aTokenId);
#else
    HRESULT assignMachine(const ComPtr<IMachine> &aMachine,
                          LockType_T aLockType,
                          const ComPtr<IToken> &aToken);
#endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
    HRESULT assignRemoteMachine(const ComPtr<IMachine> &aMachine,
                                const ComPtr<IConsole> &aConsole);
    HRESULT updateMachineState(MachineState_T aMachineState);
    HRESULT uninitialize();
    HRESULT onNetworkAdapterChange(const ComPtr<INetworkAdapter> &aNetworkAdapter,
                                   BOOL aChangeAdapter);
    HRESULT onAudioAdapterChange(const ComPtr<IAudioAdapter> &aAudioAdapter);
    HRESULT onHostAudioDeviceChange(const ComPtr<IHostAudioDevice> &aDevice,
                                    BOOL aNew, AudioDeviceState_T aState,
                                    const ComPtr<IVirtualBoxErrorInfo> &aErrInfo);
    HRESULT onSerialPortChange(const ComPtr<ISerialPort> &aSerialPort);
    HRESULT onParallelPortChange(const ComPtr<IParallelPort> &aParallelPort);
    HRESULT onStorageControllerChange(const Guid &aMachineId, const com::Utf8Str& aControllerName);
    HRESULT onMediumChange(const ComPtr<IMediumAttachment> &aMediumAttachment,
                           BOOL aForce);
    HRESULT onStorageDeviceChange(const ComPtr<IMediumAttachment> &aMediumAttachment,
                                  BOOL aRemove,
                                  BOOL aSilent);
    HRESULT onVMProcessPriorityChange(VMProcPriority_T priority);
    HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
    HRESULT onClipboardFileTransferModeChange(BOOL aEnabled);
    HRESULT onDnDModeChange(DnDMode_T aDndMode);
    HRESULT onCPUChange(ULONG aCpu,
                        BOOL aAdd);
    HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
    HRESULT onVRDEServerChange(BOOL aRestart);
    HRESULT onRecordingChange(BOOL aEnable);
    HRESULT onUSBControllerChange();
    HRESULT onSharedFolderChange(BOOL aGlobal);
    HRESULT onUSBDeviceAttach(const ComPtr<IUSBDevice> &aDevice,
                              const ComPtr<IVirtualBoxErrorInfo> &aError,
                              ULONG aMaskedInterfaces,
                              const com::Utf8Str &aCaptureFilename);
    HRESULT onUSBDeviceDetach(const com::Guid &aId,
                              const ComPtr<IVirtualBoxErrorInfo> &aError);
    HRESULT onShowWindow(BOOL aCheck,
                         BOOL *aCanShow,
                         LONG64 *aWinId);
    HRESULT onBandwidthGroupChange(const ComPtr<IBandwidthGroup> &aBandwidthGroup);
    HRESULT accessGuestProperty(const com::Utf8Str &aName,
                                const com::Utf8Str &aValue,
                                const com::Utf8Str &aFlags,
                                ULONG aAccessMode,
                                com::Utf8Str &aRetValue,
                                LONG64 *aRetTimestamp,
                                com::Utf8Str &aRetFlags);
    HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
                                     std::vector<com::Utf8Str> &aKeys,
                                     std::vector<com::Utf8Str> &aValues,
                                     std::vector<LONG64> &aTimestamps,
                                     std::vector<com::Utf8Str> &aFlags);
    HRESULT onlineMergeMedium(const ComPtr<IMediumAttachment> &aMediumAttachment,
                              ULONG aSourceIdx,
                              ULONG aTargetIdx,
                              const ComPtr<IProgress> &aProgress);
    HRESULT reconfigureMediumAttachments(const std::vector<ComPtr<IMediumAttachment> > &aAttachments);
    HRESULT enableVMMStatistics(BOOL aEnable);
    HRESULT pauseWithReason(Reason_T aReason);
    HRESULT resumeWithReason(Reason_T aReason);
    HRESULT saveStateWithReason(Reason_T aReason,
                                const ComPtr<IProgress> &aProgress,
                                const ComPtr<ISnapshot> &aSnapshot,
                                const Utf8Str &aStateFilePath,
                                BOOL aPauseVM,
                                BOOL *aLeftPaused);
    HRESULT cancelSaveStateWithReason();


    HRESULT i_unlockMachine(bool aFinalRelease, bool aFromServer, AutoWriteLock &aLockW);

    SessionState_T mState;
    SessionType_T mType;
    Utf8Str mName;

    ComPtr<IInternalMachineControl> mControl;

#ifndef VBOX_COM_INPROC_API_CLIENT
    ComObjPtr<Console> mConsole;
#endif

    ComPtr<IMachine> mRemoteMachine;
    ComPtr<IConsole> mRemoteConsole;

    ComPtr<IVirtualBox> mVirtualBox;

    class ClientTokenHolder;

    ClientTokenHolder *mClientTokenHolder;
};

#endif /* !MAIN_INCLUDED_SessionImpl_h */
/* vi: set tabstop=4 shiftwidth=4 expandtab: */