Changeset 31281 in vbox for trunk/src/VBox
- Timestamp:
- Aug 2, 2010 10:35:19 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64308
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r31270 r31281 3216 3216 { 3217 3217 /* find a DVD image by UUID */ 3218 rc = mParent->findDVD Image(&uuid, NULL, true /* aSetError */, &medium);3218 rc = mParent->findDVDOrFloppyImage(DeviceType_DVD, &uuid, Utf8Str::Empty, true /* aSetError */, &medium); 3219 3219 if (FAILED(rc)) return rc; 3220 3220 } … … 3249 3249 { 3250 3250 /* find a floppy image by UUID */ 3251 rc = mParent->find FloppyImage(&uuid, NULL, true /* aSetError */, &medium);3251 rc = mParent->findDVDOrFloppyImage(DeviceType_Floppy, &uuid, Utf8Str::Empty, true /* aSetError */, &medium); 3252 3252 if (FAILED(rc)) return rc; 3253 3253 } … … 3693 3693 { 3694 3694 case DeviceType_DVD: 3695 case DeviceType_Floppy: 3695 3696 if (!uuid.isEmpty()) 3696 3697 { 3697 /* find a DVD by host device UUID */ 3698 MediaList llHostDVDDrives; 3699 rc = mParent->host()->getDVDDrives(llHostDVDDrives); 3698 // check if the UUID refers to a host DVD or floppy drive 3699 MediaList llHostDrives; 3700 rc = (mediumType == DeviceType_DVD) 3701 ? mParent->host()->getDVDDrives(llHostDrives) 3702 : mParent->host()->getFloppyDrives(llHostDrives); 3700 3703 if (SUCCEEDED(rc)) 3701 3704 { 3702 for (MediaList::iterator it = llHostD VDDrives.begin();3703 it != llHostD VDDrives.end();3705 for (MediaList::iterator it = llHostDrives.begin(); 3706 it != llHostDrives.end(); 3704 3707 ++it) 3705 3708 { … … 3712 3715 } 3713 3716 } 3714 /* find a DVD by UUID */ 3717 3715 3718 if (medium.isNull()) 3716 rc = mParent->findDVDImage(&uuid, NULL, true /* aDoSetError */, &medium); 3719 // UUID was not a host drive: 3720 rc = mParent->findDVDOrFloppyImage(mediumType, &uuid, Utf8Str::Empty, true /* aDoSetError */, &medium); 3717 3721 } 3718 3722 if (FAILED(rc)) return rc; 3719 break; 3720 case DeviceType_Floppy: 3721 if (!uuid.isEmpty()) 3722 { 3723 /* find a Floppy by host device UUID */ 3724 MediaList llHostFloppyDrives; 3725 rc = mParent->host()->getFloppyDrives(llHostFloppyDrives); 3726 if (SUCCEEDED(rc)) 3727 { 3728 for (MediaList::iterator it = llHostFloppyDrives.begin(); 3729 it != llHostFloppyDrives.end(); 3730 ++it) 3731 { 3732 ComObjPtr<Medium> &p = *it; 3733 if (uuid == p->getId()) 3734 { 3735 medium = p; 3736 break; 3737 } 3738 } 3739 } 3740 /* find a Floppy by UUID */ 3741 if (medium.isNull()) 3742 rc = mParent->findFloppyImage(&uuid, NULL, true /* aDoSetError */, &medium); 3743 } 3744 if (FAILED(rc)) return rc; 3745 break; 3723 break; 3724 3746 3725 default: 3747 3726 return setError(VBOX_E_INVALID_OBJECT_STATE, … … 7168 7147 /* find a floppy by UUID */ 7169 7148 if (!dev.uuid.isEmpty()) 7170 rc = mParent->find FloppyImage(&dev.uuid, NULL, true /* aDoSetError */, &medium);7149 rc = mParent->findDVDOrFloppyImage(DeviceType_Floppy, &dev.uuid, Utf8Str::Empty, true /* aDoSetError */, &medium); 7171 7150 /* find a floppy by host device name */ 7172 7151 else if (!dev.strHostDriveSrc.isEmpty()) … … 7194 7173 /* find a DVD by UUID */ 7195 7174 if (!dev.uuid.isEmpty()) 7196 rc = mParent->findDVD Image(&dev.uuid, NULL, true /* aDoSetError */, &medium);7175 rc = mParent->findDVDOrFloppyImage(DeviceType_DVD, &dev.uuid, Utf8Str::Empty, true /* aDoSetError */, &medium); 7197 7176 /* find a DVD by host device name */ 7198 7177 else if (!dev.strHostDriveSrc.isEmpty()) -
trunk/src/VBox/Main/MediumImpl.cpp
r31258 r31281 4850 4850 ++it) 4851 4851 { 4852 m->properties.insert(std::make_pair(it->name, Bstr:: Null));4852 m->properties.insert(std::make_pair(it->name, Bstr::Empty)); 4853 4853 } 4854 4854 } -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r30950 r31281 84 84 unconst(mParent) = aParent; 85 85 86 setDefaultMachineFolder(Utf8Str:: Null);87 setDefaultHardDiskFolder(Utf8Str:: Null);88 setDefaultHardDiskFormat(Utf8Str:: Null);89 90 setRemoteDisplayAuthLibrary(Utf8Str:: Null);86 setDefaultMachineFolder(Utf8Str::Empty); 87 setDefaultHardDiskFolder(Utf8Str::Empty); 88 setDefaultHardDiskFormat(Utf8Str::Empty); 89 90 setRemoteDisplayAuthLibrary(Utf8Str::Empty); 91 91 92 92 m->ulLogHistoryCount = 3; -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31034 r31281 1551 1551 Guid id(aId); 1552 1552 ComObjPtr<Medium> image; 1553 HRESULT rc = findDVD Image(&id, NULL, true /* setError */, &image);1553 HRESULT rc = findDVDOrFloppyImage(DeviceType_DVD, &id, Utf8Str::Empty, true /* setError */, &image); 1554 1554 1555 1555 /* the below will set *aDVDImage to NULL if image is null */ … … 1569 1569 1570 1570 ComObjPtr<Medium> image; 1571 HRESULT rc = findDVD Image(NULL, aLocation, true /* setError */, &image);1571 HRESULT rc = findDVDOrFloppyImage(DeviceType_DVD, NULL, aLocation, true /* setError */, &image); 1572 1572 1573 1573 /* the below will set *aDVDImage to NULL if dvd is null */ … … 1628 1628 Guid id(aId); 1629 1629 ComObjPtr<Medium> image; 1630 HRESULT rc = find FloppyImage(&id, NULL, true /* setError */, &image);1630 HRESULT rc = findDVDOrFloppyImage(DeviceType_Floppy, &id, Utf8Str::Empty, true /* setError */, &image); 1631 1631 1632 1632 /* the below will set *aFloppyImage to NULL if image is null */ … … 1647 1647 1648 1648 ComObjPtr<Medium> image; 1649 HRESULT rc = find FloppyImage(NULL, aLocation, true /* setError */, &image);1649 HRESULT rc = findDVDOrFloppyImage(DeviceType_Floppy, NULL, aLocation, true /* setError */, &image); 1650 1650 1651 1651 /* the below will set *aFloppyImage to NULL if img is null */ … … 2755 2755 /** 2756 2756 * Searches for a Medium object with the given ID or location in the list of 2757 * registered DVD images. If both ID and file path are specified, the first 2758 * object that matches either of them (not necessarily both) is returned. 2759 * 2760 * @param aId ID of the DVD image (unused when NULL). 2757 * registered DVD or floppy images, depending on the @a mediumType argument. 2758 * If both ID and file path are specified, the first object that matches either 2759 * of them (not necessarily both) is returned. 2760 * 2761 * @param mediumType Must be either DeviceType_DVD or DeviceType_Floppy. 2762 * @param aId ID of the image file (unused when NULL). 2761 2763 * @param aLocation Full path to the image file (unused when NULL). 2762 2764 * @param aSetError If @c true, the appropriate error info is set in case when … … 2764 2766 * @param aImage Where to store the found image object (can be NULL). 2765 2767 * 2766 * @return S_OK when found or E_INVALIDARG when not found.2768 * @return S_OK when found or E_INVALIDARG or VBOX_E_OBJECT_NOT_FOUND when not found. 2767 2769 * 2768 2770 * @note Locks the media tree for reading. 2769 2771 */ 2770 HRESULT VirtualBox::findDVDImage(const Guid *aId, 2771 CBSTR aLocation, 2772 bool aSetError, 2773 ComObjPtr<Medium> *aImage /* = NULL */) 2774 { 2775 AssertReturn(aId || aLocation, E_INVALIDARG); 2772 /** 2773 * 2774 * @param aId 2775 * @param aLocation 2776 * @param aSetError 2777 * @param aImage 2778 * @return 2779 */ 2780 HRESULT VirtualBox::findDVDOrFloppyImage(DeviceType_T mediumType, 2781 const Guid *aId, 2782 const Utf8Str &aLocation, 2783 bool aSetError, 2784 ComObjPtr<Medium> *aImage /* = NULL */) 2785 { 2786 AssertReturn(aId || !aLocation.isEmpty(), E_INVALIDARG); 2776 2787 2777 2788 Utf8Str location; 2778 2779 if (aLocation != NULL) 2780 { 2781 int vrc = calculateFullPath(Utf8Str(aLocation), location); 2789 if (!aLocation.isEmpty()) 2790 { 2791 int vrc = calculateFullPath(aLocation, location); 2782 2792 if (RT_FAILURE(vrc)) 2783 2793 return setError(VBOX_E_FILE_ERROR, 2784 2794 tr("Invalid image file location '%ls' (%Rrc)"), 2785 aLocation ,2795 aLocation.c_str(), 2786 2796 vrc); 2787 2797 } 2788 2798 2789 AutoReadLock alock(m->allDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2799 MediaOList *pMediaList; 2800 2801 switch (mediumType) 2802 { 2803 case DeviceType_DVD: 2804 pMediaList = &m->allDVDImages; 2805 break; 2806 2807 case DeviceType_Floppy: 2808 pMediaList = &m->allFloppyImages; 2809 break; 2810 2811 default: 2812 return E_INVALIDARG; 2813 } 2814 2815 AutoReadLock alock(pMediaList->getLockHandle() COMMA_LOCKVAL_SRC_POS); 2790 2816 2791 2817 bool found = false; 2792 2818 2793 for (MediaList::const_iterator it = m->allDVDImages.begin(); 2794 it != m->allDVDImages.end(); 2795 ++ it) 2796 { 2797 /* no AutoCaller, registered image life time is bound to this */ 2798 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2799 2800 found = (aId && (*it)->getId() == *aId) || 2801 (aLocation != NULL && 2802 RTPathCompare(location.c_str(), 2803 (*it)->getLocationFull().c_str() 2804 ) == 0); 2819 for (MediaList::const_iterator it = pMediaList->begin(); 2820 it != pMediaList->end(); 2821 ++it) 2822 { 2823 // no AutoCaller, registered image life time is bound to this 2824 Medium *pMedium = *it; 2825 AutoReadLock imageLock(pMedium COMMA_LOCKVAL_SRC_POS); 2826 const Utf8Str &strLocationFull = pMedium->getLocationFull(); 2827 2828 found = ( aId 2829 && pMedium->getId() == *aId) 2830 || ( !aLocation.isEmpty() 2831 && RTPathCompare(location.c_str(), 2832 strLocationFull.c_str()) == 0); 2805 2833 if (found) 2806 2834 { 2835 if (pMedium->getType() != mediumType) 2836 { 2837 if (mediumType == DeviceType_DVD) 2838 return setError(E_INVALIDARG, 2839 "Cannot mount DVD medium '%s' as floppy", strLocationFull.c_str()); 2840 else 2841 return setError(E_INVALIDARG, 2842 "Cannot mount floppy medium '%s' as DVD", strLocationFull.c_str()); 2843 } 2844 2807 2845 if (aImage) 2808 *aImage = *it;2846 *aImage = pMedium; 2809 2847 break; 2810 2848 } … … 2817 2855 if (aId) 2818 2856 setError(rc, 2819 tr("Could not find a CD/DVD image with UUID {%RTuuid} in the media registry ('%s')"),2857 tr("Could not find an image file with UUID {%RTuuid} in the media registry ('%s')"), 2820 2858 aId->raw(), 2821 2859 m->strSettingsFilePath.raw()); 2822 2860 else 2823 2861 setError(rc, 2824 tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"), 2825 aLocation, 2826 m->strSettingsFilePath.raw()); 2827 } 2828 2829 return rc; 2830 } 2831 2832 /** 2833 * Searches for a Medium object with the given ID or location in the 2834 * collection of registered DVD images. If both ID and file path are specified, 2835 * the first object that matches either of them (not necessarily both) is 2836 * returned. 2837 * 2838 * @param aId ID of the DVD image (unused when NULL). 2839 * @param aLocation Full path to the image file (unused when NULL). 2840 * @param aSetError If @c true, the appropriate error info is set in case when 2841 * the image is not found. 2842 * @param aImage Where to store the found image object (can be NULL). 2843 * 2844 * @return S_OK when found or E_INVALIDARG when not found. 2845 * 2846 * @note Locks the media tree for reading. 2847 */ 2848 HRESULT VirtualBox::findFloppyImage(const Guid *aId, 2849 CBSTR aLocation, 2850 bool aSetError, 2851 ComObjPtr<Medium> *aImage /* = NULL */) 2852 { 2853 AssertReturn(aId || aLocation, E_INVALIDARG); 2854 2855 Utf8Str location; 2856 2857 if (aLocation != NULL) 2858 { 2859 int vrc = calculateFullPath(Utf8Str(aLocation), location); 2860 if (RT_FAILURE(vrc)) 2861 return setError(VBOX_E_FILE_ERROR, 2862 tr("Invalid image file location '%ls' (%Rrc)"), 2863 aLocation, vrc); 2864 } 2865 2866 AutoReadLock alock(m->allFloppyImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2867 2868 bool found = false; 2869 2870 for (MediaList::const_iterator it = m->allFloppyImages.begin(); 2871 it != m->allFloppyImages.end(); 2872 ++ it) 2873 { 2874 /* no AutoCaller, registered image life time is bound to this */ 2875 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2876 2877 found = (aId && (*it)->getId() == *aId) || 2878 (aLocation != NULL && 2879 RTPathCompare(location.c_str(), 2880 (*it)->getLocationFull().c_str() 2881 ) == 0); 2882 if (found) 2883 { 2884 if (aImage) 2885 *aImage = *it; 2886 break; 2887 } 2888 } 2889 2890 HRESULT rc = found ? S_OK : VBOX_E_OBJECT_NOT_FOUND; 2891 2892 if (aSetError && !found) 2893 { 2894 if (aId) 2895 setError(rc, 2896 tr("Could not find a floppy image with UUID {%RTuuid} in the media registry ('%s')"), 2897 aId->raw(), 2898 m->strSettingsFilePath.raw()); 2899 else 2900 setError(rc, 2901 tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"), 2902 aLocation, 2862 tr("Could not find an image file with location '%ls' in the media registry ('%s')"), 2863 aLocation.c_str(), 2903 2864 m->strSettingsFilePath.raw()); 2904 2865 } … … 3090 3051 { 3091 3052 ComObjPtr<Medium> image; 3092 rc = findDVD Image(&aId, bstrLocation, false /* aSetError */, &image);3053 rc = findDVDOrFloppyImage(DeviceType_DVD, &aId, bstrLocation, false /* aSetError */, &image); 3093 3054 if (SUCCEEDED(rc)) 3094 3055 { … … 3104 3065 { 3105 3066 ComObjPtr<Medium> image; 3106 rc = find FloppyImage(&aId, bstrLocation, false /* aSetError */, &image);3067 rc = findDVDOrFloppyImage(DeviceType_Floppy, &aId, bstrLocation, false /* aSetError */, &image); 3107 3068 if (SUCCEEDED(rc)) 3108 3069 { -
trunk/src/VBox/Main/glue/string.cpp
r30750 r31281 34 34 35 35 /* static */ 36 const Bstr Bstr:: Null; /* default ctor is OK */36 const Bstr Bstr::Empty; /* default ctor is OK */ 37 37 38 38 /* static */ 39 const Utf8Str Utf8Str:: Null; /* default ctor is OK */39 const Utf8Str Utf8Str::Empty; /* default ctor is OK */ 40 40 41 41 #if defined (VBOX_WITH_XPCOM) -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31273 r31281 223 223 HRESULT findHardDisk(const Guid *aId, CBSTR aLocation, 224 224 bool aSetError, ComObjPtr<Medium> *aHardDisk = NULL); 225 HRESULT findDVDImage(const Guid *aId, CBSTR aLocation, 226 bool aSetError, ComObjPtr<Medium> *aImage = NULL); 227 HRESULT findFloppyImage(const Guid *aId, CBSTR aLocation, 228 bool aSetError, ComObjPtr<Medium> *aImage = NULL); 225 HRESULT findDVDOrFloppyImage(DeviceType_T mediumType, 226 const Guid *aId, 227 const Utf8Str &aLocation, 228 bool aSetError, 229 ComObjPtr<Medium> *aImage = NULL); 229 230 230 231 HRESULT findGuestOSType(const Bstr &bstrOSType,
Note:
See TracChangeset
for help on using the changeset viewer.