1 |
|
---|
2 | /* $Id: GuestSessionImpl.h 47817 2013-08-16 15:30:15Z vboxsync $ */
|
---|
3 | /** @file
|
---|
4 | * VirtualBox Main - Guest session handling.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2012-2013 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef ____H_GUESTSESSIONIMPL
|
---|
20 | #define ____H_GUESTSESSIONIMPL
|
---|
21 |
|
---|
22 | #include "VirtualBoxBase.h"
|
---|
23 | #include "EventImpl.h"
|
---|
24 |
|
---|
25 | #include "GuestCtrlImplPrivate.h"
|
---|
26 | #include "GuestProcessImpl.h"
|
---|
27 | #include "GuestDirectoryImpl.h"
|
---|
28 | #include "GuestFileImpl.h"
|
---|
29 | #include "GuestFsObjInfoImpl.h"
|
---|
30 |
|
---|
31 | #include <iprt/isofs.h> /* For UpdateAdditions. */
|
---|
32 |
|
---|
33 | class Guest;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Abstract base class for a lenghtly per-session operation which
|
---|
37 | * runs in a Main worker thread.
|
---|
38 | */
|
---|
39 | class GuestSessionTask
|
---|
40 | {
|
---|
41 | public:
|
---|
42 |
|
---|
43 | GuestSessionTask(GuestSession *pSession);
|
---|
44 |
|
---|
45 | virtual ~GuestSessionTask(void);
|
---|
46 |
|
---|
47 | public:
|
---|
48 |
|
---|
49 | virtual int Run(void) = 0;
|
---|
50 | virtual int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress) = 0;
|
---|
51 |
|
---|
52 | protected:
|
---|
53 |
|
---|
54 | int getGuestProperty(const ComObjPtr<Guest> &pGuest,
|
---|
55 | const Utf8Str &strPath, Utf8Str &strValue);
|
---|
56 | int setProgress(ULONG uPercent);
|
---|
57 | int setProgressSuccess(void);
|
---|
58 | HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg);
|
---|
59 |
|
---|
60 | protected:
|
---|
61 |
|
---|
62 | Utf8Str mDesc;
|
---|
63 | GuestSession *mSession;
|
---|
64 | /** Progress object for getting updated when running
|
---|
65 | * asynchronously. Optional. */
|
---|
66 | ComObjPtr<Progress> mProgress;
|
---|
67 | };
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Task for opening a guest session.
|
---|
71 | */
|
---|
72 | class SessionTaskOpen : public GuestSessionTask
|
---|
73 | {
|
---|
74 | public:
|
---|
75 |
|
---|
76 | SessionTaskOpen(GuestSession *pSession,
|
---|
77 | uint32_t uFlags,
|
---|
78 | uint32_t uTimeoutMS);
|
---|
79 |
|
---|
80 | virtual ~SessionTaskOpen(void);
|
---|
81 |
|
---|
82 | public:
|
---|
83 |
|
---|
84 | int Run(int *pGuestRc);
|
---|
85 | int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
|
---|
86 | static int taskThread(RTTHREAD Thread, void *pvUser);
|
---|
87 |
|
---|
88 | protected:
|
---|
89 |
|
---|
90 | /** Session creation flags. */
|
---|
91 | uint32_t mFlags;
|
---|
92 | /** Session creation timeout (in ms). */
|
---|
93 | uint32_t mTimeoutMS;
|
---|
94 | };
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Task for copying files from host to the guest.
|
---|
98 | */
|
---|
99 | class SessionTaskCopyTo : public GuestSessionTask
|
---|
100 | {
|
---|
101 | public:
|
---|
102 |
|
---|
103 | SessionTaskCopyTo(GuestSession *pSession,
|
---|
104 | const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
|
---|
105 |
|
---|
106 | SessionTaskCopyTo(GuestSession *pSession,
|
---|
107 | PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
|
---|
108 | const Utf8Str &strDest, uint32_t uFlags);
|
---|
109 |
|
---|
110 | virtual ~SessionTaskCopyTo(void);
|
---|
111 |
|
---|
112 | public:
|
---|
113 |
|
---|
114 | int Run(void);
|
---|
115 | int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
|
---|
116 | static int taskThread(RTTHREAD Thread, void *pvUser);
|
---|
117 |
|
---|
118 | protected:
|
---|
119 |
|
---|
120 | Utf8Str mSource;
|
---|
121 | PRTFILE mSourceFile;
|
---|
122 | size_t mSourceOffset;
|
---|
123 | uint64_t mSourceSize;
|
---|
124 | Utf8Str mDest;
|
---|
125 | uint32_t mCopyFileFlags;
|
---|
126 | };
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Task for copying files from guest to the host.
|
---|
130 | */
|
---|
131 | class SessionTaskCopyFrom : public GuestSessionTask
|
---|
132 | {
|
---|
133 | public:
|
---|
134 |
|
---|
135 | SessionTaskCopyFrom(GuestSession *pSession,
|
---|
136 | const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
|
---|
137 |
|
---|
138 | virtual ~SessionTaskCopyFrom(void);
|
---|
139 |
|
---|
140 | public:
|
---|
141 |
|
---|
142 | int Run(void);
|
---|
143 | int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
|
---|
144 | static int taskThread(RTTHREAD Thread, void *pvUser);
|
---|
145 |
|
---|
146 | protected:
|
---|
147 |
|
---|
148 | Utf8Str mSource;
|
---|
149 | Utf8Str mDest;
|
---|
150 | uint32_t mFlags;
|
---|
151 | };
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Task for automatically updating the Guest Additions on the guest.
|
---|
155 | */
|
---|
156 | class SessionTaskUpdateAdditions : public GuestSessionTask
|
---|
157 | {
|
---|
158 | public:
|
---|
159 |
|
---|
160 | SessionTaskUpdateAdditions(GuestSession *pSession,
|
---|
161 | const Utf8Str &strSource, const ProcessArguments &aArguments,
|
---|
162 | uint32_t uFlags);
|
---|
163 |
|
---|
164 | virtual ~SessionTaskUpdateAdditions(void);
|
---|
165 |
|
---|
166 | public:
|
---|
167 |
|
---|
168 | int Run(void);
|
---|
169 | int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
|
---|
170 | static int taskThread(RTTHREAD Thread, void *pvUser);
|
---|
171 |
|
---|
172 | protected:
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Suported OS types for automatic updating.
|
---|
176 | */
|
---|
177 | enum eOSType
|
---|
178 | {
|
---|
179 | eOSType_Unknown = 0,
|
---|
180 | eOSType_Windows = 1,
|
---|
181 | eOSType_Linux = 2,
|
---|
182 | eOSType_Solaris = 3
|
---|
183 | };
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Structure representing a file to
|
---|
187 | * get off the .ISO, copied to the guest.
|
---|
188 | */
|
---|
189 | struct InstallerFile
|
---|
190 | {
|
---|
191 | InstallerFile(const Utf8Str &aSource,
|
---|
192 | const Utf8Str &aDest,
|
---|
193 | uint32_t aFlags = 0)
|
---|
194 | : strSource(aSource),
|
---|
195 | strDest(aDest),
|
---|
196 | fFlags(aFlags) { }
|
---|
197 |
|
---|
198 | InstallerFile(const Utf8Str &aSource,
|
---|
199 | const Utf8Str &aDest,
|
---|
200 | uint32_t aFlags,
|
---|
201 | GuestProcessStartupInfo startupInfo)
|
---|
202 | : strSource(aSource),
|
---|
203 | strDest(aDest),
|
---|
204 | fFlags(aFlags),
|
---|
205 | mProcInfo(startupInfo)
|
---|
206 | {
|
---|
207 | mProcInfo.mCommand = strDest;
|
---|
208 | if (mProcInfo.mName.isEmpty())
|
---|
209 | mProcInfo.mName = strDest;
|
---|
210 | }
|
---|
211 |
|
---|
212 | /** Source file on .ISO. */
|
---|
213 | Utf8Str strSource;
|
---|
214 | /** Destination file on the guest. */
|
---|
215 | Utf8Str strDest;
|
---|
216 | /** File flags. */
|
---|
217 | uint32_t fFlags;
|
---|
218 | /** Optional arguments if this file needs to be
|
---|
219 | * executed. */
|
---|
220 | GuestProcessStartupInfo mProcInfo;
|
---|
221 | };
|
---|
222 |
|
---|
223 | int addProcessArguments(ProcessArguments &aArgumentsDest,
|
---|
224 | const ProcessArguments &aArgumentsSource);
|
---|
225 | int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
|
---|
226 | Utf8Str const &strFileSource, const Utf8Str &strFileDest,
|
---|
227 | bool fOptional, uint32_t *pcbSize);
|
---|
228 | int runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
|
---|
229 |
|
---|
230 | /** Files to handle. */
|
---|
231 | std::vector<InstallerFile> mFiles;
|
---|
232 | /** The (optionally) specified Guest Additions .ISO on the host
|
---|
233 | * which will be used for the updating process. */
|
---|
234 | Utf8Str mSource;
|
---|
235 | /** (Optional) installer command line arguments. */
|
---|
236 | ProcessArguments mArguments;
|
---|
237 | /** Update flags. */
|
---|
238 | uint32_t mFlags;
|
---|
239 | };
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * Guest session implementation.
|
---|
243 | */
|
---|
244 | class ATL_NO_VTABLE GuestSession :
|
---|
245 | public VirtualBoxBase,
|
---|
246 | public GuestBase,
|
---|
247 | VBOX_SCRIPTABLE_IMPL(IGuestSession)
|
---|
248 | {
|
---|
249 | public:
|
---|
250 | /** @name COM and internal init/term/mapping cruft.
|
---|
251 | * @{ */
|
---|
252 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestSession, IGuestSession)
|
---|
253 | DECLARE_NOT_AGGREGATABLE(GuestSession)
|
---|
254 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
255 | BEGIN_COM_MAP(GuestSession)
|
---|
256 | VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestSession)
|
---|
257 | END_COM_MAP()
|
---|
258 | DECLARE_EMPTY_CTOR_DTOR(GuestSession)
|
---|
259 |
|
---|
260 | int init(Guest *pGuest, const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds);
|
---|
261 | void uninit(void);
|
---|
262 | HRESULT FinalConstruct(void);
|
---|
263 | void FinalRelease(void);
|
---|
264 | /** @} */
|
---|
265 |
|
---|
266 | /** @name IGuestSession properties.
|
---|
267 | * @{ */
|
---|
268 | STDMETHOD(COMGETTER(User))(BSTR *aName);
|
---|
269 | STDMETHOD(COMGETTER(Domain))(BSTR *aDomain);
|
---|
270 | STDMETHOD(COMGETTER(Name))(BSTR *aName);
|
---|
271 | STDMETHOD(COMGETTER(Id))(ULONG *aId);
|
---|
272 | STDMETHOD(COMGETTER(Status))(GuestSessionStatus_T *aStatus);
|
---|
273 | STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
|
---|
274 | STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
|
---|
275 | STDMETHOD(COMGETTER(ProtocolVersion))(ULONG *aVersion);
|
---|
276 | STDMETHOD(COMGETTER(Environment))(ComSafeArrayOut(BSTR, aEnvironment));
|
---|
277 | STDMETHOD(COMSETTER(Environment))(ComSafeArrayIn(IN_BSTR, aEnvironment));
|
---|
278 | STDMETHOD(COMGETTER(Processes))(ComSafeArrayOut(IGuestProcess *, aProcesses));
|
---|
279 | STDMETHOD(COMGETTER(Directories))(ComSafeArrayOut(IGuestDirectory *, aDirectories));
|
---|
280 | STDMETHOD(COMGETTER(Files))(ComSafeArrayOut(IGuestFile *, aFiles));
|
---|
281 | STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
|
---|
282 | /** @} */
|
---|
283 |
|
---|
284 | /** @name IGuestSession methods.
|
---|
285 | * @{ */
|
---|
286 | STDMETHOD(Close)(void);
|
---|
287 | STDMETHOD(CopyFrom)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress);
|
---|
288 | STDMETHOD(CopyTo)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress);
|
---|
289 | STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ComSafeArrayIn(DirectoryCreateFlag_T, aFlags));
|
---|
290 | STDMETHOD(DirectoryCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory);
|
---|
291 | STDMETHOD(DirectoryExists)(IN_BSTR aPath, BOOL *aExists);
|
---|
292 | STDMETHOD(DirectoryOpen)(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory);
|
---|
293 | STDMETHOD(DirectoryQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
|
---|
294 | STDMETHOD(DirectoryRemove)(IN_BSTR aPath);
|
---|
295 | STDMETHOD(DirectoryRemoveRecursive)(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress);
|
---|
296 | STDMETHOD(DirectoryRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
|
---|
297 | STDMETHOD(DirectorySetACL)(IN_BSTR aPath, IN_BSTR aACL);
|
---|
298 | STDMETHOD(EnvironmentClear)(void);
|
---|
299 | STDMETHOD(EnvironmentGet)(IN_BSTR aName, BSTR *aValue);
|
---|
300 | STDMETHOD(EnvironmentSet)(IN_BSTR aName, IN_BSTR aValue);
|
---|
301 | STDMETHOD(EnvironmentUnset)(IN_BSTR aName);
|
---|
302 | STDMETHOD(FileCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, IGuestFile **aFile);
|
---|
303 | STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists);
|
---|
304 | STDMETHOD(FileRemove)(IN_BSTR aPath);
|
---|
305 | STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, IGuestFile **aFile);
|
---|
306 | STDMETHOD(FileOpenEx)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile);
|
---|
307 | STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
|
---|
308 | STDMETHOD(FileQuerySize)(IN_BSTR aPath, LONG64 *aSize);
|
---|
309 | STDMETHOD(FileRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
|
---|
310 | STDMETHOD(FileSetACL)(IN_BSTR aPath, IN_BSTR aACL);
|
---|
311 | STDMETHOD(ProcessCreate)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
|
---|
312 | ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess);
|
---|
313 | STDMETHOD(ProcessCreateEx)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
|
---|
314 | ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
|
---|
315 | ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
|
---|
316 | IGuestProcess **aProcess);
|
---|
317 | STDMETHOD(ProcessGet)(ULONG aPID, IGuestProcess **aProcess);
|
---|
318 | STDMETHOD(SymlinkCreate)(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType);
|
---|
319 | STDMETHOD(SymlinkExists)(IN_BSTR aSymlink, BOOL *aExists);
|
---|
320 | STDMETHOD(SymlinkRead)(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget);
|
---|
321 | STDMETHOD(SymlinkRemoveDirectory)(IN_BSTR aPath);
|
---|
322 | STDMETHOD(SymlinkRemoveFile)(IN_BSTR aFile);
|
---|
323 | STDMETHOD(WaitFor)(ULONG aWaitFlags, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
|
---|
324 | STDMETHOD(WaitForArray)(ComSafeArrayIn(GuestSessionWaitForFlag_T, aFlags), ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
|
---|
325 | /** @} */
|
---|
326 |
|
---|
327 | private:
|
---|
328 |
|
---|
329 | typedef std::vector <ComObjPtr<GuestDirectory> > SessionDirectories;
|
---|
330 | /** Map of guest files. The key specifies the internal file ID. */
|
---|
331 | typedef std::map <uint32_t, ComObjPtr<GuestFile> > SessionFiles;
|
---|
332 | /** Map of guest processes. The key specifies the internal process number.
|
---|
333 | * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
|
---|
334 | typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
|
---|
335 |
|
---|
336 | public:
|
---|
337 | /** @name Public internal methods.
|
---|
338 | * @{ */
|
---|
339 | int closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
|
---|
340 | int directoryRemoveFromList(GuestDirectory *pDirectory);
|
---|
341 | int directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
|
---|
342 | int objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, const Utf8Str &strName, int *pGuestRc);
|
---|
343 | int directoryOpenInternal(const Utf8Str &strPath, const Utf8Str &strFilter, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory);
|
---|
344 | int directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
|
---|
345 | int dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
346 | int dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
347 | int dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
348 | inline bool fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
|
---|
349 | int fileRemoveFromList(GuestFile *pFile);
|
---|
350 | int fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
|
---|
351 | int fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
|
---|
352 | int fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
|
---|
353 | int fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc);
|
---|
354 | int fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
|
---|
355 | const GuestCredentials &getCredentials(void);
|
---|
356 | const GuestEnvironment &getEnvironment(void);
|
---|
357 | EventSource *getEventSource(void) { return mEventSource; }
|
---|
358 | Utf8Str getName(void);
|
---|
359 | ULONG getId(void) { return mData.mSession.mID; }
|
---|
360 | static Utf8Str guestErrorToString(int guestRc);
|
---|
361 | HRESULT isReadyExternal(void);
|
---|
362 | int onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
|
---|
363 | int startSessionInternal(int *pGuestRc);
|
---|
364 | int startSessionAsync(void);
|
---|
365 | static DECLCALLBACK(int)
|
---|
366 | startSessionThread(RTTHREAD Thread, void *pvUser);
|
---|
367 | Guest *getParent(void) { return mParent; }
|
---|
368 | uint32_t getProtocolVersion(void) { return mData.mProtocolVersion; }
|
---|
369 | int processRemoveFromList(GuestProcess *pProcess);
|
---|
370 | int processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
|
---|
371 | inline bool processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
|
---|
372 | inline int processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
|
---|
373 | int sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
|
---|
374 | static HRESULT setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
|
---|
375 | int setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
|
---|
376 | int signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
|
---|
377 | int startTaskAsync(const Utf8Str &strTaskDesc, GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress);
|
---|
378 | int queryInfo(void);
|
---|
379 | int waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
|
---|
380 | int waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS, GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
|
---|
381 | /** @} */
|
---|
382 |
|
---|
383 | private:
|
---|
384 |
|
---|
385 | /** Pointer to the parent (Guest). */
|
---|
386 | Guest *mParent;
|
---|
387 | /**
|
---|
388 | * The session's event source. This source is used for
|
---|
389 | * serving the internal listener as well as all other
|
---|
390 | * external listeners that may register to it.
|
---|
391 | *
|
---|
392 | * Note: This can safely be used without holding any locks.
|
---|
393 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
394 | * internally there is a lock providing the necessary serialization.
|
---|
395 | */
|
---|
396 | const ComObjPtr<EventSource> mEventSource;
|
---|
397 |
|
---|
398 | struct Data
|
---|
399 | {
|
---|
400 | /** The session credentials. */
|
---|
401 | GuestCredentials mCredentials;
|
---|
402 | /** The session's startup info. */
|
---|
403 | GuestSessionStartupInfo mSession;
|
---|
404 | /** The session's current status. */
|
---|
405 | GuestSessionStatus_T mStatus;
|
---|
406 | /** The session's environment block. Can be
|
---|
407 | * overwritten/extended by ProcessCreate(Ex). */
|
---|
408 | GuestEnvironment mEnvironment;
|
---|
409 | /** Directory objects bound to this session. */
|
---|
410 | SessionDirectories mDirectories;
|
---|
411 | /** File objects bound to this session. */
|
---|
412 | SessionFiles mFiles;
|
---|
413 | /** Process objects bound to this session. */
|
---|
414 | SessionProcesses mProcesses;
|
---|
415 | /** Guest control protocol version to be used.
|
---|
416 | * Guest Additions < VBox 4.3 have version 1,
|
---|
417 | * any newer version will have version 2. */
|
---|
418 | uint32_t mProtocolVersion;
|
---|
419 | /** Session timeout (in ms). */
|
---|
420 | uint32_t mTimeout;
|
---|
421 | /** Total number of session objects (processes,
|
---|
422 | * files, ...). */
|
---|
423 | uint32_t mNumObjects;
|
---|
424 | /** The last returned session status
|
---|
425 | * returned from the guest side. */
|
---|
426 | int mRC;
|
---|
427 | } mData;
|
---|
428 | };
|
---|
429 |
|
---|
430 | #endif /* !____H_GUESTSESSIONIMPL */
|
---|
431 |
|
---|