VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestSessionImpl.h@ 55631

Last change on this file since 55631 was 55631, checked in by vboxsync, 9 years ago

IGuestSession:

  • Added pathStyle attribute and associated enum.
  • Added a currentDirectory attribute (stub).
  • Introduced fsObjExists (earlier fsExists) which works on all fs obj types.
  • Combined directoryQueryInfo and fileQueryInfo into fsObjQueryInfo (earlier fsQueryInfo) which works on all fs obj types. Caller can check the type attribute.
  • Combined fileRemove and symlinkRemove* into fsObjRemove both on suggestion from Michael and because it's impossible to implement correctly with introducing races. Besides, our implementation was already doing the fsObjRemove job, no type checks.
  • Combined directoryRename, fileRename and symlinkRename into fsObjRename since we cannot implement type specific renames without introducing races on all platforms, and again, the current implementation already does the whole shebang.
  • Combined directorySetACL and fileSetACL into fsObjSetACL, adding a UNIX-style mode parameter for use when the ACL string is empty.
  • Stubbed the recursive directory copy methods directoryCopy, directoryCopyToGuest, and directoryCopyFromGuest. These replaces the proposed FileCopyFlag::Recursive flag.
  • Stubbed a generic move-anything-inside-the-guest method, fsObjMove, for future explotations. (Considered this on file/dir level, but it's the rename and type race problem. So, did the 'mv' approach instead.)
  • Renamed CopyFileFlag to FileCopyFlag.
  • Prefixed copyTo and copyFrom with 'file' and added 'Guest' postfix to clarify the direction (now: fileCopyToGuest, fileCopyFromGuest).
  • Added fileCopy method for copy a guest file to another guest location.
  • directoryExists got a followSymlinks parameter.
  • fileExist and fileQuerySize all got a followSymlinks parameter.
  • Retired directoryRename in favor of fsObjRename.
  • Retired directorySetACL in favor of fsObjSetACL.
  • Retired fileSetACL in favor of fsObjSetACL.
  • Retired fileRemove in favor of fsObjRemove - fileRemove was already removing everything except directories, no need for ambiguous duplications.
  • Retired symlinkRemoveDirectory and symlinkRemoveFile in favor of fsObjRemove.
  • replaced the openMode string parameter int fileOpen[Ex] methods with an enum FileAccessMode (we made some wrong design choices way back).
  • replaced the disposition string parameter in fileOpen[Ex] methods with an enum FileOpenAction. This one was more obvious, should've seen this way back.
  • replaced the sharingMode stirng parameter in the fileOpenEx method with an enum FileSharingMode.
  • Documented directoryRemoveRecursive flags issue.


IFile,IGuestFile:

  • Stubbed querySize
  • Stubbed setSize.
  • Renamed FileSeekType to FileSeekOrigin.
  • Implemented seek() relative to end, flag was forgotten.
  • Made seek() return the new offset.
  • Extended setACL with a UNIX-style file mode argument that should be used if the ACL string is empty (this way we can actually get something implemented without 2 months of cross platform ACL research).
  • The openMode and disposition attributes has been updated to match the fileOpenEx enum changes.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.3 KB
Line 
1/* $Id: GuestSessionImpl.h 55631 2015-05-04 04:08:10Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest session handling.
4 */
5
6/*
7 * Copyright (C) 2012-2013 Oracle Corporation
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_GUESTSESSIONIMPL
19#define ____H_GUESTSESSIONIMPL
20
21#include "GuestSessionWrap.h"
22#include "EventImpl.h"
23
24#include "GuestCtrlImplPrivate.h"
25#include "GuestProcessImpl.h"
26#include "GuestDirectoryImpl.h"
27#include "GuestFileImpl.h"
28#include "GuestFsObjInfoImpl.h"
29
30#include <iprt/isofs.h> /* For UpdateAdditions. */
31
32class Guest;
33
34/**
35 * Abstract base class for a lenghtly per-session operation which
36 * runs in a Main worker thread.
37 */
38class GuestSessionTask
39{
40public:
41
42 GuestSessionTask(GuestSession *pSession);
43
44 virtual ~GuestSessionTask(void);
45
46public:
47
48 virtual int Run(void) = 0;
49 virtual int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress) = 0;
50
51protected:
52
53 int getGuestProperty(const ComObjPtr<Guest> &pGuest,
54 const Utf8Str &strPath, Utf8Str &strValue);
55 int setProgress(ULONG uPercent);
56 int setProgressSuccess(void);
57 HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg);
58
59protected:
60
61 Utf8Str mDesc;
62 GuestSession *mSession;
63 /** Progress object for getting updated when running
64 * asynchronously. Optional. */
65 ComObjPtr<Progress> mProgress;
66};
67
68/**
69 * Task for opening a guest session.
70 */
71class SessionTaskOpen : public GuestSessionTask
72{
73public:
74
75 SessionTaskOpen(GuestSession *pSession,
76 uint32_t uFlags,
77 uint32_t uTimeoutMS);
78
79 virtual ~SessionTaskOpen(void);
80
81public:
82
83 int Run(int *pGuestRc);
84 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
85 static int taskThread(RTTHREAD Thread, void *pvUser);
86
87protected:
88
89 /** Session creation flags. */
90 uint32_t mFlags;
91 /** Session creation timeout (in ms). */
92 uint32_t mTimeoutMS;
93};
94
95/**
96 * Task for copying files from host to the guest.
97 */
98class SessionTaskCopyTo : public GuestSessionTask
99{
100public:
101
102 SessionTaskCopyTo(GuestSession *pSession,
103 const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
104
105 SessionTaskCopyTo(GuestSession *pSession,
106 PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
107 const Utf8Str &strDest, uint32_t uFlags);
108
109 virtual ~SessionTaskCopyTo(void);
110
111public:
112
113 int Run(void);
114 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
115 static int taskThread(RTTHREAD Thread, void *pvUser);
116
117protected:
118
119 Utf8Str mSource;
120 PRTFILE mSourceFile;
121 size_t mSourceOffset;
122 uint64_t mSourceSize;
123 Utf8Str mDest;
124 uint32_t mCopyFileFlags;
125};
126
127/**
128 * Task for copying files from guest to the host.
129 */
130class SessionTaskCopyFrom : public GuestSessionTask
131{
132public:
133
134 SessionTaskCopyFrom(GuestSession *pSession,
135 const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
136
137 virtual ~SessionTaskCopyFrom(void);
138
139public:
140
141 int Run(void);
142 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
143 static int taskThread(RTTHREAD Thread, void *pvUser);
144
145protected:
146
147 Utf8Str mSource;
148 Utf8Str mDest;
149 uint32_t mFlags;
150};
151
152/**
153 * Task for automatically updating the Guest Additions on the guest.
154 */
155class SessionTaskUpdateAdditions : public GuestSessionTask
156{
157public:
158
159 SessionTaskUpdateAdditions(GuestSession *pSession,
160 const Utf8Str &strSource, const ProcessArguments &aArguments,
161 uint32_t uFlags);
162
163 virtual ~SessionTaskUpdateAdditions(void);
164
165public:
166
167 int Run(void);
168 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
169 static int taskThread(RTTHREAD Thread, void *pvUser);
170
171protected:
172
173 /**
174 * Suported OS types for automatic updating.
175 */
176 enum eOSType
177 {
178 eOSType_Unknown = 0,
179 eOSType_Windows = 1,
180 eOSType_Linux = 2,
181 eOSType_Solaris = 3
182 };
183
184 /**
185 * Structure representing a file to
186 * get off the .ISO, copied to the guest.
187 */
188 struct InstallerFile
189 {
190 InstallerFile(const Utf8Str &aSource,
191 const Utf8Str &aDest,
192 uint32_t aFlags = 0)
193 : strSource(aSource),
194 strDest(aDest),
195 fFlags(aFlags) { }
196
197 InstallerFile(const Utf8Str &aSource,
198 const Utf8Str &aDest,
199 uint32_t aFlags,
200 GuestProcessStartupInfo startupInfo)
201 : strSource(aSource),
202 strDest(aDest),
203 fFlags(aFlags),
204 mProcInfo(startupInfo)
205 {
206 mProcInfo.mExecutable = strDest;
207 if (mProcInfo.mName.isEmpty())
208 mProcInfo.mName = strDest;
209 }
210
211 /** Source file on .ISO. */
212 Utf8Str strSource;
213 /** Destination file on the guest. */
214 Utf8Str strDest;
215 /** File flags. */
216 uint32_t fFlags;
217 /** Optional arguments if this file needs to be
218 * executed. */
219 GuestProcessStartupInfo mProcInfo;
220 };
221
222 int i_addProcessArguments(ProcessArguments &aArgumentsDest,
223 const ProcessArguments &aArgumentsSource);
224 int i_copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
225 Utf8Str const &strFileSource, const Utf8Str &strFileDest,
226 bool fOptional, uint32_t *pcbSize);
227 int i_runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
228
229 /** Files to handle. */
230 std::vector<InstallerFile> mFiles;
231 /** The (optionally) specified Guest Additions .ISO on the host
232 * which will be used for the updating process. */
233 Utf8Str mSource;
234 /** (Optional) installer command line arguments. */
235 ProcessArguments mArguments;
236 /** Update flags. */
237 uint32_t mFlags;
238};
239
240/**
241 * Guest session implementation.
242 */
243class ATL_NO_VTABLE GuestSession :
244 public GuestSessionWrap,
245 public GuestBase
246{
247public:
248 /** @name COM and internal init/term/mapping cruft.
249 * @{ */
250 DECLARE_EMPTY_CTOR_DTOR(GuestSession)
251
252 int init(Guest *pGuest, const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds);
253 void uninit(void);
254 HRESULT FinalConstruct(void);
255 void FinalRelease(void);
256 /** @} */
257
258private:
259
260 /** Wrapped @name IGuestSession properties.
261 * @{ */
262 HRESULT getUser(com::Utf8Str &aUser);
263 HRESULT getDomain(com::Utf8Str &aDomain);
264 HRESULT getName(com::Utf8Str &aName);
265 HRESULT getId(ULONG *aId);
266 HRESULT getTimeout(ULONG *aTimeout);
267 HRESULT setTimeout(ULONG aTimeout);
268 HRESULT getProtocolVersion(ULONG *aProtocolVersion);
269 HRESULT getStatus(GuestSessionStatus_T *aStatus);
270 HRESULT getEnvironmentChanges(std::vector<com::Utf8Str> &aEnvironmentChanges);
271 HRESULT setEnvironmentChanges(const std::vector<com::Utf8Str> &aEnvironmentChanges);
272 HRESULT getEnvironmentBase(std::vector<com::Utf8Str> &aEnvironmentBase);
273 HRESULT getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses);
274 HRESULT getPathStyle(PathStyle_T *aPathStyle);
275 HRESULT getCurrentDirectory(com::Utf8Str &aCurrentDirectory);
276 HRESULT setCurrentDirectory(const com::Utf8Str &aCurrentDirectory);
277 HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories);
278 HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles);
279 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
280 /** @} */
281
282 /** Wrapped @name IGuestSession methods.
283 * @{ */
284 HRESULT close();
285
286 HRESULT directoryCopy(const com::Utf8Str &aSource,
287 const com::Utf8Str &aDestination,
288 const std::vector<DirectoryCopyFlags_T> &aFlags,
289 ComPtr<IProgress> &aProgress);
290 HRESULT directoryCopyFromGuest(const com::Utf8Str &aSource,
291 const com::Utf8Str &aDestination,
292 const std::vector<DirectoryCopyFlags_T> &aFlags,
293 ComPtr<IProgress> &aProgress);
294 HRESULT directoryCopyToGuest(const com::Utf8Str &aSource,
295 const com::Utf8Str &aDestination,
296 const std::vector<DirectoryCopyFlags_T> &aFlags,
297 ComPtr<IProgress> &aProgress);
298 HRESULT directoryCreate(const com::Utf8Str &aPath,
299 ULONG aMode,
300 const std::vector<DirectoryCreateFlag_T> &aFlags);
301 HRESULT directoryCreateTemp(const com::Utf8Str &aTemplateName,
302 ULONG aMode,
303 const com::Utf8Str &aPath,
304 BOOL aSecure,
305 com::Utf8Str &aDirectory);
306 HRESULT directoryExists(const com::Utf8Str &aPath,
307 BOOL aFollowSymlinks,
308 BOOL *aExists);
309 HRESULT directoryOpen(const com::Utf8Str &aPath,
310 const com::Utf8Str &aFilter,
311 const std::vector<DirectoryOpenFlag_T> &aFlags,
312 ComPtr<IGuestDirectory> &aDirectory);
313 HRESULT directoryRemove(const com::Utf8Str &aPath);
314 HRESULT directoryRemoveRecursive(const com::Utf8Str &aPath,
315 const std::vector<DirectoryRemoveRecFlag_T> &aFlags,
316 ComPtr<IProgress> &aProgress);
317 HRESULT environmentScheduleSet(const com::Utf8Str &aName,
318 const com::Utf8Str &aValue);
319 HRESULT environmentScheduleUnset(const com::Utf8Str &aName);
320 HRESULT environmentGetBaseVariable(const com::Utf8Str &aName,
321 com::Utf8Str &aValue);
322 HRESULT environmentDoesBaseVariableExist(const com::Utf8Str &aName,
323 BOOL *aExists);
324
325 HRESULT fileCopy(const com::Utf8Str &aSource,
326 const com::Utf8Str &aDestination,
327 const std::vector<FileCopyFlag_T> &aFlags,
328 ComPtr<IProgress> &aProgress);
329 HRESULT fileCopyToGuest(const com::Utf8Str &aSource,
330 const com::Utf8Str &aDestination,
331 const std::vector<FileCopyFlag_T> &aFlags,
332 ComPtr<IProgress> &aProgress);
333 HRESULT fileCopyFromGuest(const com::Utf8Str &aSource,
334 const com::Utf8Str &aDestination,
335 const std::vector<FileCopyFlag_T> &aFlags,
336 ComPtr<IProgress> &aProgress);
337 HRESULT fileCreateTemp(const com::Utf8Str &aTemplateName,
338 ULONG aMode,
339 const com::Utf8Str &aPath,
340 BOOL aSecure,
341 ComPtr<IGuestFile> &aFile);
342 HRESULT fileExists(const com::Utf8Str &aPath,
343 BOOL aFollowSymlinks,
344 BOOL *aExists);
345 HRESULT fileOpen(const com::Utf8Str &aPath,
346 FileAccessMode_T aAccessMode,
347 FileOpenAction_T aOpenAction,
348 ULONG aCreationMode,
349 ComPtr<IGuestFile> &aFile);
350 HRESULT fileOpenEx(const com::Utf8Str &aPath,
351 FileAccessMode_T aAccessMode,
352 FileOpenAction_T aOpenAction,
353 FileSharingMode_T aSharingMode,
354 ULONG aCreationMode,
355 LONG64 aOffset,
356 ComPtr<IGuestFile> &aFile);
357 HRESULT fileQuerySize(const com::Utf8Str &aPath,
358 BOOL aFollowSymlinks,
359 LONG64 *aSize);
360 HRESULT fsObjExists(const com::Utf8Str &aPath,
361 BOOL aFollowSymlinks,
362 BOOL *pfExists);
363 HRESULT fsObjQueryInfo(const com::Utf8Str &aPath,
364 BOOL aFollowSymlinks,
365 ComPtr<IGuestFsObjInfo> &aInfo);
366 HRESULT fsObjRemove(const com::Utf8Str &aPath);
367 HRESULT fsObjRename(const com::Utf8Str &aOldPath,
368 const com::Utf8Str &aNewPath,
369 const std::vector<FsObjRenameFlag_T> &aFlags);
370 HRESULT fsObjMove(const com::Utf8Str &aSource,
371 const com::Utf8Str &aDestination,
372 const std::vector<FsObjMoveFlags_T> &aFlags,
373 ComPtr<IProgress> &aProgress);
374 HRESULT fsObjSetACL(const com::Utf8Str &aPath,
375 BOOL aFollowSymlinks,
376 const com::Utf8Str &aAcl,
377 ULONG aMode);
378 HRESULT processCreate(const com::Utf8Str &aCommand,
379 const std::vector<com::Utf8Str> &aArguments,
380 const std::vector<com::Utf8Str> &aEnvironment,
381 const std::vector<ProcessCreateFlag_T> &aFlags,
382 ULONG aTimeoutMS,
383 ComPtr<IGuestProcess> &aGuestProcess);
384 HRESULT processCreateEx(const com::Utf8Str &aCommand,
385 const std::vector<com::Utf8Str> &aArguments,
386 const std::vector<com::Utf8Str> &aEnvironment,
387 const std::vector<ProcessCreateFlag_T> &aFlags,
388 ULONG aTimeoutMS,
389 ProcessPriority_T aPriority,
390 const std::vector<LONG> &aAffinity,
391 ComPtr<IGuestProcess> &aGuestProcess);
392 HRESULT processGet(ULONG aPid,
393 ComPtr<IGuestProcess> &aGuestProcess);
394 HRESULT symlinkCreate(const com::Utf8Str &aSource,
395 const com::Utf8Str &aTarget,
396 SymlinkType_T aType);
397 HRESULT symlinkExists(const com::Utf8Str &aSymlink,
398 BOOL *aExists);
399 HRESULT symlinkRead(const com::Utf8Str &aSymlink,
400 const std::vector<SymlinkReadFlag_T> &aFlags,
401 com::Utf8Str &aTarget);
402 HRESULT waitFor(ULONG aWaitFor,
403 ULONG aTimeoutMS,
404 GuestSessionWaitResult_T *aReason);
405 HRESULT waitForArray(const std::vector<GuestSessionWaitForFlag_T> &aWaitFor,
406 ULONG aTimeoutMS,
407 GuestSessionWaitResult_T *aReason);
408 /** @} */
409
410 /** Map of guest directories. The key specifies the internal directory ID. */
411 typedef std::map <uint32_t, ComObjPtr<GuestDirectory> > SessionDirectories;
412 /** Map of guest files. The key specifies the internal file ID. */
413 typedef std::map <uint32_t, ComObjPtr<GuestFile> > SessionFiles;
414 /** Map of guest processes. The key specifies the internal process number.
415 * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
416 typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
417
418public:
419 /** @name Public internal methods.
420 * @todo r=bird: Most of these are public for no real reason...
421 * @{ */
422 int i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
423 inline bool i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
424 int i_directoryRemoveFromList(GuestDirectory *pDirectory);
425 int i_directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc);
426 int i_directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
427 int i_objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,
428 Utf8Str &strName, int *pGuestRc);
429 int i_directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo,
430 ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
431 int i_directoryQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
432 int i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
433 int i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
434 int i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
435 int i_dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
436 int i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
437 inline bool i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
438 int i_fileRemoveFromList(GuestFile *pFile);
439 int i_fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
440 int i_fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
441 int i_fileQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
442 int i_fileQuerySizeInternal(const Utf8Str &strPath, bool fFollowSymlinks, int64_t *pllSize, int *pGuestRc);
443 int i_fsQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
444 const GuestCredentials &i_getCredentials(void);
445 EventSource *i_getEventSource(void) { return mEventSource; }
446 Utf8Str i_getName(void);
447 ULONG i_getId(void) { return mData.mSession.mID; }
448 static Utf8Str i_guestErrorToString(int guestRc);
449 HRESULT i_isReadyExternal(void);
450 int i_onRemove(void);
451 int i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
452 int i_startSessionInternal(int *pGuestRc);
453 int i_startSessionAsync(void);
454 static DECLCALLBACK(int)
455 i_startSessionThread(RTTHREAD Thread, void *pvUser);
456 Guest *i_getParent(void) { return mParent; }
457 uint32_t i_getProtocolVersion(void) { return mData.mProtocolVersion; }
458 int i_pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags,
459 int *pGuestRc);
460 int i_processRemoveFromList(GuestProcess *pProcess);
461 int i_processCreateExInternal(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
462 inline bool i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
463 inline int i_processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
464 int i_sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
465 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
466 int i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
467 int i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
468 int i_startTaskAsync(const Utf8Str &strTaskDesc, GuestSessionTask *pTask,
469 ComObjPtr<Progress> &pProgress);
470 int i_determineProtocolVersion(void);
471 int i_waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
472 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
473 GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
474 /** @} */
475
476private:
477
478 /** Pointer to the parent (Guest). */
479 Guest *mParent;
480 /**
481 * The session's event source. This source is used for
482 * serving the internal listener as well as all other
483 * external listeners that may register to it.
484 *
485 * Note: This can safely be used without holding any locks.
486 * An AutoCaller suffices to prevent it being destroy while in use and
487 * internally there is a lock providing the necessary serialization.
488 */
489 const ComObjPtr<EventSource> mEventSource;
490
491 struct Data
492 {
493 /** The session credentials. */
494 GuestCredentials mCredentials;
495 /** The session's startup info. */
496 GuestSessionStartupInfo mSession;
497 /** The session's current status. */
498 GuestSessionStatus_T mStatus;
499 /** The set of environment changes for the session for use when
500 * creating new guest processes. */
501 GuestEnvironmentChanges mEnvironmentChanges;
502 /** Pointer to the immutable base environment for the session.
503 * @note This is not allocated until the guest reports it to the host. It is
504 * also shared with child processes. */
505 GuestEnvironment const *mpBaseEnvironment;
506 /** Directory objects bound to this session. */
507 SessionDirectories mDirectories;
508 /** File objects bound to this session. */
509 SessionFiles mFiles;
510 /** Process objects bound to this session. */
511 SessionProcesses mProcesses;
512 /** Guest control protocol version to be used.
513 * Guest Additions < VBox 4.3 have version 1,
514 * any newer version will have version 2. */
515 uint32_t mProtocolVersion;
516 /** Session timeout (in ms). */
517 uint32_t mTimeout;
518 /** Total number of session objects (processes,
519 * files, ...). */
520 uint32_t mNumObjects;
521 /** The last returned session status
522 * returned from the guest side. */
523 int mRC;
524
525 Data(void)
526 : mpBaseEnvironment(NULL)
527 { }
528 Data(const Data &rThat)
529 : mCredentials(rThat.mCredentials)
530 , mSession(rThat.mSession)
531 , mStatus(rThat.mStatus)
532 , mEnvironmentChanges(rThat.mEnvironmentChanges)
533 , mpBaseEnvironment(NULL)
534 , mDirectories(rThat.mDirectories)
535 , mFiles(rThat.mFiles)
536 , mProcesses(rThat.mProcesses)
537 , mProtocolVersion(rThat.mProtocolVersion)
538 , mTimeout(rThat.mTimeout)
539 , mNumObjects(rThat.mNumObjects)
540 , mRC(rThat.mRC)
541 { }
542 ~Data(void)
543 {
544 if (mpBaseEnvironment)
545 {
546 mpBaseEnvironment->releaseConst();
547 mpBaseEnvironment = NULL;
548 }
549 }
550 } mData;
551};
552
553#endif /* !____H_GUESTSESSIONIMPL */
554
Note: See TracBrowser for help on using the repository browser.

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