VirtualBox

Changeset 71213 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Mar 5, 2018 8:30:44 PM (7 years ago)
Author:
vboxsync
Message:

Guest Control: Moved the copying host -> guest implementations from VBoxMange into Main, where it actually belongs. Also cleaned up and refactored the internal session task helpers into file / directory primitives, which can be reused for various different tasks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r69500 r71213  
    55
    66/*
    7  * Copyright (C) 2012-2017 Oracle Corporation
     7 * Copyright (C) 2012-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7070    }
    7171
    72     const ComObjPtr<Progress>& GetProgressObject() const {return mProgress;}
    73 
    74 protected:
    75 
    76     int getGuestProperty(const ComObjPtr<Guest> &pGuest,
    77                            const Utf8Str &strPath, Utf8Str &strValue);
     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, bool fFollowSymlinks);
     79    /** @}  */
     80
     81    /** @name File handling primitives.
     82     * @{ */
     83    int fileCopyToGuestEx(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags, PRTFILE pFile, uint64_t cbOffset, uint64_t cbSize);
     84    int fileCopyToGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags);
     85    /** @}  */
     86
     87    /** @name Guest property handling primitives.
     88     * @{ */
     89    int getGuestProperty(const ComObjPtr<Guest> &pGuest, const Utf8Str &strPath, Utf8Str &strValue);
     90    /** @}  */
     91
     92    /** @name Path handling primitives.
     93     * @{ */
     94    int pathConstructOnGuest(const Utf8Str &strSourceRoot, const Utf8Str &strSource, const Utf8Str &strDest, Utf8Str &strOut);
     95    /** @}  */
     96
    7897    int setProgress(ULONG uPercent);
    7998    int setProgressSuccess(void);
    8099    HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg);
     100
    81101    inline void setTaskDesc(const Utf8Str &strTaskDesc) throw()
    82102    {
     
    85105
    86106    HRESULT createAndSetProgressObject();
     107
    87108protected:
    88109
    89110    Utf8Str                 mDesc;
    90     GuestSession           *mSession;
     111    /** The guest session object this task is working on. */
     112    ComObjPtr<GuestSession> mSession;
    91113    /** Progress object for getting updated when running
    92114     *  asynchronously. Optional. */
     
    116138
    117139/**
     140 * Task for copying directories from guest to the host.
     141 */
     142class SessionTaskCopyDirFrom : public GuestSessionTask
     143{
     144public:
     145
     146    SessionTaskCopyDirFrom(GuestSession *pSession,
     147                           const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, DirectoryCopyFlags_T enmDirCopyFlags);
     148    virtual ~SessionTaskCopyDirFrom(void);
     149    int Run(void);
     150
     151protected:
     152
     153    int directoryCopyToHost(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, bool fFollowSymlinks,
     154                            const Utf8Str &strSubDir /* For recursion. */);
     155protected:
     156
     157    Utf8Str              mSource;
     158    Utf8Str              mDest;
     159    Utf8Str              mFilter;
     160    DirectoryCopyFlags_T mDirCopyFlags;
     161};
     162
     163/**
     164 * Task for copying directories from host to the guest.
     165 */
     166class SessionTaskCopyDirTo : public GuestSessionTask
     167{
     168public:
     169
     170    SessionTaskCopyDirTo(GuestSession *pSession,
     171                         const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, DirectoryCopyFlags_T enmDirCopyFlags);
     172    virtual ~SessionTaskCopyDirTo(void);
     173    int Run(void);
     174
     175protected:
     176
     177    int directoryCopyToGuest(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, bool fFollowSymlinks,
     178                             const Utf8Str &strSubDir /* For recursion. */);
     179protected:
     180
     181    Utf8Str              mSource;
     182    Utf8Str              mDest;
     183    Utf8Str              mFilter;
     184    DirectoryCopyFlags_T mDirCopyFlags;
     185};
     186
     187/**
    118188 * Task for copying files from host to the guest.
    119189 */
    120 class SessionTaskCopyTo : public GuestSessionTask
    121 {
    122 public:
    123 
    124     SessionTaskCopyTo(GuestSession *pSession,
    125                       const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
    126     SessionTaskCopyTo(GuestSession *pSession,
    127                       PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
    128                       const Utf8Str &strDest, uint32_t uFlags);
    129     virtual ~SessionTaskCopyTo(void);
     190class SessionTaskCopyFileTo : public GuestSessionTask
     191{
     192public:
     193
     194    SessionTaskCopyFileTo(GuestSession *pSession,
     195                          const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
     196    SessionTaskCopyFileTo(GuestSession *pSession,
     197                          PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
     198                          const Utf8Str &strDest, uint32_t uFlags);
     199    virtual ~SessionTaskCopyFileTo(void);
    130200    int Run(void);
    131201
     
    143213 * Task for copying files from guest to the host.
    144214 */
    145 class SessionTaskCopyFrom : public GuestSessionTask
    146 {
    147 public:
    148 
    149     SessionTaskCopyFrom(GuestSession *pSession,
     215class SessionTaskCopyFileFrom : public GuestSessionTask
     216{
     217public:
     218
     219    SessionTaskCopyFileFrom(GuestSession *pSession,
    150220                        const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
    151     virtual ~SessionTaskCopyFrom(void);
     221    virtual ~SessionTaskCopyFileFrom(void);
    152222    int Run(void);
    153223
     
    223293    };
    224294
    225     int i_addProcessArguments(ProcessArguments &aArgumentsDest,
    226                               const ProcessArguments &aArgumentsSource);
    227     int i_copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
    228                           Utf8Str const &strFileSource, const Utf8Str &strFileDest,
    229                           bool fOptional, uint32_t *pcbSize);
    230     int i_runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
     295    int addProcessArguments(ProcessArguments &aArgumentsDest, const ProcessArguments &aArgumentsSource);
     296    int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO, Utf8Str const &strFileSource, const Utf8Str &strFileDest, bool fOptional, uint32_t *pcbSize);
     297    int runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
    231298
    232299    /** Files to handle. */
     
    423490     * @todo r=bird: Most of these are public for no real reason...
    424491     * @{ */
     492    int                     i_copyToGuestCreateDir(const com::Utf8Str &aDestination, uint32_t fFlags, int *pGuestRc);
    425493    int                     i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
    426494    inline bool             i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
Note: See TracChangeset for help on using the changeset viewer.

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