VirtualBox

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

Last change on this file since 71314 was 71314, checked in by vboxsync, 7 years ago

GuestControl: Added and implemented IGuestSession::userHome and IGuestSession::userDocuments attributes. Untested.

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