Changeset 71648 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Apr 4, 2018 10:54:39 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121675
- Location:
- trunk/src/VBox/Main/include
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestSessionImpl.h
r71406 r71648 27 27 #include "GuestFileImpl.h" 28 28 #include "GuestFsObjInfoImpl.h" 29 #include "ThreadTask.h"30 31 #include <iprt/isofs.h> /* For UpdateAdditions. */32 29 33 30 #include <deque> 34 31 35 class Guest; 36 class GuestSessionTaskInternalOpen; 37 38 /** 39 * Abstract base class for a lenghtly per-session operation which 40 * runs in a Main worker thread. 41 */ 42 class GuestSessionTask : public ThreadTask 43 { 44 public: 45 46 GuestSessionTask(GuestSession *pSession); 47 48 virtual ~GuestSessionTask(void); 49 50 public: 51 52 virtual int Run(void) = 0; 53 void handler() 54 { 55 int vrc = Run(); 56 NOREF(vrc); 57 /** @todo 58 * 59 * r=bird: what was your idea WRT to Run status code and async tasks? 60 * 61 */ 62 } 63 64 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress); 65 66 HRESULT Init(const Utf8Str &strTaskDesc) 67 { 68 HRESULT hr = S_OK; 69 setTaskDesc(strTaskDesc); 70 hr = createAndSetProgressObject(); 71 return hr; 72 } 73 74 const ComObjPtr<Progress>& GetProgressObject() const { return mProgress; } 75 76 protected: 77 78 /** @name Directory handling primitives. 79 * @{ */ 80 int directoryCreate(const com::Utf8Str &strPath, DirectoryCreateFlag_T enmDirecotryCreateFlags, uint32_t uMode, 81 bool fFollowSymlinks); 82 /** @} */ 83 84 /** @name File handling primitives. 85 * @{ */ 86 int fileCopyFromEx(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags, 87 PRTFILE pFile, uint64_t cbOffset, uint64_t cbSize); 88 int fileCopyFrom(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags); 89 int fileCopyToEx(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags, PRTFILE pFile, 90 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)? */ 91 int fileCopyTo(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags); 92 /** @} */ 93 94 /** @name Guest property handling primitives. 95 * @{ */ 96 int getGuestProperty(const ComObjPtr<Guest> &pGuest, const Utf8Str &strPath, Utf8Str &strValue); 97 /** @} */ 98 99 /** @name Path handling primitives. 100 * @{ */ 101 int pathConstructOnGuest(const Utf8Str &strSourceRoot, const Utf8Str &strSource, const Utf8Str &strDest, Utf8Str &strOut); 102 /** @} */ 103 104 int setProgress(ULONG uPercent); 105 int setProgressSuccess(void); 106 HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg); 107 108 inline void setTaskDesc(const Utf8Str &strTaskDesc) throw() 109 { 110 mDesc = strTaskDesc; 111 } 112 113 HRESULT createAndSetProgressObject(); 114 115 protected: 116 117 Utf8Str mDesc; 118 /** The guest session object this task is working on. */ 119 ComObjPtr<GuestSession> mSession; 120 /** Progress object for getting updated when running 121 * asynchronously. Optional. */ 122 ComObjPtr<Progress> mProgress; 123 }; 124 125 /** 126 * Task for opening a guest session. 127 */ 128 class SessionTaskOpen : public GuestSessionTask 129 { 130 public: 131 132 SessionTaskOpen(GuestSession *pSession, 133 uint32_t uFlags, 134 uint32_t uTimeoutMS); 135 virtual ~SessionTaskOpen(void); 136 int Run(void); 137 138 protected: 139 140 /** Session creation flags. */ 141 uint32_t mFlags; 142 /** Session creation timeout (in ms). */ 143 uint32_t mTimeoutMS; 144 }; 145 146 /** 147 * Task for copying directories from guest to the host. 148 */ 149 class SessionTaskCopyDirFrom : public GuestSessionTask 150 { 151 public: 152 153 SessionTaskCopyDirFrom(GuestSession *pSession, const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, 154 DirectoryCopyFlag_T enmDirCopyFlags); 155 virtual ~SessionTaskCopyDirFrom(void); 156 int Run(void); 157 158 protected: 159 160 int directoryCopyToHost(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, 161 bool fFollowSymlinks, const Utf8Str &strSubDir /* For recursion. */); 162 protected: 163 164 Utf8Str mSource; 165 Utf8Str mDest; 166 Utf8Str mFilter; 167 DirectoryCopyFlag_T mDirCopyFlags; 168 }; 169 170 /** 171 * Task for copying directories from host to the guest. 172 */ 173 class SessionTaskCopyDirTo : public GuestSessionTask 174 { 175 public: 176 177 SessionTaskCopyDirTo(GuestSession *pSession, const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, 178 DirectoryCopyFlag_T enmDirCopyFlags); 179 virtual ~SessionTaskCopyDirTo(void); 180 int Run(void); 181 182 protected: 183 184 int directoryCopyToGuest(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, 185 bool fFollowSymlinks, const Utf8Str &strSubDir /* For recursion. */); 186 protected: 187 188 Utf8Str mSource; 189 Utf8Str mDest; 190 Utf8Str mFilter; 191 DirectoryCopyFlag_T mDirCopyFlags; 192 }; 193 194 /** 195 * Task for copying files from host to the guest. 196 */ 197 class SessionTaskCopyFileTo : public GuestSessionTask 198 { 199 public: 200 201 SessionTaskCopyFileTo(GuestSession *pSession, 202 const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags); 203 SessionTaskCopyFileTo(GuestSession *pSession, 204 PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize, 205 const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags); 206 virtual ~SessionTaskCopyFileTo(void); 207 int Run(void); 208 209 protected: 210 211 Utf8Str mSource; 212 PRTFILE mSourceFile; 213 size_t mSourceOffset; 214 uint64_t mSourceSize; 215 Utf8Str mDest; 216 FileCopyFlag_T mFileCopyFlags; 217 }; 218 219 /** 220 * Task for copying files from guest to the host. 221 */ 222 class SessionTaskCopyFileFrom : public GuestSessionTask 223 { 224 public: 225 226 SessionTaskCopyFileFrom(GuestSession *pSession, 227 const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags); 228 virtual ~SessionTaskCopyFileFrom(void); 229 int Run(void); 230 231 protected: 232 233 Utf8Str mSource; 234 Utf8Str mDest; 235 FileCopyFlag_T mFileCopyFlags; 236 }; 237 238 /** 239 * Task for automatically updating the Guest Additions on the guest. 240 */ 241 class SessionTaskUpdateAdditions : public GuestSessionTask 242 { 243 public: 244 245 SessionTaskUpdateAdditions(GuestSession *pSession, 246 const Utf8Str &strSource, const ProcessArguments &aArguments, 247 uint32_t uFlags); 248 virtual ~SessionTaskUpdateAdditions(void); 249 int Run(void); 250 251 protected: 252 253 /** 254 * Suported OS types for automatic updating. 255 */ 256 enum eOSType 257 { 258 eOSType_Unknown = 0, 259 eOSType_Windows = 1, 260 eOSType_Linux = 2, 261 eOSType_Solaris = 3 262 }; 263 264 /** 265 * Structure representing a file to 266 * get off the .ISO, copied to the guest. 267 */ 268 struct InstallerFile 269 { 270 InstallerFile(const Utf8Str &aSource, 271 const Utf8Str &aDest, 272 uint32_t aFlags = 0) 273 : strSource(aSource), 274 strDest(aDest), 275 fFlags(aFlags) { } 276 277 InstallerFile(const Utf8Str &aSource, 278 const Utf8Str &aDest, 279 uint32_t aFlags, 280 const GuestProcessStartupInfo &aStartupInfo) 281 : strSource(aSource), 282 strDest(aDest), 283 fFlags(aFlags), 284 mProcInfo(aStartupInfo) 285 { 286 mProcInfo.mExecutable = strDest; 287 if (mProcInfo.mName.isEmpty()) 288 mProcInfo.mName = strDest; 289 } 290 291 /** Source file on .ISO. */ 292 Utf8Str strSource; 293 /** Destination file on the guest. */ 294 Utf8Str strDest; 295 /** File flags. */ 296 uint32_t fFlags; 297 /** Optional arguments if this file needs to be 298 * executed. */ 299 GuestProcessStartupInfo mProcInfo; 300 }; 301 302 int addProcessArguments(ProcessArguments &aArgumentsDest, const ProcessArguments &aArgumentsSource); 303 int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO, Utf8Str const &strFileSource, const Utf8Str &strFileDest, bool fOptional, uint32_t *pcbSize); 304 int runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo); 305 306 /** Files to handle. */ 307 std::vector<InstallerFile> mFiles; 308 /** The (optionally) specified Guest Additions .ISO on the host 309 * which will be used for the updating process. */ 310 Utf8Str mSource; 311 /** (Optional) installer command line arguments. */ 312 ProcessArguments mArguments; 313 /** Update flags. */ 314 uint32_t mFlags; 315 }; 32 class GuestSessionTaskInternalOpen; /* Needed for i_startSessionThreadTask(). */ 316 33 317 34 /**
Note:
See TracChangeset
for help on using the changeset viewer.