VirtualBox

Changeset 16207 in vbox


Ignore:
Timestamp:
Jan 23, 2009 5:49:31 PM (16 years ago)
Author:
vboxsync
Message:

Replaced iterations over IHostNetworkInterface array with FindHostNetworkInterfaceById and FindHostNetworkInterfaceByName where appropriate.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r15991 r16207  
    42534253                ComPtr<IHost> host;
    42544254                virtualBox->COMGETTER(Host)(host.asOutParam());
    4255                 com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
    4256                 host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces));
    4257                 bool found = false;
    4258                 for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
    4259                 {
    4260                     Bstr name;
    4261                     hostNetworkInterfaces[i]->COMGETTER(Name) (name.asOutParam());
    4262                     if (name == hostif)
    4263                     {
    4264                         found = true;
    4265                         break;
    4266                     }
    4267                 }
    4268                 if (!found)
     4255                ComPtr<IHostNetworkInterface> hostInterface;
     4256                if (!SUCCEEDED(host->FindHostNetworkInterfaceByName(hostif, hostInterface.asOutParam())))
    42694257                {
    42704258                    return setError (VBOX_E_HOST_ERROR,
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r16170 r16207  
    13221322
    13231323# elif defined(RT_OS_WINDOWS)
    1324                     com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
    1325                     hrc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces));
    1326                     if(FAILED(hrc))
    1327                     {
    1328                         LogRel(("NetworkAttachmentType_HostInterface: COMGETTER(NetworkInterfaces) failed, hrc (0x%x)", hrc));
    1329                         H();
    1330                     }
    13311324                    ComPtr<IHostNetworkInterface> hostInterface;
    1332                     for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
    1333                     {
    1334                         Bstr name;
    1335                         hostNetworkInterfaces[i]->COMGETTER(Name) (name.asOutParam());
    1336                         if (name == HifName)
    1337                         {
    1338                             hostInterface = hostNetworkInterfaces[i];
    1339                             break;
    1340                         }
    1341                     }
    1342                     if (hostInterface.isNull())
     1325                    rc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
     1326                    if (!SUCCEEDED(rc))
    13431327                    {
    13441328                        AssertBreakpoint();
     
    15181502                    Bstr hostInterfaceName;
    15191503                    hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H();
    1520                     com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
    1521                     hrc = host->COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces)); H();
    15221504                    ComPtr<IHostNetworkInterface> hostInterface;
    1523                     for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
    1524                     {
    1525                         Bstr name;
    1526                         hostNetworkInterfaces[i]->COMGETTER(Name) (name.asOutParam());
    1527                         if (name == hostInterfaceName)
    1528                         {
    1529                             hostInterface = hostNetworkInterfaces[i];
    1530                             break;
    1531                         }
    1532                     }
    1533                     if (hostInterface.isNull())
     1505                    rc = host->FindHostNetworkInterfaceByName(hostInterfaceName, hostInterface.asOutParam());
     1506                    if (!SUCCEEDED(rc))
    15341507                    {
    15351508                        AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName));
  • trunk/src/VBox/Main/HostImpl.cpp

    r16198 r16207  
    13861386    /* first check whether an interface with the given name already exists */
    13871387    {
    1388         com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
    1389         rc = COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces));
    1390         CheckComRCReturnRC (rc);
    1391         for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
    1392         {
    1393             Bstr name;
    1394             hostNetworkInterfaces[i]->COMGETTER(Name) (name.asOutParam());
    1395             if (name == aName)
    1396             {
    1397                 return setError (E_INVALIDARG,
    1398                                  tr ("Host network interface '%ls' already exists"), aName);
    1399             }
    1400         }
     1388        ComPtr <IHostNetworkInterface> iface;
     1389        if (SUCCEEDED (FindHostNetworkInterfaceByName (aName, iface.asOutParam())))
     1390            return setError (E_INVALIDARG,
     1391                             tr ("Host network interface '%ls' already exists"), aName);
    14011392    }
    14021393
     
    14541445    /* first check whether an interface with the given name already exists */
    14551446    {
    1456         com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
    1457         rc = COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces));
    1458         CheckComRCReturnRC (rc);
    14591447        ComPtr <IHostNetworkInterface> iface;
    1460         for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
    1461         {
    1462             Guid guid;
    1463             hostNetworkInterfaces[i]->COMGETTER(Id) (guid.asOutParam());
    1464             if (guid == aId)
    1465             {
    1466                 iface = hostNetworkInterfaces[i];
    1467                 break;
    1468             }
    1469         }
    1470         if (iface.isNull())
     1448        if (FAILED (FindHostNetworkInterfaceById (aId, iface.asOutParam())))
    14711449            return setError (VBOX_E_OBJECT_NOT_FOUND,
    14721450                tr ("Host network interface with UUID {%RTuuid} does not exist"),
Note: See TracChangeset for help on using the changeset viewer.

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