VirtualBox

Changeset 98340 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Jan 30, 2023 12:09:34 AM (23 months ago)
Author:
vboxsync
Message:

Main: bugref:4784: seperated SharedFolder API between VboxSVC and VM process (fixed issues from previous attempt on this)

Location:
trunk/src/VBox/Main/src-all
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/ConsoleSharedFolderImpl.cpp

    r98048 r98340  
    2727
    2828#define LOG_GROUP LOG_GROUP_MAIN_SHAREDFOLDER
    29 #include "SharedFolderImpl.h"
    30 #if !defined(VBOX_COM_INPROC)
    31 # include "VirtualBoxImpl.h"
    32 # include "MachineImpl.h"
    33 #endif
     29#include "ConsoleSharedFolderImpl.h"
    3430#include "ConsoleImpl.h"
    3531
     
    4137
    4238/////////////////////////////////////////////////////////////////////////////
    43 // SharedFolder::Data structure
    44 /////////////////////////////////////////////////////////////////////////////
    45 
    46 struct SharedFolder::Data
     39// ConsoleSharedFolder::Data structure
     40/////////////////////////////////////////////////////////////////////////////
     41
     42struct ConsoleSharedFolder::Data
    4743{
    4844    Data()
     
    6258/////////////////////////////////////////////////////////////////////////////
    6359
    64 SharedFolder::SharedFolder()
     60ConsoleSharedFolder::ConsoleSharedFolder()
    6561    : mParent(NULL),
    66 #if !defined(VBOX_COM_INPROC)
    67       mMachine(NULL),
    68       mVirtualBox(NULL)
    69 #else
    7062      mConsole(NULL)
    71 #endif
    7263{
    7364    m = new Data;
    7465}
    7566
    76 SharedFolder::~SharedFolder()
     67ConsoleSharedFolder::~ConsoleSharedFolder()
    7768{
    7869    delete m;
     
    8071}
    8172
    82 HRESULT SharedFolder::FinalConstruct()
     73HRESULT ConsoleSharedFolder::FinalConstruct()
    8374{
    8475    return BaseFinalConstruct();
    8576}
    8677
    87 void SharedFolder::FinalRelease()
     78void ConsoleSharedFolder::FinalRelease()
    8879{
    8980    uninit();
     
    9485/////////////////////////////////////////////////////////////////////////////
    9586
    96 #if !defined(VBOX_COM_INPROC)
    9787/**
    9888 *  Initializes the shared folder object.
    9989 *
    100  *  This variant initializes a machine instance that lives in the server address space.
    101  *
    102  *  @param aMachine     parent Machine object
     90 *  This variant initializes an instance that lives in the console address space.
     91 *
     92 *  @param aConsole     Console parent object
    10393 *  @param aName        logical name of the shared folder
    10494 *  @param aHostPath    full path to the shared folder on the host
    10595 *  @param aWritable    writable if true, readonly otherwise
    106  *  @param aAutoMount   if auto mounted by guest true, false otherwise
    10796 *  @param aAutoMountPoint Where the guest should try auto mount it.
    10897 *  @param fFailOnError Whether to fail with an error if the shared folder path is bad.
     
    11099 *  @return          COM result indicator
    111100 */
    112 HRESULT SharedFolder::init(Machine *aMachine,
     101HRESULT ConsoleSharedFolder::init(Console *aConsole,
    113102                           const Utf8Str &aName,
    114103                           const Utf8Str &aHostPath,
     
    122111    AssertReturn(autoInitSpan.isOk(), E_FAIL);
    123112
    124     unconst(mMachine) = aMachine;
    125 
    126     HRESULT hrc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
     113    unconst(mConsole) = aConsole;
     114
     115    HRESULT hrc = i_protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
    127116
    128117    /* Confirm a successful initialization when it's the case */
     
    134123
    135124/**
    136  *  Initializes the shared folder object given another object
    137  *  (a kind of copy constructor).  This object makes a private copy of data
    138  *  of the original object passed as an argument.
    139  *
    140  *  @param aMachine     parent Machine object
    141  *  @param aThat        shared folder object to copy
    142  *
    143  *  @return          COM result indicator
    144  */
    145 HRESULT SharedFolder::initCopy(Machine *aMachine, SharedFolder *aThat)
    146 {
    147     ComAssertRet(aThat, E_INVALIDARG);
    148 
    149     /* Enclose the state transition NotReady->InInit->Ready */
    150     AutoInitSpan autoInitSpan(this);
    151     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    152 
    153     unconst(mMachine) = aMachine;
    154 
    155     HRESULT hrc = i_protectedInit(aMachine,
    156                                   aThat->m->strName,
    157                                   aThat->m->strHostPath,
    158                                   aThat->m->fWritable,
    159                                   aThat->m->fAutoMount,
    160                                   aThat->m->strAutoMountPoint,
    161                                   false /* fFailOnError */ );
    162 
    163     /* Confirm a successful initialization when it's the case */
    164     if (SUCCEEDED(hrc))
    165         autoInitSpan.setSucceeded();
    166 
    167     return hrc;
    168 }
    169 
    170 # if 0
    171 
    172 /**
    173  *  Initializes the shared folder object.
    174  *
    175  *  This variant initializes a global instance that lives in the server address space. It is not presently used.
    176  *
    177  *  @param aVirtualBox  VirtualBox parent object
    178  *  @param aName        logical name of the shared folder
    179  *  @param aHostPath    full path to the shared folder on the host
    180  *  @param aWritable    writable if true, readonly otherwise
    181  *  @param aAutoMountPoint Where the guest should try auto mount it.
    182  *  @param fFailOnError Whether to fail with an error if the shared folder path is bad.
    183  *
    184  *  @return          COM result indicator
    185  */
    186 HRESULT SharedFolder::init(VirtualBox *aVirtualBox,
    187                            const Utf8Str &aName,
    188                            const Utf8Str &aHostPath,
    189                            bool aWritable,
    190                            bool aAutoMount,
    191                            const Utf8Str &aAutoMountPoint
    192                            bool fFailOnError)
    193 {
    194     /* Enclose the state transition NotReady->InInit->Ready */
    195     AutoInitSpan autoInitSpan(this);
    196     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    197 
    198     unconst(mVirtualBox) = aVirtualBox;
    199 
    200     HRESULT hrc = protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
    201 
    202     /* Confirm a successful initialization when it's the case */
    203     if (SUCCEEDED(hrc))
    204         autoInitSpan.setSucceeded();
    205 
    206     return hrc;
    207 }
    208 
    209 # endif
    210 
    211 #else
    212 
    213 /**
    214  *  Initializes the shared folder object.
    215  *
    216  *  This variant initializes an instance that lives in the console address space.
    217  *
    218  *  @param aConsole     Console parent object
    219  *  @param aName        logical name of the shared folder
    220  *  @param aHostPath    full path to the shared folder on the host
    221  *  @param aWritable    writable if true, readonly otherwise
    222  *  @param aAutoMountPoint Where the guest should try auto mount it.
    223  *  @param fFailOnError Whether to fail with an error if the shared folder path is bad.
    224  *
    225  *  @return          COM result indicator
    226  */
    227 HRESULT SharedFolder::init(Console *aConsole,
    228                            const Utf8Str &aName,
    229                            const Utf8Str &aHostPath,
    230                            bool aWritable,
    231                            bool aAutoMount,
    232                            const Utf8Str &aAutoMountPoint,
    233                            bool fFailOnError)
    234 {
    235     /* Enclose the state transition NotReady->InInit->Ready */
    236     AutoInitSpan autoInitSpan(this);
    237     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    238 
    239     unconst(mConsole) = aConsole;
    240 
    241     HRESULT hrc = i_protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
    242 
    243     /* Confirm a successful initialization when it's the case */
    244     if (SUCCEEDED(hrc))
    245         autoInitSpan.setSucceeded();
    246 
    247     return hrc;
    248 }
    249 #endif
    250 
    251 /**
    252125 *  Shared initialization code. Called from the other constructors.
    253126 *
     
    255128 *      Must be called from under the object's lock!
    256129 */
    257 HRESULT SharedFolder::i_protectedInit(VirtualBoxBase *aParent,
     130HRESULT ConsoleSharedFolder::i_protectedInit(VirtualBoxBase *aParent,
    258131                                      const Utf8Str &aName,
    259132                                      const Utf8Str &aHostPath,
     
    326199 *  Called either from FinalRelease() or by the parent when it gets destroyed.
    327200 */
    328 void SharedFolder::uninit()
     201void ConsoleSharedFolder::uninit()
    329202{
    330203    LogFlowThisFunc(("\n"));
     
    336209
    337210    unconst(mParent) = NULL;
    338 
    339 #if !defined(VBOX_COM_INPROC)
    340     unconst(mMachine) = NULL;
    341     unconst(mVirtualBox) = NULL;
    342 #else
    343211    unconst(mConsole) = NULL;
    344 #endif
    345212}
    346213
    347214// wrapped ISharedFolder properties
    348215/////////////////////////////////////////////////////////////////////////////
    349 HRESULT SharedFolder::getName(com::Utf8Str &aName)
     216HRESULT ConsoleSharedFolder::getName(com::Utf8Str &aName)
    350217{
    351218    /* mName is constant during life time, no need to lock */
     
    354221}
    355222
    356 HRESULT SharedFolder::getHostPath(com::Utf8Str &aHostPath)
     223HRESULT ConsoleSharedFolder::getHostPath(com::Utf8Str &aHostPath)
    357224{
    358225    /* mHostPath is constant during life time, no need to lock */
     
    361228}
    362229
    363 HRESULT SharedFolder::getAccessible(BOOL *aAccessible)
     230HRESULT ConsoleSharedFolder::getAccessible(BOOL *aAccessible)
    364231{
    365232    /* mName and mHostPath are constant during life time, no need to lock */
     
    391258}
    392259
    393 HRESULT SharedFolder::getWritable(BOOL *aWritable)
     260HRESULT ConsoleSharedFolder::getWritable(BOOL *aWritable)
    394261{
    395262    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    398265}
    399266
    400 HRESULT SharedFolder::setWritable(BOOL aWritable)
     267HRESULT ConsoleSharedFolder::setWritable(BOOL aWritable)
    401268{
    402269    RT_NOREF(aWritable);
     
    404271}
    405272
    406 HRESULT SharedFolder::getAutoMount(BOOL *aAutoMount)
     273HRESULT ConsoleSharedFolder::getAutoMount(BOOL *aAutoMount)
    407274{
    408275    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    411278}
    412279
    413 HRESULT SharedFolder::setAutoMount(BOOL aAutoMount)
     280HRESULT ConsoleSharedFolder::setAutoMount(BOOL aAutoMount)
    414281{
    415282    RT_NOREF(aAutoMount);
     
    417284}
    418285
    419 HRESULT SharedFolder::getAutoMountPoint(com::Utf8Str &aAutoMountPoint)
     286HRESULT ConsoleSharedFolder::getAutoMountPoint(com::Utf8Str &aAutoMountPoint)
    420287{
    421288    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    424291}
    425292
    426 HRESULT SharedFolder::setAutoMountPoint(com::Utf8Str const &aAutoMountPoint)
     293HRESULT ConsoleSharedFolder::setAutoMountPoint(com::Utf8Str const &aAutoMountPoint)
    427294{
    428295    RT_NOREF(aAutoMountPoint);
     
    430297}
    431298
    432 HRESULT SharedFolder::getLastAccessError(com::Utf8Str &aLastAccessError)
     299HRESULT ConsoleSharedFolder::getLastAccessError(com::Utf8Str &aLastAccessError)
    433300{
    434301    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    438305
    439306
    440 const Utf8Str& SharedFolder::i_getName() const
     307const Utf8Str& ConsoleSharedFolder::i_getName() const
    441308{
    442309    return m->strName;
    443310}
    444311
    445 const Utf8Str& SharedFolder::i_getHostPath() const
     312const Utf8Str& ConsoleSharedFolder::i_getHostPath() const
    446313{
    447314    return m->strHostPath;
    448315}
    449316
    450 bool SharedFolder::i_isWritable() const
     317bool ConsoleSharedFolder::i_isWritable() const
    451318{
    452319    return m->fWritable;
    453320}
    454321
    455 bool SharedFolder::i_isAutoMounted() const
     322bool ConsoleSharedFolder::i_isAutoMounted() const
    456323{
    457324    return m->fAutoMount;
    458325}
    459326
    460 const Utf8Str &SharedFolder::i_getAutoMountPoint() const
     327const Utf8Str &ConsoleSharedFolder::i_getAutoMountPoint() const
    461328{
    462329    return m->strAutoMountPoint;
  • trunk/src/VBox/Main/src-all/MachineSharedFolderImpl.cpp

    r98048 r98340  
    2727
    2828#define LOG_GROUP LOG_GROUP_MAIN_SHAREDFOLDER
    29 #include "SharedFolderImpl.h"
    30 #if !defined(VBOX_COM_INPROC)
    31 # include "VirtualBoxImpl.h"
    32 # include "MachineImpl.h"
    33 #endif
     29#include "MachineSharedFolderImpl.h"
     30#include "VirtualBoxImpl.h"
     31#include "MachineImpl.h"
    3432#include "ConsoleImpl.h"
    3533
     
    6462SharedFolder::SharedFolder()
    6563    : mParent(NULL),
    66 #if !defined(VBOX_COM_INPROC)
    6764      mMachine(NULL),
    6865      mVirtualBox(NULL)
    69 #else
    70       mConsole(NULL)
    71 #endif
    7266{
    7367    m = new Data;
     
    9488/////////////////////////////////////////////////////////////////////////////
    9589
    96 #if !defined(VBOX_COM_INPROC)
    9790/**
    9891 *  Initializes the shared folder object.
     
    189182                           bool aWritable,
    190183                           bool aAutoMount,
    191                            const Utf8Str &aAutoMountPoint
     184                           const Utf8Str &aAutoMountPoint,
    192185                           bool fFailOnError)
    193186{
     
    208201
    209202# endif
    210 
    211 #else
    212 
    213 /**
    214  *  Initializes the shared folder object.
    215  *
    216  *  This variant initializes an instance that lives in the console address space.
    217  *
    218  *  @param aConsole     Console parent object
    219  *  @param aName        logical name of the shared folder
    220  *  @param aHostPath    full path to the shared folder on the host
    221  *  @param aWritable    writable if true, readonly otherwise
    222  *  @param aAutoMountPoint Where the guest should try auto mount it.
    223  *  @param fFailOnError Whether to fail with an error if the shared folder path is bad.
    224  *
    225  *  @return          COM result indicator
    226  */
    227 HRESULT SharedFolder::init(Console *aConsole,
    228                            const Utf8Str &aName,
    229                            const Utf8Str &aHostPath,
    230                            bool aWritable,
    231                            bool aAutoMount,
    232                            const Utf8Str &aAutoMountPoint,
    233                            bool fFailOnError)
    234 {
    235     /* Enclose the state transition NotReady->InInit->Ready */
    236     AutoInitSpan autoInitSpan(this);
    237     AssertReturn(autoInitSpan.isOk(), E_FAIL);
    238 
    239     unconst(mConsole) = aConsole;
    240 
    241     HRESULT hrc = i_protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError);
    242 
    243     /* Confirm a successful initialization when it's the case */
    244     if (SUCCEEDED(hrc))
    245         autoInitSpan.setSucceeded();
    246 
    247     return hrc;
    248 }
    249 #endif
    250203
    251204/**
     
    336289
    337290    unconst(mParent) = NULL;
    338 
    339 #if !defined(VBOX_COM_INPROC)
    340291    unconst(mMachine) = NULL;
    341292    unconst(mVirtualBox) = NULL;
    342 #else
    343     unconst(mConsole) = NULL;
    344 #endif
    345293}
    346294
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