VirtualBox

Changeset 21394 in vbox for trunk/src


Ignore:
Timestamp:
Jul 8, 2009 1:06:27 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49764
Message:

Backing out r49763 to fix Windows burns.

Location:
trunk/src/VBox
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r21393 r21394  
    750750    }
    751751
    752     if (!rawdisk.length())
     752    if (rawdisk.isEmpty())
    753753        return errorSyntax(USAGE_LISTPARTITIONS, "Mandatory parameter -rawdisk missing");
    754754
     
    865865    if (filename.isEmpty())
    866866        return errorSyntax(USAGE_CREATERAWVMDK, "Mandatory parameter -filename missing");
    867     if (!rawdisk.length())
     867    if (rawdisk.isEmpty())
    868868        return errorSyntax(USAGE_CREATERAWVMDK, "Mandatory parameter -rawdisk missing");
    869869    if (!pszPartitions && pszMBRFilename)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r21393 r21394  
    167167    {
    168168        HRESULT rc = S_OK;
    169         Utf8Str utf8Name(name);
     169        Utf8Str utf8Name (name);
    170170        Guid uuid(machineId);
     171        if (utf8Name.isNull())
     172            rc = E_OUTOFMEMORY;
    171173        if (   SUCCEEDED (rc)
    172174            && uuid == mUuid
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r21393 r21394  
    202202
    203203            case VINF_GETOPT_NOT_OPTION:
    204                 if (!strOvfFilename.length())
     204                if (strOvfFilename.isEmpty())
    205205                    strOvfFilename = ValueUnion.psz;
    206206                else
     
    225225    }
    226226
    227     if (!strOvfFilename.length())
     227    if (strOvfFilename.isEmpty())
    228228        return errorSyntax(USAGE_IMPORTAPPLIANCE, "Not enough arguments for \"import\" command.");
    229229
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp

    r21393 r21394  
    11781178    /* now the text */
    11791179    if (    mLabelFont != NULL
    1180          && mSecureLabelText.length()
     1180         && !mSecureLabelText.isEmpty()
    11811181       )
    11821182    {
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r21393 r21394  
    13701370            /* If the there isn't any name specified create a default one out of
    13711371             * the OS type */
    1372             Utf8Str nameVBox(vsysThis.strName);
    1373             if (!nameVBox.length())
     1372            Utf8Str nameVBox = vsysThis.strName;
     1373            if (nameVBox.isEmpty())
    13741374                nameVBox = strOsTypeVBox;
    13751375            searchUniqueVMName(nameVBox);
     
    13801380
    13811381            /* VM Product */
    1382             if (vsysThis.strProduct.length())
     1382            if (!vsysThis.strProduct.isEmpty())
    13831383                pNewDesc->addEntry(VirtualSystemDescriptionType_Product,
    13841384                                    "",
     
    13871387
    13881388            /* VM Vendor */
    1389             if (vsysThis.strVendor.length())
     1389            if (!vsysThis.strVendor.isEmpty())
    13901390                pNewDesc->addEntry(VirtualSystemDescriptionType_Vendor,
    13911391                                    "",
     
    13941394
    13951395            /* VM Version */
    1396             if (vsysThis.strVersion.length())
     1396            if (!vsysThis.strVersion.isEmpty())
    13971397                pNewDesc->addEntry(VirtualSystemDescriptionType_Version,
    13981398                                    "",
     
    14011401
    14021402            /* VM ProductUrl */
    1403             if (vsysThis.strProductUrl.length())
     1403            if (!vsysThis.strProductUrl.isEmpty())
    14041404                pNewDesc->addEntry(VirtualSystemDescriptionType_ProductUrl,
    14051405                                    "",
     
    14081408
    14091409            /* VM VendorUrl */
    1410             if (vsysThis.strVendorUrl.length())
     1410            if (!vsysThis.strVendorUrl.isEmpty())
    14111411                pNewDesc->addEntry(VirtualSystemDescriptionType_VendorUrl,
    14121412                                    "",
     
    14151415
    14161416            /* VM description */
    1417             if (vsysThis.strDescription.length())
     1417            if (!vsysThis.strDescription.isEmpty())
    14181418                pNewDesc->addEntry(VirtualSystemDescriptionType_Description,
    14191419                                    "",
     
    14221422
    14231423            /* VM license */
    1424             if (vsysThis.strLicenseText.length())
     1424            if (!vsysThis.strLicenseText.isEmpty())
    14251425                pNewDesc->addEntry(VirtualSystemDescriptionType_License,
    14261426                                    "",
     
    14751475
    14761476            /* Audio */
    1477             if (vsysThis.strSoundCardType.length())
     1477            if (!vsysThis.strSoundCardType.isNull())
    14781478                /* Currently we set the AC97 always.
    14791479                   @todo: figure out the hardware which could be possible */
     
    22852285                        ComPtr<IHardDisk> dstHdVBox;
    22862286                        /* If strHref is empty we have to create a new file */
    2287                         if (!di.strHref.length())
     2287                        if (di.strHref.isEmpty())
    22882288                        {
    22892289                            /* Which format to use? */
     
    29282928            std::list<VirtualSystemDescriptionEntry*> llVendorUrl = vsdescThis->findByType(VirtualSystemDescriptionType_VendorUrl);
    29292929            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();
    29352935            if (fProduct ||
    29362936                fProductUrl ||
     
    29722972            // description
    29732973            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())
    29772976            {
    29782977                /*  <Section ovf:required="false" xsi:type="ovf:AnnotationSection_Type">
     
    29962995            // license
    29972996            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())
    30012999            {
    30023000                /* <EulaSection>
     
    32173215                                lBusNumber = 0;
    32183216
    3219                                 if (    !desc.strVbox.length()      // AHCI is the default in VirtualBox
     3217                                if (    desc.strVbox.isEmpty()      // AHCI is the default in VirtualBox
    32203218                                     || (!desc.strVbox.compare("ahci", Utf8Str::CaseInsensitive))
    32213219                                   )
     
    32523250                                lBusNumber = 0;
    32533251
    3254                                 if (    !desc.strVbox.length()      // LsiLogic is the default in VirtualBox
     3252                                if (    desc.strVbox.isEmpty()      // LsiLogic is the default in VirtualBox
    32553253                                     || (!desc.strVbox.compare("lsilogic", Utf8Str::CaseInsensitive))
    32563254                                   )
     
    34283426                        // exactly this order, as stupid as it seems.
    34293427
    3430                         if (strCaption.length())
     3428                        if (!strCaption.isEmpty())
    34313429                        {
    34323430                            pItem->createChild("rasd:Caption")->addContent(strCaption);
     
    34353433                        }
    34363434
    3437                         if (strDescription.length())
     3435                        if (!strDescription.isEmpty())
    34383436                            pItem->createChild("rasd:Description")->addContent(strDescription);
    34393437
     
    34483446                        // <rasd:ResourceType>3</rasd:ResourceType>
    34493447                        pItem->createChild("rasd:ResourceType")->addContent(Utf8StrFmt("%d", type));
    3450                         if (strResourceSubType.length())
     3448                        if (!strResourceSubType.isEmpty())
    34513449                            pItem->createChild("rasd:ResourceSubType")->addContent(strResourceSubType);
    34523450
    3453                         if (strHostResource.length())
     3451                        if (!strHostResource.isEmpty())
    34543452                            pItem->createChild("rasd:HostResource")->addContent(strHostResource);
    34553453
    3456                         if (strAllocationUnits.length())
     3454                        if (!strAllocationUnits.isEmpty())
    34573455                            pItem->createChild("rasd:AllocationUnits")->addContent(strAllocationUnits);
    34583456
     
    34643462                            pItem->createChild("rasd:AutomaticAllocation")->addContent( (lAutomaticAllocation) ? "true" : "false" );
    34653463
    3466                         if (strConnection.length())
     3464                        if (!strConnection.isEmpty())
    34673465                            pItem->createChild("rasd:Connection")->addContent(strConnection);
    34683466
     
    36513649    }
    36523650    /* If there is no bucket name provided reject the upload */
    3653     if (!bucket.length())
     3651    if (bucket.isEmpty())
    36543652        return setError(E_INVALIDARG,
    36553653                        tr("You doesn't provide a bucket name in the URI"), tmpPath.c_str());
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r21393 r21394  
    10841084    for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i)
    10851085    {
    1086         try
    1087         {
    1088             Utf8Buf.reserve(cchBuf + 1024);
    1089         }
    1090         catch(...)
    1091         {
     1086        Utf8Buf.reserve(cchBuf + 1024);
     1087        if (Utf8Buf.isNull())
    10921088            return E_OUTOFMEMORY;
    1093         }
    10941089        parm[1].type = VBOX_HGCM_SVC_PARM_PTR;
    10951090        parm[1].u.pointer.addr = Utf8Buf.mutableRaw();
     
    38763871    using namespace guestProp;
    38773872
    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);
    39113902        }
    39123903        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);
    39203909    return rc;
    39213910#endif /* else !defined (VBOX_WITH_GUEST_PROPS) */
     
    44034392
    44044393    /* make sure the Logs folder exists */
    4405     Assert(logDir.length());
     4394    Assert (!logDir.isEmpty());
    44064395    if (!RTDirExists (logDir))
    44074396        RTDirCreateFullPath (logDir, 0777);
     
    62026191
    62036192    /* append to the existing error message if any */
    6204     if (task->mErrorMsg.length())
     6193    if (!task->mErrorMsg.isEmpty())
    62056194        task->mErrorMsg = Utf8StrFmt ("%s.\n%N (%Rrc)", task->mErrorMsg.raw(),
    62066195                                      pszFormat, &va2, rc, rc);
     
    66776666
    66786667                /* Load saved state? */
    6679                 if (task->mSavedStateFile.length())
     6668                if (!task->mSavedStateFile.isEmpty())
    66806669                {
    66816670                    LogFlowFunc (("Restoring saved state from '%s'...\n",
     
    67606749             * this function is not updated.
    67616750             */
    6762             if (!task->mErrorMsg.length())
     6751            if (task->mErrorMsg.isNull())
    67636752            {
    67646753                /* If the error message is not set but we've got a failure,
     
    71067095    AssertReturn (task.get(), VERR_INVALID_PARAMETER);
    71077096
    7108     Assert(task->mSavedStateFile.length());
    7109     Assert(!task->mProgress.isNull());
     7097    Assert (!task->mSavedStateFile.isNull());
     7098    Assert (!task->mProgress.isNull());
    71107099
    71117100    const ComObjPtr <Console> &that = task->mConsole;
     
    72637252    else
    72647253    {
    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);
    72707257        else
    72717258            task->mProgress->notifyComplete (rc);
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r21393 r21394  
    18011801     * Guest property service
    18021802     */
    1803     try
    18041803    {
    18051804        /* Load the service */
     
    18451844                timestamps.push_back(timestampsOut[i]);
    18461845                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
    18471853            }
    18481854            for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i)
     
    18831889            Log(("Set VBoxGuestPropSvc property store\n"));
    18841890        }
    1885     }
    1886     catch(std::bad_alloc &e)
    1887     {
    1888         return VERR_NO_MEMORY;
    18891891    }
    18901892#endif /* VBOX_WITH_GUEST_PROPS defined */
  • trunk/src/VBox/Main/DHCPServerRunner.cpp

    r21393 r21394  
    9797    for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)
    9898    {
    99         if (mOptions[i].length())
     99        if (!mOptions[i].isNull())
    100100        {
    101101            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            }
    104107        }
    105108    }
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r21393 r21394  
    35703570    Utf8Str error;
    35713571
    3572     if (!mm.vdError.length())
     3572    if (mm.vdError.isEmpty())
    35733573        error = Utf8StrFmt (" (%Rrc)", aVRC);
    35743574    else
     
    36033603    AssertReturnVoid (that != NULL);
    36043604
    3605     if (!that->mm.vdError.length())
     3605    if (that->mm.vdError.isEmpty())
    36063606        that->mm.vdError =
    36073607            Utf8StrFmt ("%s (%Rrc)", Utf8StrFmtVA (pszFormat, va).raw(), rc);
  • trunk/src/VBox/Main/MachineImpl.cpp

    r21393 r21394  
    14081408    Utf8Str snapshotFolder = aSnapshotFolder;
    14091409
    1410     if (!snapshotFolder.length())
     1410    if (snapshotFolder.isEmpty())
    14111411    {
    14121412        if (isInOwnDir())
     
    27802780        Utf8Str logFolder;
    27812781        getLogFolder (logFolder);
    2782         Assert(logFolder.length());
    2783         if (RTDirExists(logFolder))
     2782        Assert (!logFolder.isEmpty());
     2783        if (RTDirExists (logFolder))
    27842784        {
    27852785            /* Delete all VBox.log[.N] files from the Logs folder
     
    28052805         * there (we don't check for errors because the user might have
    28062806         * 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);
    28112811
    28122812        /* delete the directory that contains the settings file, but only
     
    30563056}
    30573057
    3058 STDMETHODIMP Machine::SetGuestProperty(IN_BSTR aName,
    3059                                        IN_BSTR aValue,
    3060                                        IN_BSTR aFlags)
     3058STDMETHODIMP Machine::SetGuestProperty (IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags)
    30613059{
    30623060#if !defined (VBOX_WITH_GUEST_PROPS)
     
    30703068        return E_INVALIDARG;
    30713069
    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
    31173120                    {
    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);
    31353128                    }
    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;
    31473131                }
    3148             }
    3149             else if (SUCCEEDED (rc) && *aValue)
     3132        }
     3133        if (found && SUCCEEDED (rc))
     3134        {
     3135            if (*aValue)
    31503136            {
    31513137                RTTIMESPEC time;
    3152                 mHWData.backup();
    3153                 property.mName = aName;
    31543138                property.mValue = aValue;
    31553139                property.mTimestamp = RTTimeSpecGetNano (RTTimeNow (&time));
    3156                 property.mFlags = fFlags;
     3140                if (aFlags != NULL)
     3141                    property.mFlags = fFlags;
    31573142                mHWData->mGuestProperties.push_back (property);
    31583143            }
    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;
    31673175        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    }
    31903180    return rc;
    31913181#endif /* else !defined (VBOX_WITH_GUEST_PROPS) */
     
    54115401#ifdef VBOX_WITH_GUEST_PROPS
    54125402    /* Guest properties (optional) */
    5413     try
    54145403    {
    54155404        using namespace guestProp;
     
    54335422                /* property flags (optional, defaults to empty) */
    54345423                Bstr flags = (*it).stringValue ("flags");
    5435                 Utf8Str utf8Flags(flags);
     5424                Utf8Str utf8Flags (flags);
     5425                if (utf8Flags.isNull ())
     5426                    return E_OUTOFMEMORY;
    54365427                validateFlags (utf8Flags.raw(), &fFlags);
    54375428                HWData::GuestProperty property = { name, value, timestamp, fFlags };
     
    54515442        if (mHWData->mGuestPropertyNotificationPatterns.isNull ())
    54525443            return E_OUTOFMEMORY;
    5453     }
    5454     catch(std::bad_alloc &e)
    5455     {
    5456         return E_OUTOFMEMORY;
    54575444    }
    54585445#endif /* VBOX_WITH_GUEST_PROPS defined */
     
    96299616        return E_POINTER;  /* aValue can be NULL to indicate deletion */
    96309617
    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       )
    96779625        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
    96799665    return S_OK;
    96809666#else
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r21393 r21394  
    412412
    413413    /* state file may be NULL (for offline snapshots) */
    414     if (    path.length()
     414    if (    !path.isEmpty()
    415415         && RTPathStartsWith(path, aOldPath)
    416416       )
  • trunk/src/VBox/Main/VFSExplorerImpl.cpp

    r21393 r21394  
    403403        RTS3SetProgressCallback(hS3, VFSExplorer::TaskVFSExplorer::uploadProgress, &aTask);
    404404        /* Do we need the list of buckets or keys? */
    405         if (!m->strBucket.length())
     405        if (m->strBucket.isEmpty())
    406406        {
    407407            PCRTS3BUCKETENTRY pBuckets = NULL;
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r21393 r21394  
    34813481    AutoReadLock hardDiskLock (aHardDisk);
    34823482
    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);
    34873487    CheckComRCReturnRC (rc);
    34883488
    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());
    34973496    }
    34983497
     
    35993598    AutoReadLock imageLock (aImage);
    36003599
    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);
    36053603    CheckComRCReturnRC (rc);
    36063604
    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());
    36153612    }
    36163613
     
    37023699    AutoReadLock imageLock (aImage);
    37033700
    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);
    37083704    CheckComRCReturnRC (rc);
    37093705
    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());
    37183713    }
    37193714
     
    39423937        {
    39433938            *aFormatVersion = aTree.oldVersion();
    3944             if (!aFormatVersion->length())
     3939            if (aFormatVersion->isNull())
    39453940                *aFormatVersion = VBOX_XML_VERSION_FULL;
    39463941        }
  • trunk/src/VBox/Main/glue/string.cpp

    r21393 r21394  
    139139Utf8Str& Utf8Str::toLower()
    140140{
    141     if (length())
     141    if (!isEmpty())
    142142        ::RTStrToLower(m_psz);
    143143    return *this;
     
    146146Utf8Str& Utf8Str::toUpper()
    147147{
    148     if (length())
     148    if (!isEmpty())
    149149        ::RTStrToUpper(m_psz);
    150150    return *this;
  • trunk/src/VBox/Main/include/HostHardwareLinux.h

    r21393 r21394  
    6666            mDescription (aDescription != NULL ? aDescription : std::string ()) {}
    6767    };
    68 
     68   
    6969    /** List (resp vector) holding drive information */
    7070    typedef std::vector <DriveInfo> DriveInfoList;
     
    144144        USBDeviceInfo () {}
    145145    };
    146 
     146   
    147147    /** List (resp vector) holding drive information */
    148148    typedef std::vector <USBDeviceInfo> DeviceInfoList;
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r21393 r21394  
    987987
    988988    copy1 = NULL;
    989     CHECK( (copy1.length() == 0) );
     989    CHECK( (copy1.isNull()) );
    990990
    991991    copy1 = "";
    992     CHECK( (copy1.length() == 0) );
     992    CHECK( (copy1.isEmpty()) );
    993993
    994994    CHECK( (ministring("abc") < ministring("def")) );
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette