Changeset 2929 in vbox
- Timestamp:
- May 30, 2007 1:31:16 PM (18 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostDVDDriveImpl.cpp
r2917 r2929 25 25 ///////////////////////////////////////////////////////////////////////////// 26 26 27 HostDVDDrive::HostDVDDrive() 27 DEFINE_EMPTY_CTOR_DTOR (HostDVDDrive) 28 29 HRESULT HostDVDDrive::FinalConstruct() 28 30 { 31 return S_OK; 29 32 } 30 33 31 HostDVDDrive::~HostDVDDrive()34 void HostDVDDrive::FinalRelease() 32 35 { 36 uninit(); 33 37 } 34 38 … … 37 41 38 42 /** 39 * Initializes the host object.43 * Initializes the host DVD drive object. 40 44 * 41 * @returns COM result indicator 42 * @param driveName name of the drive 45 * @param aName Name of the drive. 46 * @param aDescription Human-readable drive description (may be NULL). 47 * 48 * @return COM result indicator. 43 49 */ 44 HRESULT HostDVDDrive::init (INPTR BSTR driveName) 50 HRESULT HostDVDDrive::init (INPTR BSTR aName, 51 INPTR BSTR aDescription /* = NULL */) 45 52 { 46 ComAssertRet ( driveName, E_INVALIDARG);53 ComAssertRet (aName, E_INVALIDARG); 47 54 48 AutoLock lock(this); 49 mDriveName = driveName; 50 setReady(true); 55 /* Enclose the state transition NotReady->InInit->Ready */ 56 AutoInitSpan autoInitSpan (this); 57 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED); 58 59 unconst (mName) = aName; 60 unconst (mDescription) = aDescription; 61 62 /* Confirm the successful initialization */ 63 autoInitSpan.setSucceeded(); 64 51 65 return S_OK; 52 66 } 53 67 54 68 /** 55 * Initializes the host object. 56 * 57 * @returns COM result indicator 58 * @param driveName name of the drive 59 * @param driveDescription human readable description of the drive 69 * Uninitializes the instance and sets the ready flag to FALSE. 70 * Called either from FinalRelease() or by the parent when it gets destroyed. 60 71 */ 61 HRESULT HostDVDDrive::init (INPTR BSTR driveName, INPTR BSTR driveDescription)72 void HostDVDDrive::uninit() 62 73 { 63 ComAssertRet (driveName, E_INVALIDARG); 64 ComAssertRet (driveDescription, E_INVALIDARG); 74 /* Enclose the state transition Ready->InUninit->NotReady */ 75 AutoUninitSpan autoUninitSpan (this); 76 if (autoUninitSpan.uninitDone()) 77 return; 65 78 66 AutoLock lock(this); 67 mDriveName = driveName; 68 mDriveDescription = driveDescription; 69 setReady(true); 70 return S_OK; 79 unconst (mDescription).setNull(); 80 unconst (mName).setNull(); 71 81 } 72 82 … … 74 84 ///////////////////////////////////////////////////////////////////////////// 75 85 76 /** 77 * Returns the name of the host drive 78 * 79 * @returns COM status code 80 * @param driveName address of result pointer 81 */ 82 STDMETHODIMP HostDVDDrive::COMGETTER(Name) (BSTR *driveName) 86 STDMETHODIMP HostDVDDrive::COMGETTER(Name) (BSTR *aName) 83 87 { 84 if (! driveName)88 if (!aName) 85 89 return E_POINTER; 86 AutoLock lock(this); 87 CHECK_READY(); 88 mDriveName.cloneTo(driveName); 90 91 AutoCaller autoCaller (this); 92 CheckComRCReturnRC (autoCaller.rc()); 93 94 /* mName is constant during life time, no need to lock */ 95 96 mName.cloneTo (aName); 97 89 98 return S_OK; 90 99 } 91 100 92 /** 93 * Returns the description of the host drive 94 * 95 * @returns COM status code 96 * @param driveDescription address of result pointer 97 */ 98 STDMETHODIMP HostDVDDrive::COMGETTER(Description) (BSTR *driveDescription) 101 STDMETHODIMP HostDVDDrive::COMGETTER(Description) (BSTR *aDescription) 99 102 { 100 if (! driveDescription)103 if (!aDescription) 101 104 return E_POINTER; 102 AutoLock lock(this); 103 CHECK_READY(); 104 mDriveDescription.cloneTo(driveDescription); 105 106 AutoCaller autoCaller (this); 107 CheckComRCReturnRC (autoCaller.rc()); 108 109 /* mDescription is constant during life time, no need to lock */ 110 111 mDescription.cloneTo (aDescription); 112 105 113 return S_OK; 106 114 } -
trunk/src/VBox/Main/HostFloppyDriveImpl.cpp
r1 r2929 25 25 ///////////////////////////////////////////////////////////////////////////// 26 26 27 HostFloppyDrive::HostFloppyDrive() 27 DEFINE_EMPTY_CTOR_DTOR (HostFloppyDrive) 28 29 HRESULT HostFloppyDrive::FinalConstruct() 28 30 { 31 return S_OK; 29 32 } 30 33 31 HostFloppyDrive::~HostFloppyDrive()34 void HostFloppyDrive::FinalRelease() 32 35 { 36 uninit(); 33 37 } 34 38 … … 39 43 * Initializes the host floppy drive object. 40 44 * 41 * @returns COM result indicator 42 * @param driveName name of the drive 45 * @param aName Name of the drive. 46 * 47 * @return COM result indicator. 43 48 */ 44 HRESULT HostFloppyDrive::init (INPTR BSTR driveName)49 HRESULT HostFloppyDrive::init (INPTR BSTR aName) 45 50 { 46 ComAssertRet ( driveName, E_INVALIDARG);51 ComAssertRet (aName, E_INVALIDARG); 47 52 48 AutoLock lock(this); 49 mDriveName = driveName; 50 setReady(true); 53 /* Enclose the state transition NotReady->InInit->Ready */ 54 AutoInitSpan autoInitSpan (this); 55 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED); 56 57 unconst (mName) = aName; 58 59 /* Confirm the successful initialization */ 60 autoInitSpan.setSucceeded(); 61 51 62 return S_OK; 63 } 64 65 /** 66 * Uninitializes the instance and sets the ready flag to FALSE. 67 * Called either from FinalRelease() or by the parent when it gets destroyed. 68 */ 69 void HostFloppyDrive::uninit() 70 { 71 /* Enclose the state transition Ready->InUninit->NotReady */ 72 AutoUninitSpan autoUninitSpan (this); 73 if (autoUninitSpan.uninitDone()) 74 return; 75 76 unconst (mName).setNull(); 52 77 } 53 78 … … 55 80 ///////////////////////////////////////////////////////////////////////////// 56 81 57 /** 58 * Returns the name of the host drive 59 * 60 * @returns COM status code 61 * @param driveName address of result pointer 62 */ 63 STDMETHODIMP HostFloppyDrive::COMGETTER(Name) (BSTR *driveName) 82 STDMETHODIMP HostFloppyDrive::COMGETTER(Name) (BSTR *aName) 64 83 { 65 if (! driveName)84 if (!aName) 66 85 return E_POINTER; 67 AutoLock lock(this); 68 CHECK_READY(); 69 mDriveName.cloneTo(driveName); 86 87 AutoCaller autoCaller (this); 88 CheckComRCReturnRC (autoCaller.rc()); 89 90 /* mName is constant during life time, no need to lock */ 91 92 mName.cloneTo (aName); 93 70 94 return S_OK; 71 95 } -
trunk/src/VBox/Main/HostImpl.cpp
r2917 r2929 1426 1426 if (validateDevice(devNode, true)) 1427 1427 { 1428 char description[256];1428 Utf8Str description; 1429 1429 char *vendor, *product; 1430 1430 /* We have at least one hit, so operation successful :) */ … … 1434 1434 product = libhal_device_get_property_string(halContext, 1435 1435 halDevices[i], "info.product", &dbusError); 1436 if ((product != 0 ))1436 if ((product != 0 && product[0] != 0)) 1437 1437 { 1438 1438 if (vendor != 0 && vendor[0] != 0) 1439 1439 { 1440 RTStrPrintf(description, sizeof(description),1441 "%s %s (%s)", vendor, product, devNode);1440 description = Utf8StrFmt ("%s %s", 1441 vendor, product); 1442 1442 } 1443 1443 else 1444 1444 { 1445 RTStrPrintf(description, sizeof(description), 1446 "%s (%s)", product, devNode); 1445 description = product; 1447 1446 } 1448 1447 ComObjPtr <HostDVDDrive> hostDVDDriveObj; -
trunk/src/VBox/Main/include/HostDVDDriveImpl.h
r2917 r2929 27 27 28 28 class ATL_NO_VTABLE HostDVDDrive : 29 public VirtualBoxBaseNEXT, 29 30 public VirtualBoxSupportErrorInfoImpl <HostDVDDrive, IHostDVDDrive>, 30 31 public VirtualBoxSupportTranslation <HostDVDDrive>, 31 public VirtualBoxBase,32 32 public IHostDVDDrive 33 33 { 34 34 public: 35 35 36 HostDVDDrive(); 37 virtual ~HostDVDDrive(); 36 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostDVDDrive) 38 37 39 DECLARE_NOT_AGGREGATABLE (HostDVDDrive)38 DECLARE_NOT_AGGREGATABLE (HostDVDDrive) 40 39 41 40 DECLARE_PROTECT_FINAL_CONSTRUCT() … … 48 47 NS_DECL_ISUPPORTS 49 48 49 DECLARE_EMPTY_CTOR_DTOR (HostDVDDrive) 50 51 HRESULT FinalConstruct(); 52 void FinalRelease(); 53 50 54 // public initializer/uninitializer for internal purposes only 51 HRESULT init (INPTR BSTR driveName);52 HRESULT init (INPTR BSTR driveName, INPTR BSTR driveDescription);55 HRESULT init (INPTR BSTR aName, INPTR BSTR aDescription = NULL); 56 void uninit(); 53 57 54 58 // IHostDVDDrive properties 55 STDMETHOD(COMGETTER(Name)) (BSTR * driveName);56 STDMETHOD(COMGETTER(Description)) (BSTR * driveDescription);59 STDMETHOD(COMGETTER(Name)) (BSTR *aName); 60 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription); 57 61 58 62 // public methods for internal purposes only 59 63 60 const Bstr &driveName() const { return mDriveName; } 64 /* @note Must be called from under the object read lock. */ 65 const Bstr &name() const { return mName; } 61 66 62 67 // for VirtualBoxSupportErrorInfoImpl … … 65 70 private: 66 71 67 Bstr mDriveName;68 Bstr mDriveDescription;72 const Bstr mName; 73 const Bstr mDescription; 69 74 }; 70 75 71 76 COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostDVDDrive) 72 77 73 STDMETHOD(FindByName) (INPTR BSTR name, IHostDVDDrive **drive)78 STDMETHOD(FindByName) (INPTR BSTR aName, IHostDVDDrive **aDrive) 74 79 { 75 if (! name)80 if (!aName) 76 81 return E_INVALIDARG; 77 if (! drive)82 if (!aDrive) 78 83 return E_POINTER; 79 84 80 * drive = NULL;85 *aDrive = NULL; 81 86 Vector::value_type found; 82 87 Vector::iterator it = vec.begin(); … … 85 90 Bstr n; 86 91 (*it)->COMGETTER(Name) (n.asOutParam()); 87 if (n == name)92 if (n == aName) 88 93 found = *it; 89 94 ++ it; … … 92 97 if (!found) 93 98 return setError (E_INVALIDARG, HostDVDDriveCollection::tr ( 94 "The host DVD drive named '%ls' could not be found"), name);99 "The host DVD drive named '%ls' could not be found"), aName); 95 100 96 return found.queryInterfaceTo ( drive);101 return found.queryInterfaceTo (aDrive); 97 102 } 98 103 -
trunk/src/VBox/Main/include/HostFloppyDriveImpl.h
r1 r2929 27 27 28 28 class ATL_NO_VTABLE HostFloppyDrive : 29 public VirtualBoxBaseNEXT, 29 30 public VirtualBoxSupportErrorInfoImpl <HostFloppyDrive, IHostFloppyDrive>, 30 31 public VirtualBoxSupportTranslation <HostFloppyDrive>, 31 public VirtualBoxBase,32 32 public IHostFloppyDrive 33 33 { 34 34 public: 35 35 36 HostFloppyDrive(); 37 virtual ~HostFloppyDrive(); 36 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostFloppyDrive) 38 37 39 DECLARE_NOT_AGGREGATABLE (HostFloppyDrive)38 DECLARE_NOT_AGGREGATABLE (HostFloppyDrive) 40 39 41 40 DECLARE_PROTECT_FINAL_CONSTRUCT() … … 48 47 NS_DECL_ISUPPORTS 49 48 49 DECLARE_EMPTY_CTOR_DTOR (HostFloppyDrive) 50 51 HRESULT FinalConstruct(); 52 void FinalRelease(); 53 50 54 // public initializer/uninitializer for internal purposes only 51 HRESULT init (INPTR BSTR driveName); 55 HRESULT init (INPTR BSTR aName); 56 void uninit(); 52 57 53 58 // IHostDVDDrive properties 54 STDMETHOD(COMGETTER(Name)) (BSTR * driveName);59 STDMETHOD(COMGETTER(Name)) (BSTR *aName); 55 60 56 61 // public methods for internal purposes only 57 62 58 const Bstr &driveName() const { return mDriveName; } 63 /* @note Must be called from under the object read lock. */ 64 const Bstr &name() const { return mName; } 59 65 60 66 // for VirtualBoxSupportErrorInfoImpl … … 63 69 private: 64 70 65 Bstr mDriveName;71 const Bstr mName; 66 72 }; 67 73 68 74 COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostFloppyDrive) 69 75 70 STDMETHOD(FindByName) (INPTR BSTR name, IHostFloppyDrive **drive)76 STDMETHOD(FindByName) (INPTR BSTR aName, IHostFloppyDrive **aDrive) 71 77 { 72 if (! name)78 if (!aName) 73 79 return E_INVALIDARG; 74 if (! drive)80 if (!aDrive) 75 81 return E_POINTER; 76 82 77 * drive = NULL;83 *aDrive = NULL; 78 84 Vector::value_type found; 79 85 Vector::iterator it = vec.begin(); … … 82 88 Bstr n; 83 89 (*it)->COMGETTER(Name) (n.asOutParam()); 84 if (n == name)90 if (n == aName) 85 91 found = *it; 86 92 ++ it; … … 89 95 if (!found) 90 96 return setError (E_INVALIDARG, HostFloppyDriveCollection::tr ( 91 "The host floppy drive named '%ls' could not be found"), name);97 "The host floppy drive named '%ls' could not be found"), aName); 92 98 93 return found.queryInterfaceTo ( drive);99 return found.queryInterfaceTo (aDrive); 94 100 } 95 101
Note:
See TracChangeset
for help on using the changeset viewer.