- Timestamp:
- Jul 8, 2009 1:06:27 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49764
- Location:
- trunk/src/VBox
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r21393 r21394 750 750 } 751 751 752 if ( !rawdisk.length())752 if (rawdisk.isEmpty()) 753 753 return errorSyntax(USAGE_LISTPARTITIONS, "Mandatory parameter -rawdisk missing"); 754 754 … … 865 865 if (filename.isEmpty()) 866 866 return errorSyntax(USAGE_CREATERAWVMDK, "Mandatory parameter -filename missing"); 867 if ( !rawdisk.length())867 if (rawdisk.isEmpty()) 868 868 return errorSyntax(USAGE_CREATERAWVMDK, "Mandatory parameter -rawdisk missing"); 869 869 if (!pszPartitions && pszMBRFilename) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r21393 r21394 167 167 { 168 168 HRESULT rc = S_OK; 169 Utf8Str utf8Name (name);169 Utf8Str utf8Name (name); 170 170 Guid uuid(machineId); 171 if (utf8Name.isNull()) 172 rc = E_OUTOFMEMORY; 171 173 if ( SUCCEEDED (rc) 172 174 && uuid == mUuid -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r21393 r21394 202 202 203 203 case VINF_GETOPT_NOT_OPTION: 204 if ( !strOvfFilename.length())204 if (strOvfFilename.isEmpty()) 205 205 strOvfFilename = ValueUnion.psz; 206 206 else … … 225 225 } 226 226 227 if ( !strOvfFilename.length())227 if (strOvfFilename.isEmpty()) 228 228 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Not enough arguments for \"import\" command."); 229 229 -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r21393 r21394 1178 1178 /* now the text */ 1179 1179 if ( mLabelFont != NULL 1180 && mSecureLabelText.length()1180 && !mSecureLabelText.isEmpty() 1181 1181 ) 1182 1182 { -
trunk/src/VBox/Main/ApplianceImpl.cpp
r21393 r21394 1370 1370 /* If the there isn't any name specified create a default one out of 1371 1371 * the OS type */ 1372 Utf8Str nameVBox (vsysThis.strName);1373 if ( !nameVBox.length())1372 Utf8Str nameVBox = vsysThis.strName; 1373 if (nameVBox.isEmpty()) 1374 1374 nameVBox = strOsTypeVBox; 1375 1375 searchUniqueVMName(nameVBox); … … 1380 1380 1381 1381 /* VM Product */ 1382 if ( vsysThis.strProduct.length())1382 if (!vsysThis.strProduct.isEmpty()) 1383 1383 pNewDesc->addEntry(VirtualSystemDescriptionType_Product, 1384 1384 "", … … 1387 1387 1388 1388 /* VM Vendor */ 1389 if ( vsysThis.strVendor.length())1389 if (!vsysThis.strVendor.isEmpty()) 1390 1390 pNewDesc->addEntry(VirtualSystemDescriptionType_Vendor, 1391 1391 "", … … 1394 1394 1395 1395 /* VM Version */ 1396 if ( vsysThis.strVersion.length())1396 if (!vsysThis.strVersion.isEmpty()) 1397 1397 pNewDesc->addEntry(VirtualSystemDescriptionType_Version, 1398 1398 "", … … 1401 1401 1402 1402 /* VM ProductUrl */ 1403 if ( vsysThis.strProductUrl.length())1403 if (!vsysThis.strProductUrl.isEmpty()) 1404 1404 pNewDesc->addEntry(VirtualSystemDescriptionType_ProductUrl, 1405 1405 "", … … 1408 1408 1409 1409 /* VM VendorUrl */ 1410 if ( vsysThis.strVendorUrl.length())1410 if (!vsysThis.strVendorUrl.isEmpty()) 1411 1411 pNewDesc->addEntry(VirtualSystemDescriptionType_VendorUrl, 1412 1412 "", … … 1415 1415 1416 1416 /* VM description */ 1417 if ( vsysThis.strDescription.length())1417 if (!vsysThis.strDescription.isEmpty()) 1418 1418 pNewDesc->addEntry(VirtualSystemDescriptionType_Description, 1419 1419 "", … … 1422 1422 1423 1423 /* VM license */ 1424 if ( vsysThis.strLicenseText.length())1424 if (!vsysThis.strLicenseText.isEmpty()) 1425 1425 pNewDesc->addEntry(VirtualSystemDescriptionType_License, 1426 1426 "", … … 1475 1475 1476 1476 /* Audio */ 1477 if ( vsysThis.strSoundCardType.length())1477 if (!vsysThis.strSoundCardType.isNull()) 1478 1478 /* Currently we set the AC97 always. 1479 1479 @todo: figure out the hardware which could be possible */ … … 2285 2285 ComPtr<IHardDisk> dstHdVBox; 2286 2286 /* If strHref is empty we have to create a new file */ 2287 if ( !di.strHref.length())2287 if (di.strHref.isEmpty()) 2288 2288 { 2289 2289 /* Which format to use? */ … … 2928 2928 std::list<VirtualSystemDescriptionEntry*> llVendorUrl = vsdescThis->findByType(VirtualSystemDescriptionType_VendorUrl); 2929 2929 std::list<VirtualSystemDescriptionEntry*> llVersion = vsdescThis->findByType(VirtualSystemDescriptionType_Version); 2930 bool fProduct = llProduct.size() && (llProduct.front()->strVbox.length() > 0);2931 bool fProductUrl = llProductUrl.size() && (llProductUrl.front()->strVbox.length() > 0);2932 bool fVendor = llVendor.size() && (llVendor.front()->strVbox.length() > 0);2933 bool fVendorUrl = llVendorUrl.size() && (llVendorUrl.front()->strVbox.length() > 0);2934 bool fVersion = llVersion.size() && (llVersion.front()->strVbox.length() > 0);2930 bool fProduct = llProduct.size() && !llProduct.front()->strVbox.isEmpty(); 2931 bool fProductUrl = llProductUrl.size() && !llProductUrl.front()->strVbox.isEmpty(); 2932 bool fVendor = llVendor.size() && !llVendor.front()->strVbox.isEmpty(); 2933 bool fVendorUrl = llVendorUrl.size() && !llVendorUrl.front()->strVbox.isEmpty(); 2934 bool fVersion = llVersion.size() && !llVersion.front()->strVbox.isEmpty(); 2935 2935 if (fProduct || 2936 2936 fProductUrl || … … 2972 2972 // description 2973 2973 std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description); 2974 if ( llDescription.size() 2975 && (llDescription.front()->strVbox.length() > 0) 2976 ) 2974 if (llDescription.size() && 2975 !llDescription.front()->strVbox.isEmpty()) 2977 2976 { 2978 2977 /* <Section ovf:required="false" xsi:type="ovf:AnnotationSection_Type"> … … 2996 2995 // license 2997 2996 std::list<VirtualSystemDescriptionEntry*> llLicense = vsdescThis->findByType(VirtualSystemDescriptionType_License); 2998 if ( llLicense.size() 2999 && (llLicense.front()->strVbox.length() > 0) 3000 ) 2997 if (llLicense.size() && 2998 !llLicense.front()->strVbox.isEmpty()) 3001 2999 { 3002 3000 /* <EulaSection> … … 3217 3215 lBusNumber = 0; 3218 3216 3219 if ( !desc.strVbox.length() // AHCI is the default in VirtualBox3217 if ( desc.strVbox.isEmpty() // AHCI is the default in VirtualBox 3220 3218 || (!desc.strVbox.compare("ahci", Utf8Str::CaseInsensitive)) 3221 3219 ) … … 3252 3250 lBusNumber = 0; 3253 3251 3254 if ( !desc.strVbox.length() // LsiLogic is the default in VirtualBox3252 if ( desc.strVbox.isEmpty() // LsiLogic is the default in VirtualBox 3255 3253 || (!desc.strVbox.compare("lsilogic", Utf8Str::CaseInsensitive)) 3256 3254 ) … … 3428 3426 // exactly this order, as stupid as it seems. 3429 3427 3430 if ( strCaption.length())3428 if (!strCaption.isEmpty()) 3431 3429 { 3432 3430 pItem->createChild("rasd:Caption")->addContent(strCaption); … … 3435 3433 } 3436 3434 3437 if ( strDescription.length())3435 if (!strDescription.isEmpty()) 3438 3436 pItem->createChild("rasd:Description")->addContent(strDescription); 3439 3437 … … 3448 3446 // <rasd:ResourceType>3</rasd:ResourceType> 3449 3447 pItem->createChild("rasd:ResourceType")->addContent(Utf8StrFmt("%d", type)); 3450 if ( strResourceSubType.length())3448 if (!strResourceSubType.isEmpty()) 3451 3449 pItem->createChild("rasd:ResourceSubType")->addContent(strResourceSubType); 3452 3450 3453 if ( strHostResource.length())3451 if (!strHostResource.isEmpty()) 3454 3452 pItem->createChild("rasd:HostResource")->addContent(strHostResource); 3455 3453 3456 if ( strAllocationUnits.length())3454 if (!strAllocationUnits.isEmpty()) 3457 3455 pItem->createChild("rasd:AllocationUnits")->addContent(strAllocationUnits); 3458 3456 … … 3464 3462 pItem->createChild("rasd:AutomaticAllocation")->addContent( (lAutomaticAllocation) ? "true" : "false" ); 3465 3463 3466 if ( strConnection.length())3464 if (!strConnection.isEmpty()) 3467 3465 pItem->createChild("rasd:Connection")->addContent(strConnection); 3468 3466 … … 3651 3649 } 3652 3650 /* If there is no bucket name provided reject the upload */ 3653 if ( !bucket.length())3651 if (bucket.isEmpty()) 3654 3652 return setError(E_INVALIDARG, 3655 3653 tr("You doesn't provide a bucket name in the URI"), tmpPath.c_str()); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r21393 r21394 1084 1084 for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i) 1085 1085 { 1086 try 1087 { 1088 Utf8Buf.reserve(cchBuf + 1024); 1089 } 1090 catch(...) 1091 { 1086 Utf8Buf.reserve(cchBuf + 1024); 1087 if (Utf8Buf.isNull()) 1092 1088 return E_OUTOFMEMORY; 1093 }1094 1089 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 1095 1090 parm[1].u.pointer.addr = Utf8Buf.mutableRaw(); … … 3876 3871 using namespace guestProp; 3877 3872 3878 try 3879 { 3880 VBOXHGCMSVCPARM parm[4]; 3881 Utf8Str Utf8Name = aName; 3882 char pszBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN]; 3883 3884 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3885 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3886 /* The + 1 is the null terminator */ 3887 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 3888 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 3889 parm[1].u.pointer.addr = pszBuffer; 3890 parm[1].u.pointer.size = sizeof(pszBuffer); 3891 int vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", GET_PROP_HOST, 3892 4, &parm[0]); 3893 /* The returned string should never be able to be greater than our buffer */ 3894 AssertLogRel (vrc != VERR_BUFFER_OVERFLOW); 3895 AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 3896 if (RT_SUCCESS (vrc) || (VERR_NOT_FOUND == vrc)) 3897 { 3898 rc = S_OK; 3899 if (vrc != VERR_NOT_FOUND) 3900 { 3901 Utf8Str strBuffer(pszBuffer); 3902 strBuffer.cloneTo(aValue); 3903 3904 *aTimestamp = parm[2].u.uint64; 3905 3906 size_t iFlags = strBuffer.length() + 1; 3907 Utf8Str(pszBuffer + iFlags).cloneTo(aFlags); 3908 } 3909 else 3910 aValue = NULL; 3873 VBOXHGCMSVCPARM parm[4]; 3874 Utf8Str Utf8Name = aName; 3875 AssertReturn(!Utf8Name.isNull(), E_OUTOFMEMORY); 3876 char pszBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN]; 3877 3878 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3879 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3880 /* The + 1 is the null terminator */ 3881 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; 3882 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 3883 parm[1].u.pointer.addr = pszBuffer; 3884 parm[1].u.pointer.size = sizeof(pszBuffer); 3885 int vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", GET_PROP_HOST, 3886 4, &parm[0]); 3887 /* The returned string should never be able to be greater than our buffer */ 3888 AssertLogRel (vrc != VERR_BUFFER_OVERFLOW); 3889 AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type); 3890 if (RT_SUCCESS (vrc) || (VERR_NOT_FOUND == vrc)) 3891 { 3892 rc = S_OK; 3893 if (vrc != VERR_NOT_FOUND) 3894 { 3895 Utf8Str strBuffer(pszBuffer); 3896 strBuffer.cloneTo(aValue); 3897 3898 *aTimestamp = parm[2].u.uint64; 3899 3900 size_t iFlags = strBuffer.length() + 1; 3901 Utf8Str(pszBuffer + iFlags).cloneTo(aFlags); 3911 3902 } 3912 3903 else 3913 rc = setError (E_UNEXPECTED, 3914 tr ("The service call failed with the error %Rrc"), vrc); 3915 } 3916 catch(std::bad_alloc &e) 3917 { 3918 rc = E_OUTOFMEMORY; 3919 } 3904 aValue = NULL; 3905 } 3906 else 3907 rc = setError (E_UNEXPECTED, 3908 tr ("The service call failed with the error %Rrc"), vrc); 3920 3909 return rc; 3921 3910 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */ … … 4403 4392 4404 4393 /* make sure the Logs folder exists */ 4405 Assert (logDir.length());4394 Assert (!logDir.isEmpty()); 4406 4395 if (!RTDirExists (logDir)) 4407 4396 RTDirCreateFullPath (logDir, 0777); … … 6202 6191 6203 6192 /* append to the existing error message if any */ 6204 if ( task->mErrorMsg.length())6193 if (!task->mErrorMsg.isEmpty()) 6205 6194 task->mErrorMsg = Utf8StrFmt ("%s.\n%N (%Rrc)", task->mErrorMsg.raw(), 6206 6195 pszFormat, &va2, rc, rc); … … 6677 6666 6678 6667 /* Load saved state? */ 6679 if ( task->mSavedStateFile.length())6668 if (!task->mSavedStateFile.isEmpty()) 6680 6669 { 6681 6670 LogFlowFunc (("Restoring saved state from '%s'...\n", … … 6760 6749 * this function is not updated. 6761 6750 */ 6762 if ( !task->mErrorMsg.length())6751 if (task->mErrorMsg.isNull()) 6763 6752 { 6764 6753 /* If the error message is not set but we've got a failure, … … 7106 7095 AssertReturn (task.get(), VERR_INVALID_PARAMETER); 7107 7096 7108 Assert (task->mSavedStateFile.length());7109 Assert (!task->mProgress.isNull());7097 Assert (!task->mSavedStateFile.isNull()); 7098 Assert (!task->mProgress.isNull()); 7110 7099 7111 7100 const ComObjPtr <Console> &that = task->mConsole; … … 7263 7252 else 7264 7253 { 7265 if (errMsg.length()) 7266 task->mProgress->notifyComplete(rc, 7267 COM_IIDOF(IConsole), 7268 Console::getComponentName(), 7269 errMsg); 7254 if (!errMsg.isNull()) 7255 task->mProgress->notifyComplete (rc, 7256 COM_IIDOF(IConsole), Console::getComponentName(), errMsg); 7270 7257 else 7271 7258 task->mProgress->notifyComplete (rc); -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r21393 r21394 1801 1801 * Guest property service 1802 1802 */ 1803 try1804 1803 { 1805 1804 /* Load the service */ … … 1845 1844 timestamps.push_back(timestampsOut[i]); 1846 1845 utf8Flags.push_back(Bstr(flagsOut[i])); 1846 #if 0 /** @todo r=bird: Who is gonna catch this? Why does it trigger now? */ 1847 if ( utf8Names.back().isNull() 1848 || utf8Values.back().isNull() 1849 || utf8Flags.back().isNull() 1850 ) 1851 throw std::bad_alloc(); 1852 #endif 1847 1853 } 1848 1854 for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i) … … 1883 1889 Log(("Set VBoxGuestPropSvc property store\n")); 1884 1890 } 1885 }1886 catch(std::bad_alloc &e)1887 {1888 return VERR_NO_MEMORY;1889 1891 } 1890 1892 #endif /* VBOX_WITH_GUEST_PROPS defined */ -
trunk/src/VBox/Main/DHCPServerRunner.cpp
r21393 r21394 97 97 for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++) 98 98 { 99 if ( mOptions[i].length())99 if (!mOptions[i].isNull()) 100 100 { 101 101 const ARGDEF * pArgDef = getArgDef((DHCPCFG)i); 102 args[index++] = pArgDef->Name; // e.g. "--network" 103 args[index++] = mOptions[i].raw(); // value 102 args[index++] = pArgDef->Name; 103 if (!mOptions[i].isEmpty()) 104 { 105 args[index++] = mOptions[i].raw(); 106 } 104 107 } 105 108 } -
trunk/src/VBox/Main/HardDiskImpl.cpp
r21393 r21394 3570 3570 Utf8Str error; 3571 3571 3572 if ( !mm.vdError.length())3572 if (mm.vdError.isEmpty()) 3573 3573 error = Utf8StrFmt (" (%Rrc)", aVRC); 3574 3574 else … … 3603 3603 AssertReturnVoid (that != NULL); 3604 3604 3605 if ( !that->mm.vdError.length())3605 if (that->mm.vdError.isEmpty()) 3606 3606 that->mm.vdError = 3607 3607 Utf8StrFmt ("%s (%Rrc)", Utf8StrFmtVA (pszFormat, va).raw(), rc); -
trunk/src/VBox/Main/MachineImpl.cpp
r21393 r21394 1408 1408 Utf8Str snapshotFolder = aSnapshotFolder; 1409 1409 1410 if ( !snapshotFolder.length())1410 if (snapshotFolder.isEmpty()) 1411 1411 { 1412 1412 if (isInOwnDir()) … … 2780 2780 Utf8Str logFolder; 2781 2781 getLogFolder (logFolder); 2782 Assert (logFolder.length());2783 if (RTDirExists (logFolder))2782 Assert (!logFolder.isEmpty()); 2783 if (RTDirExists (logFolder)) 2784 2784 { 2785 2785 /* Delete all VBox.log[.N] files from the Logs folder … … 2805 2805 * there (we don't check for errors because the user might have 2806 2806 * some private files there that we don't want to delete) */ 2807 Utf8Str snapshotFolder (mUserData->mSnapshotFolderFull);2808 Assert (snapshotFolder.length());2809 if (RTDirExists (snapshotFolder))2810 RTDirRemove (snapshotFolder);2807 Utf8Str snapshotFolder = mUserData->mSnapshotFolderFull; 2808 Assert (!snapshotFolder.isEmpty()); 2809 if (RTDirExists (snapshotFolder)) 2810 RTDirRemove (snapshotFolder); 2811 2811 2812 2812 /* delete the directory that contains the settings file, but only … … 3056 3056 } 3057 3057 3058 STDMETHODIMP Machine::SetGuestProperty(IN_BSTR aName, 3059 IN_BSTR aValue, 3060 IN_BSTR aFlags) 3058 STDMETHODIMP Machine::SetGuestProperty (IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags) 3061 3059 { 3062 3060 #if !defined (VBOX_WITH_GUEST_PROPS) … … 3070 3068 return E_INVALIDARG; 3071 3069 3072 HRESULT rc = S_OK; 3073 3074 try 3075 { 3076 Utf8Str utf8Name(aName); 3077 Utf8Str utf8Flags(aFlags); 3078 Utf8Str utf8Patterns(mHWData->mGuestPropertyNotificationPatterns); 3079 3080 bool matchAll = false; 3081 if (0 == utf8Patterns.length()) 3082 matchAll = true; 3083 3084 uint32_t fFlags = NILFLAG; 3085 if ( (aFlags != NULL) 3086 && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags)) 3087 ) 3088 return setError(E_INVALIDARG, 3089 tr("Invalid flag values: '%ls'"), 3090 aFlags); 3091 3092 AutoCaller autoCaller(this); 3093 CheckComRCReturnRC(autoCaller.rc()); 3094 3095 AutoWriteLock alock(this); 3096 3097 rc = checkStateDependency(MutableStateDep); 3098 CheckComRCReturnRC (rc); 3099 3100 rc = S_OK; 3101 3102 if (!mHWData->mPropertyServiceActive) 3103 { 3104 bool found = false; 3105 HWData::GuestProperty property; 3106 property.mFlags = NILFLAG; 3107 if (fFlags & TRANSIENT) 3108 rc = setError(VBOX_E_INVALID_OBJECT_STATE, 3109 tr("Cannot set a transient property when the machine is not running")); 3110 3111 if (SUCCEEDED (rc)) 3112 { 3113 for (HWData::GuestPropertyList::iterator it = 3114 mHWData->mGuestProperties.begin(); 3115 it != mHWData->mGuestProperties.end(); ++ it) 3116 if (it->mName == aName) 3070 Utf8Str utf8Name (aName); 3071 Utf8Str utf8Flags (aFlags); 3072 Utf8Str utf8Patterns (mHWData->mGuestPropertyNotificationPatterns); 3073 if ( utf8Name.isNull() 3074 || ((aFlags != NULL) && utf8Flags.isNull()) 3075 || utf8Patterns.isNull() 3076 ) 3077 return E_OUTOFMEMORY; 3078 bool matchAll = false; 3079 if (0 == utf8Patterns.length()) 3080 matchAll = true; 3081 3082 uint32_t fFlags = NILFLAG; 3083 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags)) 3084 ) 3085 return setError (E_INVALIDARG, tr ("Invalid flag values: '%ls'"), 3086 aFlags); 3087 3088 AutoCaller autoCaller (this); 3089 CheckComRCReturnRC (autoCaller.rc()); 3090 3091 AutoWriteLock alock (this); 3092 3093 HRESULT rc = checkStateDependency (MutableStateDep); 3094 CheckComRCReturnRC (rc); 3095 3096 rc = S_OK; 3097 3098 if (!mHWData->mPropertyServiceActive) 3099 { 3100 bool found = false; 3101 HWData::GuestProperty property; 3102 property.mFlags = NILFLAG; 3103 if (fFlags & TRANSIENT) 3104 rc = setError (VBOX_E_INVALID_OBJECT_STATE, 3105 tr ("Cannot set a transient property when the " 3106 "machine is not running")); 3107 if (SUCCEEDED (rc)) 3108 { 3109 for (HWData::GuestPropertyList::iterator it = 3110 mHWData->mGuestProperties.begin(); 3111 it != mHWData->mGuestProperties.end(); ++ it) 3112 if (it->mName == aName) 3113 { 3114 property = *it; 3115 if (it->mFlags & (RDONLYHOST)) 3116 rc = setError (E_ACCESSDENIED, 3117 tr ("The property '%ls' cannot be changed by the host"), 3118 aName); 3119 else 3117 3120 { 3118 property = *it; 3119 if (it->mFlags & (RDONLYHOST)) 3120 rc = setError (E_ACCESSDENIED, 3121 tr ("The property '%ls' cannot be changed by the host"), 3122 aName); 3123 else 3124 { 3125 mHWData.backup(); 3126 /* The backup() operation invalidates our iterator, so 3127 * get a new one. */ 3128 for (it = mHWData->mGuestProperties.begin(); 3129 it->mName != aName; ++ it) 3130 ; 3131 mHWData->mGuestProperties.erase (it); 3132 } 3133 found = true; 3134 break; 3121 mHWData.backup(); 3122 /* The backup() operation invalidates our iterator, so 3123 * get a new one. */ 3124 for (it = mHWData->mGuestProperties.begin(); 3125 it->mName != aName; ++ it) 3126 ; 3127 mHWData->mGuestProperties.erase (it); 3135 3128 } 3136 } 3137 if (found && SUCCEEDED (rc)) 3138 { 3139 if (*aValue) 3140 { 3141 RTTIMESPEC time; 3142 property.mValue = aValue; 3143 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3144 if (aFlags != NULL) 3145 property.mFlags = fFlags; 3146 mHWData->mGuestProperties.push_back (property); 3129 found = true; 3130 break; 3147 3131 } 3148 } 3149 else if (SUCCEEDED (rc) && *aValue) 3132 } 3133 if (found && SUCCEEDED (rc)) 3134 { 3135 if (*aValue) 3150 3136 { 3151 3137 RTTIMESPEC time; 3152 mHWData.backup();3153 property.mName = aName;3154 3138 property.mValue = aValue; 3155 3139 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3156 property.mFlags = fFlags; 3140 if (aFlags != NULL) 3141 property.mFlags = fFlags; 3157 3142 mHWData->mGuestProperties.push_back (property); 3158 3143 } 3159 if ( SUCCEEDED (rc) 3160 && ( matchAll 3161 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 3162 utf8Name.raw(), RTSTR_MAX, NULL) 3163 ) 3164 ) 3165 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 3166 } 3144 } 3145 else if (SUCCEEDED (rc) && *aValue) 3146 { 3147 RTTIMESPEC time; 3148 mHWData.backup(); 3149 property.mName = aName; 3150 property.mValue = aValue; 3151 property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time)); 3152 property.mFlags = fFlags; 3153 mHWData->mGuestProperties.push_back (property); 3154 } 3155 if ( SUCCEEDED (rc) 3156 && ( matchAll 3157 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 3158 utf8Name.raw(), RTSTR_MAX, NULL) 3159 ) 3160 ) 3161 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 3162 } 3163 else 3164 { 3165 ComPtr <IInternalSessionControl> directControl = 3166 mData->mSession.mDirectControl; 3167 3168 /* just be on the safe side when calling another process */ 3169 alock.leave(); 3170 3171 BSTR dummy = NULL; 3172 ULONG64 dummy64; 3173 if (!directControl) 3174 rc = E_FAIL; 3167 3175 else 3168 { 3169 ComPtr <IInternalSessionControl> directControl = 3170 mData->mSession.mDirectControl; 3171 3172 /* just be on the safe side when calling another process */ 3173 alock.leave(); 3174 3175 BSTR dummy = NULL; 3176 ULONG64 dummy64; 3177 if (!directControl) 3178 rc = E_FAIL; 3179 else 3180 rc = directControl->AccessGuestProperty(aName, aValue, aFlags, 3181 true /* isSetter */, 3182 &dummy, &dummy64, &dummy); 3183 } 3184 } 3185 catch (std::bad_alloc &e) 3186 { 3187 rc = E_OUTOFMEMORY; 3188 } 3189 3176 rc = directControl->AccessGuestProperty (aName, aValue, aFlags, 3177 true /* isSetter */, 3178 &dummy, &dummy64, &dummy); 3179 } 3190 3180 return rc; 3191 3181 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */ … … 5411 5401 #ifdef VBOX_WITH_GUEST_PROPS 5412 5402 /* Guest properties (optional) */ 5413 try5414 5403 { 5415 5404 using namespace guestProp; … … 5433 5422 /* property flags (optional, defaults to empty) */ 5434 5423 Bstr flags = (*it).stringValue ("flags"); 5435 Utf8Str utf8Flags(flags); 5424 Utf8Str utf8Flags (flags); 5425 if (utf8Flags.isNull ()) 5426 return E_OUTOFMEMORY; 5436 5427 validateFlags (utf8Flags.raw(), &fFlags); 5437 5428 HWData::GuestProperty property = { name, value, timestamp, fFlags }; … … 5451 5442 if (mHWData->mGuestPropertyNotificationPatterns.isNull ()) 5452 5443 return E_OUTOFMEMORY; 5453 }5454 catch(std::bad_alloc &e)5455 {5456 return E_OUTOFMEMORY;5457 5444 } 5458 5445 #endif /* VBOX_WITH_GUEST_PROPS defined */ … … 9629 9616 return E_POINTER; /* aValue can be NULL to indicate deletion */ 9630 9617 9631 try 9632 { 9633 Utf8Str utf8Name(aName); 9634 Utf8Str utf8Flags(aFlags); 9635 Utf8Str utf8Patterns(mHWData->mGuestPropertyNotificationPatterns); 9636 9637 uint32_t fFlags = NILFLAG; 9638 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags))) 9639 return E_INVALIDARG; 9640 9641 bool matchAll = false; 9642 if (utf8Patterns.length() == 0) 9643 matchAll = true; 9644 9645 AutoCaller autoCaller (this); 9646 CheckComRCReturnRC (autoCaller.rc()); 9647 9648 AutoWriteLock alock (this); 9649 9650 HRESULT rc = checkStateDependency (MutableStateDep); 9651 CheckComRCReturnRC (rc); 9652 9653 mHWData.backup(); 9654 for (HWData::GuestPropertyList::iterator iter = mHWData->mGuestProperties.begin(); 9655 iter != mHWData->mGuestProperties.end(); ++iter) 9656 if (aName == iter->mName) 9657 { 9658 mHWData->mGuestProperties.erase (iter); 9659 break; 9660 } 9661 if (aValue != NULL) 9662 { 9663 HWData::GuestProperty property = { aName, aValue, aTimestamp, fFlags }; 9664 mHWData->mGuestProperties.push_back (property); 9665 } 9666 9667 /* send a callback notification if appropriate */ 9668 alock.leave(); 9669 if ( matchAll 9670 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 9671 utf8Name.raw(), RTSTR_MAX, NULL) 9672 ) 9673 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 9674 } 9675 catch(std::bad_alloc &e) 9676 { 9618 Utf8Str utf8Name (aName); 9619 Utf8Str utf8Flags (aFlags); 9620 Utf8Str utf8Patterns (mHWData->mGuestPropertyNotificationPatterns); 9621 if ( utf8Name.isNull() 9622 || ((aFlags != NULL) && utf8Flags.isNull()) 9623 || utf8Patterns.isNull() 9624 ) 9677 9625 return E_OUTOFMEMORY; 9678 } 9626 9627 uint32_t fFlags = NILFLAG; 9628 if ((aFlags != NULL) && RT_FAILURE (validateFlags (utf8Flags.raw(), &fFlags))) 9629 return E_INVALIDARG; 9630 9631 bool matchAll = false; 9632 if (utf8Patterns.length() == 0) 9633 matchAll = true; 9634 9635 AutoCaller autoCaller (this); 9636 CheckComRCReturnRC (autoCaller.rc()); 9637 9638 AutoWriteLock alock (this); 9639 9640 HRESULT rc = checkStateDependency (MutableStateDep); 9641 CheckComRCReturnRC (rc); 9642 9643 mHWData.backup(); 9644 for (HWData::GuestPropertyList::iterator iter = mHWData->mGuestProperties.begin(); 9645 iter != mHWData->mGuestProperties.end(); ++iter) 9646 if (aName == iter->mName) 9647 { 9648 mHWData->mGuestProperties.erase (iter); 9649 break; 9650 } 9651 if (aValue != NULL) 9652 { 9653 HWData::GuestProperty property = { aName, aValue, aTimestamp, fFlags }; 9654 mHWData->mGuestProperties.push_back (property); 9655 } 9656 9657 /* send a callback notification if appropriate */ 9658 alock.leave(); 9659 if ( matchAll 9660 || RTStrSimplePatternMultiMatch (utf8Patterns.raw(), RTSTR_MAX, 9661 utf8Name.raw(), RTSTR_MAX, NULL) 9662 ) 9663 mParent->onGuestPropertyChange (mData->mUuid, aName, aValue, aFlags); 9664 9679 9665 return S_OK; 9680 9666 #else -
trunk/src/VBox/Main/SnapshotImpl.cpp
r21393 r21394 412 412 413 413 /* state file may be NULL (for offline snapshots) */ 414 if ( path.length()414 if ( !path.isEmpty() 415 415 && RTPathStartsWith(path, aOldPath) 416 416 ) -
trunk/src/VBox/Main/VFSExplorerImpl.cpp
r21393 r21394 403 403 RTS3SetProgressCallback(hS3, VFSExplorer::TaskVFSExplorer::uploadProgress, &aTask); 404 404 /* Do we need the list of buckets or keys? */ 405 if ( !m->strBucket.length())405 if (m->strBucket.isEmpty()) 406 406 { 407 407 PCRTS3BUCKETENTRY pBuckets = NULL; -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r21393 r21394 3481 3481 AutoReadLock hardDiskLock (aHardDisk); 3482 3482 3483 Utf8Str strConflict;3484 HRESULT rc = checkMediaForConflicts2 (aHardDisk->id(),3485 aHardDisk->locationFull(),3486 strConflict);3483 Utf8Str conflict; 3484 HRESULT rc = checkMediaForConflicts2 (aHardDisk->id(), 3485 aHardDisk->locationFull(), 3486 conflict); 3487 3487 CheckComRCReturnRC (rc); 3488 3488 3489 if (strConflict.length()) 3490 { 3491 return setError(E_INVALIDARG, 3492 tr("Cannot register the hard disk '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3493 aHardDisk->locationFull().raw(), 3494 aHardDisk->id().raw(), 3495 strConflict.raw(), 3496 mData.mCfgFile.mName.raw()); 3489 if (!conflict.isNull()) 3490 { 3491 return setError (E_INVALIDARG, 3492 tr ("Cannot register the hard disk '%ls' with UUID {%RTuuid} " 3493 "because a %s already exists in the media registry ('%ls')"), 3494 aHardDisk->locationFull().raw(), aHardDisk->id().raw(), 3495 conflict.raw(), mData.mCfgFile.mName.raw()); 3497 3496 } 3498 3497 … … 3599 3598 AutoReadLock imageLock (aImage); 3600 3599 3601 Utf8Str strConflict; 3602 HRESULT rc = checkMediaForConflicts2(aImage->id(), 3603 aImage->locationFull(), 3604 strConflict); 3600 Utf8Str conflict; 3601 HRESULT rc = checkMediaForConflicts2 (aImage->id(), aImage->locationFull(), 3602 conflict); 3605 3603 CheckComRCReturnRC (rc); 3606 3604 3607 if (strConflict.length()) 3608 { 3609 return setError(VBOX_E_INVALID_OBJECT_STATE, 3610 tr("Cannot register the CD/DVD image '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3611 aImage->locationFull().raw(), 3612 aImage->id().raw(), 3613 strConflict.raw(), 3614 mData.mCfgFile.mName.raw()); 3605 if (!conflict.isNull()) 3606 { 3607 return setError (VBOX_E_INVALID_OBJECT_STATE, 3608 tr ("Cannot register the CD/DVD image '%ls' with UUID {%RTuuid} " 3609 "because a %s already exists in the media registry ('%ls')"), 3610 aImage->locationFull().raw(), aImage->id().raw(), 3611 conflict.raw(), mData.mCfgFile.mName.raw()); 3615 3612 } 3616 3613 … … 3702 3699 AutoReadLock imageLock (aImage); 3703 3700 3704 Utf8Str strConflict; 3705 HRESULT rc = checkMediaForConflicts2(aImage->id(), 3706 aImage->locationFull(), 3707 strConflict); 3701 Utf8Str conflict; 3702 HRESULT rc = checkMediaForConflicts2 (aImage->id(), aImage->locationFull(), 3703 conflict); 3708 3704 CheckComRCReturnRC (rc); 3709 3705 3710 if (strConflict.length()) 3711 { 3712 return setError(VBOX_E_INVALID_OBJECT_STATE, 3713 tr("Cannot register the floppy image '%ls' with UUID {%RTuuid} because a %s already exists in the media registry ('%ls')"), 3714 aImage->locationFull().raw(), 3715 aImage->id().raw(), 3716 strConflict.raw(), 3717 mData.mCfgFile.mName.raw()); 3706 if (!conflict.isNull()) 3707 { 3708 return setError (VBOX_E_INVALID_OBJECT_STATE, 3709 tr ("Cannot register the floppy image '%ls' with UUID {%RTuuid} " 3710 "because a %s already exists in the media registry ('%ls')"), 3711 aImage->locationFull().raw(), aImage->id().raw(), 3712 conflict.raw(), mData.mCfgFile.mName.raw()); 3718 3713 } 3719 3714 … … 3942 3937 { 3943 3938 *aFormatVersion = aTree.oldVersion(); 3944 if ( !aFormatVersion->length())3939 if (aFormatVersion->isNull()) 3945 3940 *aFormatVersion = VBOX_XML_VERSION_FULL; 3946 3941 } -
trunk/src/VBox/Main/glue/string.cpp
r21393 r21394 139 139 Utf8Str& Utf8Str::toLower() 140 140 { 141 if ( length())141 if (!isEmpty()) 142 142 ::RTStrToLower(m_psz); 143 143 return *this; … … 146 146 Utf8Str& Utf8Str::toUpper() 147 147 { 148 if ( length())148 if (!isEmpty()) 149 149 ::RTStrToUpper(m_psz); 150 150 return *this; -
trunk/src/VBox/Main/include/HostHardwareLinux.h
r21393 r21394 66 66 mDescription (aDescription != NULL ? aDescription : std::string ()) {} 67 67 }; 68 68 69 69 /** List (resp vector) holding drive information */ 70 70 typedef std::vector <DriveInfo> DriveInfoList; … … 144 144 USBDeviceInfo () {} 145 145 }; 146 146 147 147 /** List (resp vector) holding drive information */ 148 148 typedef std::vector <USBDeviceInfo> DeviceInfoList; -
trunk/src/VBox/Runtime/testcase/tstUtf8.cpp
r21393 r21394 987 987 988 988 copy1 = NULL; 989 CHECK( (copy1. length() == 0) );989 CHECK( (copy1.isNull()) ); 990 990 991 991 copy1 = ""; 992 CHECK( (copy1. length() == 0) );992 CHECK( (copy1.isEmpty()) ); 993 993 994 994 CHECK( (ministring("abc") < ministring("def")) );
Note:
See TracChangeset
for help on using the changeset viewer.