VirtualBox

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

Last change on this file since 42485 was 42485, checked in by vboxsync, 12 years ago

Guest Control 2.0: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1
2/* $Id: GuestSessionImpl.h 42485 2012-07-31 16:13:53Z vboxsync $ */
3/** @file
4 * VirtualBox Main - XXX.
5 */
6
7/*
8 * Copyright (C) 2012 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
24#include "GuestCtrlImplPrivate.h"
25#include "GuestProcessImpl.h"
26#include "GuestDirectoryImpl.h"
27#include "GuestFileImpl.h"
28#include "GuestFsObjInfoImpl.h"
29
30class Guest;
31
32/**
33 * TODO
34 */
35class ATL_NO_VTABLE GuestSession :
36 public VirtualBoxBase,
37 VBOX_SCRIPTABLE_IMPL(IGuestSession)
38{
39public:
40 /** @name COM and internal init/term/mapping cruft.
41 * @{ */
42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestSession, IGuestSession)
43 DECLARE_NOT_AGGREGATABLE(GuestSession)
44 DECLARE_PROTECT_FINAL_CONSTRUCT()
45 BEGIN_COM_MAP(GuestSession)
46 VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestSession)
47 END_COM_MAP()
48 DECLARE_EMPTY_CTOR_DTOR(GuestSession)
49
50 int init(Guest *aGuest, ULONG aSessionID, Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName);
51 void uninit(void);
52 HRESULT FinalConstruct(void);
53 void FinalRelease(void);
54 /** @} */
55
56 /** @name IGuestSession properties.
57 * @{ */
58 STDMETHOD(COMGETTER(User))(BSTR *aName);
59 STDMETHOD(COMGETTER(Domain))(BSTR *aDomain);
60 STDMETHOD(COMGETTER(Name))(BSTR *aName);
61 STDMETHOD(COMGETTER(Id))(ULONG *aId);
62 STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
63 STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
64 STDMETHOD(COMGETTER(Environment))(ComSafeArrayOut(BSTR, aEnvironment));
65 STDMETHOD(COMGETTER(Processes))(ComSafeArrayOut(IGuestProcess *, aProcesses));
66 STDMETHOD(COMGETTER(Directories))(ComSafeArrayOut(IGuestDirectory *, aDirectories));
67 STDMETHOD(COMGETTER(Files))(ComSafeArrayOut(IGuestFile *, aFiles));
68 /** @} */
69
70 /** @name IGuestSession methods.
71 * @{ */
72 STDMETHOD(Close)(void);
73 STDMETHOD(CopyFrom)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress);
74 STDMETHOD(CopyTo)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(ULONG, aFlags), IProgress **aProgress);
75 STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ULONG aFlags, IGuestDirectory **aDirectory);
76 STDMETHOD(DirectoryCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory);
77 STDMETHOD(DirectoryExists)(IN_BSTR aPath, BOOL *aExists);
78 STDMETHOD(DirectoryOpen)(IN_BSTR aPath, IN_BSTR aFilter, IN_BSTR aFlags, IGuestDirectory **aDirectory);
79 STDMETHOD(DirectoryQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
80 STDMETHOD(DirectoryRemove)(IN_BSTR aPath);
81 STDMETHOD(DirectoryRemoveRecursive)(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress);
82 STDMETHOD(DirectoryRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
83 STDMETHOD(DirectorySetACL)(IN_BSTR aPath, IN_BSTR aACL);
84 STDMETHOD(EnvironmentClear)(void);
85 STDMETHOD(EnvironmentGet)(IN_BSTR aName, BSTR *aValue);
86 STDMETHOD(EnvironmentSet)(IN_BSTR aName, IN_BSTR aValue);
87 STDMETHOD(EnvironmentSetArray)(ComSafeArrayIn(IN_BSTR, aValues));
88 STDMETHOD(EnvironmentUnset)(IN_BSTR aName);
89 STDMETHOD(FileCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile);
90 STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists);
91 STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile);
92 STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
93 STDMETHOD(FileQuerySize)(IN_BSTR aPath, LONG64 *aSize);
94 STDMETHOD(FileRemove)(IN_BSTR aPath);
95 STDMETHOD(FileRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
96 STDMETHOD(FileSetACL)(IN_BSTR aPath, IN_BSTR aACL);
97 STDMETHOD(ProcessCreate)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
98 ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess);
99 STDMETHOD(ProcessCreateEx)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
100 ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
101 ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
102 IGuestProcess **aProcess);
103 STDMETHOD(ProcessGet)(ULONG aPID, IGuestProcess **aProcess);
104#if 0
105 STDMETHOD(SetTimeout)(ULONG aTimeoutMS);
106#endif
107 STDMETHOD(SymlinkCreate)(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType);
108 STDMETHOD(SymlinkExists)(IN_BSTR aSymlink, BOOL *aExists);
109 STDMETHOD(SymlinkRead)(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget);
110 STDMETHOD(SymlinkRemoveDirectory)(IN_BSTR aPath);
111 STDMETHOD(SymlinkRemoveFile)(IN_BSTR aFile);
112 /** @} */
113
114private:
115
116 typedef std::vector <ComObjPtr<GuestDirectory> > SessionDirectories;
117 typedef std::vector <ComObjPtr<GuestFile> > SessionFiles;
118 /** Map of guest processes. The key specifies the internal process number.
119 * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
120 typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
121
122public:
123 /** @name Public internal methods.
124 * @{ */
125 int directoryClose(ComObjPtr<GuestDirectory> pDirectory);
126 int dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData);
127 int fileClose(ComObjPtr<GuestFile> pFile);
128 const GuestCredentials &getCredentials(void);
129 const GuestEnvironment &getEnvironment(void);
130 uint32_t getProtocolVersion(void) { return mData.mProtocolVersion; }
131 int processClose(ComObjPtr<GuestProcess> pProcess);
132 int processCreateExInteral(GuestProcessInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
133 inline bool processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
134 inline int processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
135 int queryInfo(void);
136 /** @} */
137
138private:
139
140 struct Data
141 {
142 /** Guest control protocol version to be used.
143 * Guest Additions < VBox 4.2 have version 1,
144 * any newer version will have version 2. */
145 uint32_t mProtocolVersion;
146 /** Flag indicating if this is an internal session
147 * or not. Internal session are not accessible by clients. */
148 bool fInternal;
149 /** Pointer to the parent (Guest). */
150 Guest *mParent;
151 /** The session credentials. */
152 GuestCredentials mCredentials;
153 /** The (optional) session name. */
154 Utf8Str mName;
155 /** The session ID. */
156 ULONG mId;
157 /** The session timeout. Default is 30s. */
158 ULONG mTimeout;
159 /** The next process ID for assignment. */
160 ULONG mNextProcessID;
161 /** The session's environment block. Can be
162 * overwritten/extended by ProcessCreate(Ex). */
163 GuestEnvironment mEnvironment;
164 /** Directory objects bound to this session. */
165 SessionDirectories mDirectories;
166 /** File objects bound to this session. */
167 SessionFiles mFiles;
168 /** Process objects bound to this session. */
169 SessionProcesses mProcesses;
170 } mData;
171};
172
173#endif /* !____H_GUESTSESSIONIMPL */
174
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