Changeset 6379 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 18, 2008 5:25:20 PM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r6375 r6379 882 882 vrc = SSMR3PutStrZ (pSSM, hostPath); 883 883 AssertRC (vrc); 884 885 // XXX 886 // vrc = SSMR3PutBool (pSSM, folder->writable()); 887 // AssertRC (vrc); 884 888 } 885 889 … … 953 957 ComObjPtr <SharedFolder> sharedFolder; 954 958 sharedFolder.createObject(); 955 HRESULT rc = sharedFolder->init (that, name, hostPath );959 HRESULT rc = sharedFolder->init (that, name, hostPath, PR_TRUE); /* TODO: fWritable */ 956 960 AssertComRCReturn (rc, VERR_INTERNAL_ERROR); 957 961 … … 1315 1319 for (SharedFolderMap::const_iterator it = mSharedFolders.begin(); 1316 1320 it != mSharedFolders.end(); ++ it) 1317 sharedFolders [it->first] = it->second->hostPath();1321 sharedFolders [it->first] = SharedFolderData(it->second->hostPath(), it->second->writable()); 1318 1322 } 1319 1323 … … 1991 1995 1992 1996 STDMETHODIMP 1993 Console::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath )1997 Console::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable) 1994 1998 { 1995 1999 if (!aName || !aHostPath) … … 2019 2023 2020 2024 sharedFolder.createObject(); 2021 rc = sharedFolder->init (this, aName, aHostPath );2025 rc = sharedFolder->init (this, aName, aHostPath, aWritable); 2022 2026 CheckComRCReturnRC (rc); 2023 2027 … … 2047 2051 2048 2052 /* second, create the given folder */ 2049 rc = createSharedFolder (aName, aHostPath);2053 rc = createSharedFolder (aName, SharedFolderData (aHostPath, aWritable)); 2050 2054 CheckComRCReturnRC (rc); 2051 2055 } … … 4195 4199 Bstr name; 4196 4200 Bstr hostPath; 4201 BOOL writable; 4197 4202 4198 4203 rc = folder->COMGETTER(Name) (name.asOutParam()); … … 4200 4205 rc = folder->COMGETTER(HostPath) (hostPath.asOutParam()); 4201 4206 CheckComRCBreakRC (rc); 4202 4203 mMachineSharedFolders.insert (std::make_pair (name, hostPath)); 4207 rc = folder->COMGETTER(Writable) (&writable); 4208 4209 mMachineSharedFolders.insert (std::make_pair (name, SharedFolderData (hostPath, writable))); 4204 4210 4205 4211 /* send changes to HGCM if the VM is running */ … … 4208 4214 { 4209 4215 SharedFolderDataMap::iterator it = oldFolders.find (name); 4210 if (it == oldFolders.end() || it->second != hostPath)4216 if (it == oldFolders.end() || it->second.mHostPath != hostPath) 4211 4217 { 4212 4218 /* a new machine folder is added or … … 4223 4229 rc = removeSharedFolder (name); 4224 4230 /* create the new machine folder */ 4225 rc = createSharedFolder (name, hostPath);4231 rc = createSharedFolder (name, SharedFolderData (hostPath, writable)); 4226 4232 } 4227 4233 } … … 4302 4308 * @note Doesn't lock anything. 4303 4309 */ 4304 HRESULT Console::createSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath)4310 HRESULT Console::createSharedFolder (INPTR BSTR aName, SharedFolderData aData) 4305 4311 { 4306 4312 ComAssertRet (aName && *aName, E_FAIL); 4307 ComAssertRet (a HostPath && *aHostPath, E_FAIL);4313 ComAssertRet (aData.mHostPath && *aData.mHostPath, E_FAIL); 4308 4314 4309 4315 /* sanity checks */ … … 4311 4317 AssertReturn (mVMMDev->isShFlActive(), E_FAIL); 4312 4318 4313 VBOXHGCMSVCPARM parms[ 2];4319 VBOXHGCMSVCPARM parms[SHFL_CPARMS_ADD_MAPPING]; 4314 4320 SHFLSTRING *pFolderName, *pMapName; 4315 4321 size_t cbString; … … 4317 4323 Log (("Adding shared folder '%ls' -> '%ls'\n", aName, aHostPath)); 4318 4324 4319 cbString = (RTStrUcs2Len (a HostPath) + 1) * sizeof (RTUCS2);4325 cbString = (RTStrUcs2Len (aData.mHostPath) + 1) * sizeof (RTUCS2); 4320 4326 if (cbString >= UINT16_MAX) 4321 4327 return setError (E_INVALIDARG, tr ("The name is too long")); 4322 4328 pFolderName = (SHFLSTRING *) RTMemAllocZ (sizeof (SHFLSTRING) + cbString); 4323 4329 Assert (pFolderName); 4324 memcpy (pFolderName->String.ucs2, a HostPath, cbString);4330 memcpy (pFolderName->String.ucs2, aData.mHostPath, cbString); 4325 4331 4326 4332 pFolderName->u16Size = (uint16_t)cbString; … … 4348 4354 parms[1].u.pointer.size = sizeof (SHFLSTRING) + (uint16_t)cbString; 4349 4355 4356 parms[2].type = VBOX_HGCM_SVC_PARM_32BIT; 4357 parms[2].u.uint32 = aData.mWritable; 4358 4350 4359 int vrc = mVMMDev->hgcmHostCall ("VBoxSharedFolders", 4351 4360 SHFL_FN_ADD_MAPPING, 4352 2, &parms[0]);4361 SHFL_CPARMS_ADD_MAPPING, &parms[0]); 4353 4362 RTMemFree (pFolderName); 4354 4363 RTMemFree (pMapName); … … 4358 4367 tr ("Could not create a shared folder '%ls' " 4359 4368 "mapped to '%ls' (%Vrc)"), 4360 aName, a HostPath, vrc);4369 aName, aData.mHostPath.raw(), vrc); 4361 4370 4362 4371 return S_OK; -
trunk/src/VBox/Main/MachineImpl.cpp
r6367 r6379 2372 2372 2373 2373 STDMETHODIMP 2374 Machine::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath )2374 Machine::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable) 2375 2375 { 2376 2376 if (!aName || !aHostPath) … … 2392 2392 2393 2393 sharedFolder.createObject(); 2394 rc = sharedFolder->init (machine(), aName, aHostPath );2394 rc = sharedFolder->init (machine(), aName, aHostPath, aWritable); 2395 2395 CheckComRCReturnRC (rc); 2396 2396 … … 4314 4314 Bstr hostPath = (*it).stringValue ("hostPath"); 4315 4315 4316 rc = CreateSharedFolder (name, hostPath); 4316 bool writable = (*it).value <bool> ("writable"); 4317 4318 rc = CreateSharedFolder (name, hostPath, writable); 4317 4319 CheckComRCReturnRC (rc); 4318 4320 } … … 5661 5663 folderNode.setValue <Bstr> ("name", folder->name()); 5662 5664 folderNode.setValue <Bstr> ("hostPath", folder->hostPath()); 5665 folderNode.setValue <bool> ("writable", folder->writable()); 5663 5666 } 5664 5667 } -
trunk/src/VBox/Main/SharedFolderImpl.cpp
r5999 r6379 58 58 * @param aName logical name of the shared folder 59 59 * @param aHostPath full path to the shared folder on the host 60 * @param aWritable writable if true, readonly otherwise 60 61 * 61 62 * @return COM result indicator 62 63 */ 63 64 HRESULT SharedFolder::init (Machine *aMachine, 64 const BSTR aName, const BSTR aHostPath )65 const BSTR aName, const BSTR aHostPath, bool aWritable) 65 66 { 66 67 /* Enclose the state transition NotReady->InInit->Ready */ … … 70 71 unconst (mMachine) = aMachine; 71 72 72 HRESULT rc = protectedInit (aMachine, aName, aHostPath );73 HRESULT rc = protectedInit (aMachine, aName, aHostPath, aWritable); 73 74 74 75 /* Confirm a successful initialization when it's the case */ … … 100 101 101 102 HRESULT rc = protectedInit (aMachine, aThat->mData.mName, 102 aThat->mData.mHostPath );103 aThat->mData.mHostPath, aThat->mData.mWritable); 103 104 104 105 /* Confirm a successful initialization when it's the case */ … … 115 116 * @param aName logical name of the shared folder 116 117 * @param aHostPath full path to the shared folder on the host 118 * @param aWritable writable if true, readonly otherwise 117 119 * 118 120 * @return COM result indicator 119 121 */ 120 122 HRESULT SharedFolder::init (Console *aConsole, 121 const BSTR aName, const BSTR aHostPath )123 const BSTR aName, const BSTR aHostPath, bool aWritable) 122 124 { 123 125 /* Enclose the state transition NotReady->InInit->Ready */ … … 127 129 unconst (mConsole) = aConsole; 128 130 129 HRESULT rc = protectedInit (aConsole, aName, aHostPath );131 HRESULT rc = protectedInit (aConsole, aName, aHostPath, aWritable); 130 132 131 133 /* Confirm a successful initialization when it's the case */ … … 142 144 * @param aName logical name of the shared folder 143 145 * @param aHostPath full path to the shared folder on the host 146 * @param aWritable writable if true, readonly otherwise 144 147 * 145 148 * @return COM result indicator 146 149 */ 147 150 HRESULT SharedFolder::init (VirtualBox *aVirtualBox, 148 const BSTR aName, const BSTR aHostPath )151 const BSTR aName, const BSTR aHostPath, bool aWritable) 149 152 { 150 153 /* Enclose the state transition NotReady->InInit->Ready */ … … 154 157 unconst (mVirtualBox) = aVirtualBox; 155 158 156 HRESULT rc = protectedInit (aVirtualBox, aName, aHostPath );159 HRESULT rc = protectedInit (aVirtualBox, aName, aHostPath, aWritable); 157 160 158 161 /* Confirm a successful initialization when it's the case */ … … 170 173 */ 171 174 HRESULT SharedFolder::protectedInit (VirtualBoxBaseWithChildrenNEXT *aParent, 172 const BSTR aName, const BSTR aHostPath) 173 { 174 LogFlowThisFunc (("aName={%ls}, aHostPath={%ls}\n", aName, aHostPath)); 175 const BSTR aName, const BSTR aHostPath, bool aWritable) 176 { 177 LogFlowThisFunc (("aName={%ls}, aHostPath={%ls}, aWritable={%d}\n", 178 aName, aHostPath, aWritable)); 175 179 176 180 ComAssertRet (aParent && aName && aHostPath, E_INVALIDARG); … … 216 220 unconst (mData.mName) = aName; 217 221 unconst (mData.mHostPath) = hostPath; 222 mData.mWritable = aWritable; 218 223 219 224 return S_OK; … … 307 312 } 308 313 314 STDMETHODIMP SharedFolder::COMGETTER(Writable) (BOOL *aWritable) 315 { 316 if (!aWritable) 317 return E_POINTER; 318 319 *aWritable = mData.mWritable; 320 321 return S_OK; 322 } -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r6367 r6379 1575 1575 1576 1576 STDMETHODIMP 1577 VirtualBox::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath )1577 VirtualBox::CreateSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable) 1578 1578 { 1579 1579 if (!aName || !aHostPath) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r6265 r6379 1573 1573 <desc>Full path to the shared folder in the host file system.</desc> 1574 1574 </param> 1575 <param name="writable" type="boolean" dir="in"> 1576 <desc>Whether the share is writable or readonly</desc> 1577 </param> 1575 1578 </method> 1576 1579 … … 3046 3049 <desc>Full path to the shared folder in the host file system.</desc> 3047 3050 </param> 3051 <param name="writable" type="boolean" dir="in"> 3052 <desc>Whether the share is writable or readonly</desc> 3053 </param> 3048 3054 </method> 3049 3055 … … 3901 3907 <param name="hostPath" type="wstring" dir="in"> 3902 3908 <desc>Full path to the shared folder in the host file system.</desc> 3909 </param> 3910 <param name="writable" type="boolean" dir="in"> 3911 <desc>Whether the share is writable or readonly</desc> 3903 3912 </param> 3904 3913 </method> … … 9037 9046 </desc> 9038 9047 </attribute> 9048 9049 <attribute name="writable" type="boolean" readonly="yes"> 9050 <desc> 9051 Whether the folder defined by the host path is writable or 9052 not. 9053 </desc> 9054 </attribute> 9039 9055 9040 9056 </interface> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r6156 r6379 134 134 STDMETHOD(AttachUSBDevice) (INPTR GUIDPARAM aId); 135 135 STDMETHOD(DetachUSBDevice) (INPTR GUIDPARAM aId, IUSBDevice **aDevice); 136 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath );136 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable); 137 137 STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName); 138 138 STDMETHOD(TakeSnapshot) (INPTR BSTR aName, INPTR BSTR aDescription, … … 353 353 typedef SafeVMPtrBase <true> SafeVMPtrQuiet; 354 354 355 class SharedFolderData 356 { 357 public: 358 SharedFolderData() {} 359 SharedFolderData(Bstr aHostPath, BOOL aWritable) 360 : mHostPath (aHostPath) 361 , mWritable (aWritable) {} 362 SharedFolderData(const SharedFolderData& aThat) 363 : mHostPath (aThat.mHostPath) 364 , mWritable (aThat.mWritable) {} 365 Bstr mHostPath; 366 BOOL mWritable; 367 }; 355 368 typedef std::map <Bstr, ComObjPtr <SharedFolder> > SharedFolderMap; 356 typedef std::map <Bstr, Bstr> SharedFolderDataMap;369 typedef std::map <Bstr, SharedFolderData> SharedFolderDataMap; 357 370 358 371 private: … … 386 399 SharedFolderDataMap::const_iterator &aIt); 387 400 388 HRESULT createSharedFolder (INPTR BSTR aName, INPTR BSTR aHostPath);401 HRESULT createSharedFolder (INPTR BSTR aName, SharedFolderData aData); 389 402 HRESULT removeSharedFolder (INPTR BSTR aName); 390 403 -
trunk/src/VBox/Main/include/MachineImpl.h
r6076 r6379 498 498 STDMETHOD(FindSnapshot) (INPTR BSTR aName, ISnapshot **aSnapshot); 499 499 STDMETHOD(SetCurrentSnapshot) (INPTR GUIDPARAM aId); 500 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath );500 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable); 501 501 STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName); 502 502 STDMETHOD(CanShowConsoleWindow) (BOOL *aCanShow); -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r5999 r6379 41 41 const Bstr mName; 42 42 const Bstr mHostPath; 43 bool mWritable; 43 44 }; 44 45 … … 62 63 63 64 // public initializer/uninitializer for internal purposes only 64 HRESULT init (Machine *aMachine, const BSTR aName, const BSTR aHostPath );65 HRESULT init (Machine *aMachine, const BSTR aName, const BSTR aHostPath, bool aWritable); 65 66 HRESULT initCopy (Machine *aMachine, SharedFolder *aThat); 66 HRESULT init (Console *aConsole, const BSTR aName, const BSTR aHostPath );67 HRESULT init (VirtualBox *aVirtualBox, const BSTR aName, const BSTR aHostPath );67 HRESULT init (Console *aConsole, const BSTR aName, const BSTR aHostPath, bool aWritable); 68 HRESULT init (VirtualBox *aVirtualBox, const BSTR aName, const BSTR aHostPath, bool aWritable); 68 69 void uninit(); 69 70 … … 72 73 STDMETHOD(COMGETTER(HostPath)) (BSTR *aHostPath); 73 74 STDMETHOD(COMGETTER(Accessible)) (BOOL *aAccessible); 75 STDMETHOD(COMGETTER(Writable)) (BOOL *aWritable); 74 76 75 77 // public methods for internal purposes only … … 81 83 const Bstr &name() const { return mData.mName; } 82 84 const Bstr &hostPath() const { return mData.mHostPath; } 85 BOOL writable() const { return mData.mWritable; } 83 86 84 87 // for VirtualBoxSupportErrorInfoImpl … … 88 91 89 92 HRESULT protectedInit (VirtualBoxBaseWithChildrenNEXT *aParent, 90 const BSTR aName, const BSTR aHostPath );93 const BSTR aName, const BSTR aHostPath, bool aWritable); 91 94 92 95 private: -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r6076 r6379 161 161 162 162 STDMETHOD(GetGuestOSType) (INPTR BSTR aId, IGuestOSType **aType); 163 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath );163 STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable); 164 164 STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName); 165 165 STDMETHOD(GetNextExtraDataKey) (INPTR BSTR aKey, BSTR *aNextKey, BSTR *aNextValue); -
trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd
r6173 r6379 630 630 <xsd:attribute name="name" type="TNonEmptyString" use="required"/> 631 631 <xsd:attribute name="hostPath" type="TLocalFile" use="required"/> 632 <xsd:attribute name="writable" type="xsd:boolean" default="true"/> 632 633 </xsd:complexType> 633 634
Note:
See TracChangeset
for help on using the changeset viewer.