VirtualBox

Changeset 17679 in vbox


Ignore:
Timestamp:
Mar 11, 2009 11:39:18 AM (16 years ago)
Author:
vboxsync
Message:

Main/Hostonly: not specify name on Create

Location:
trunk/src/VBox
Files:
10 edited

Legend:

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

    r17549 r17679  
    5454static int handleCreate(HandlerArg *a, int iStart, int *pcProcessed)
    5555{
    56     if (a->argc - iStart < 1)
    57         return errorSyntax(USAGE_HOSTONLYIFS, "Not enough parameters");
     56//    if (a->argc - iStart < 1)
     57//        return errorSyntax(USAGE_HOSTONLYIFS, "Not enough parameters");
    5858
    5959    int index = iStart;
    6060    HRESULT rc;
    61     Bstr name(a->argv[iStart]);
    62     index++;
     61//    Bstr name(a->argv[iStart]);
     62//    index++;
    6363
    6464    ComPtr<IHost> host;
     
    6868    ComPtr<IProgress> progress;
    6969
    70     CHECK_ERROR(host, CreateHostOnlyNetworkInterface (name, hif.asOutParam(), progress.asOutParam()));
     70    CHECK_ERROR(host, CreateHostOnlyNetworkInterface (hif.asOutParam(), progress.asOutParam()));
    7171
    7272    showProgress(progress);
     
    8787        return 1;
    8888    }
     89
     90    Bstr name;
     91    CHECK_ERROR(hif, COMGETTER(Name) (name.asOutParam()));
     92
     93    RTPrintf("Interface '%lS' was successfully created\n", name.raw());
    8994
    9095    return 0;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r17631 r17679  
    300300#if defined Q_WS_WIN
    301301    int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
    302     void cannotCreateHostInterface (const CHost &aHost, const QString &aName,
     302    void cannotCreateHostInterface (const CHost &aHost,
    303303                                    QWidget *aParent = 0);
    304304    void cannotCreateHostInterface (const CProgress &aProgress, const QString &aName,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r17640 r17679  
    14391439
    14401440void VBoxProblemReporter::cannotCreateHostInterface (
    1441     const CHost &host, const QString &name, QWidget *parent)
     1441    const CHost &host, QWidget *parent)
    14421442{
    14431443    message (parent ? parent : mainWindowShown(), Error,
    1444         tr ("Failed to create the host network interface <b>%1</b>.")
    1445             .arg (name),
     1444        tr ("Failed to create the host network interface ."),
    14461445        formatErrorInfo (host));
    14471446}
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetwork.cpp

    r17387 r17679  
    546546    }
    547547
    548     /* Creating add host interface dialog */
    549     VBoxAddNIDialog dlg (this, ifaceName.arg (++ ifaceNumber));
    550     if (dlg.exec() != QDialog::Accepted)
    551         return;
    552     QString iName = dlg.getName();
    553 
    554548    /* Create interface */
    555549    CHost host = vboxGlobal().virtualBox().GetHost();
    556550    CHostNetworkInterface iFace;
    557     CProgress progress = host.CreateHostOnlyNetworkInterface (iName, iFace);
     551    CProgress progress = host.CreateHostOnlyNetworkInterface (iFace);
    558552    if (host.isOk())
    559553    {
     554        QString iName = iFace.GetName();
     555
    560556        vboxProblem().showModalProgressDialog (progress, iName, this);
    561557        /* Add&Select newly created interface */
     
    566562    }
    567563    else
    568         vboxProblem().cannotCreateHostInterface (host, iName, this);
     564        vboxProblem().cannotCreateHostInterface (host, this);
    569565
    570566    emit listChanged();
  • trunk/src/VBox/Main/HostImpl.cpp

    r17494 r17679  
    13161316
    13171317STDMETHODIMP
    1318 Host::CreateHostOnlyNetworkInterface (IN_BSTR aName,
    1319                                   IHostNetworkInterface **aHostNetworkInterface,
     1318Host::CreateHostOnlyNetworkInterface (IHostNetworkInterface **aHostNetworkInterface,
    13201319                                  IProgress **aProgress)
    13211320{
    1322     CheckComArgNotNull(aName);
    13231321    CheckComArgOutPointerValid(aHostNetworkInterface);
    13241322    CheckComArgOutPointerValid(aProgress);
     
    13271325    CHECK_READY();
    13281326
    1329     /* first check whether an interface with the given name already exists */
    1330     {
    1331         ComPtr <IHostNetworkInterface> iface;
    1332         if (SUCCEEDED (FindHostNetworkInterfaceByName (aName, iface.asOutParam())))
    1333             return setError (E_INVALIDARG,
    1334                              tr ("Host network interface '%ls' already exists"), aName);
    1335     }
    1336 
    1337     int r = NetIfCreateHostOnlyNetworkInterface (mParent, aName, aHostNetworkInterface, aProgress);
     1327    int r = NetIfCreateHostOnlyNetworkInterface (mParent, aHostNetworkInterface, aProgress);
    13381328    if(RT_SUCCESS(r))
    13391329    {
  • trunk/src/VBox/Main/generic/NetIf-generic.cpp

    r17494 r17679  
    3838}
    3939
    40 int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IN_BSTR aName, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress)
     40int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress)
    4141{
    4242    return VERR_NOT_IMPLEMENTED;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17670 r17679  
    66096609  <interface
    66106610     name="IHost" extends="$unknown"
    6611      uuid="378cf146-6cd6-4dbc-bc60-cbd2004d99c5"
     6611     uuid="651f04ec-b2a6-4008-b979-3a01c0fc72cc"
    66126612     wsmap="managed"
    66136613     >
     
    67646764        </result>
    67656765      </desc>
    6766       <param name="name" type="wstring" dir="in">
    6767         <desc>
    6768           Adapter name.
    6769         </desc>
    6770       </param>
    67716766      <param name="hostInterface" type="IHostNetworkInterface" dir="out">
    67726767        <desc>
  • trunk/src/VBox/Main/include/HostImpl.h

    r17494 r17679  
    9696#ifdef RT_OS_WINDOWS
    9797
    98     STDMETHOD(CreateHostOnlyNetworkInterface) (IN_BSTR aName,
    99                                            IHostNetworkInterface **aHostNetworkInterface,
     98    STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
    10099                                           IProgress **aProgress);
    101100    STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_GUID aId,
  • trunk/src/VBox/Main/include/netif.h

    r17613 r17679  
    8080int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength);
    8181int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf);
    82 int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IN_BSTR aName, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress);
     82int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress);
    8383int NetIfRemoveHostOnlyNetworkInterface (VirtualBox *pVbox, IN_GUID aId, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress);
    8484int NetIfGetConfig(HostNetworkInterface * pIf, NETIFINFO *);
  • trunk/src/VBox/Main/win/NetIfList-win.cpp

    r17650 r17679  
    6464#include <cfgmgr32.h>
    6565
     66#define VBOX_APP_NAME L"VirtualBox"
    6667
    6768static HRESULT netIfWinCreateIWbemServices(IWbemServices ** ppSvc)
     
    861862            vrc = aClient->write (d->msgCode);
    862863            if (RT_FAILURE (vrc)) break;
    863             vrc = aClient->write (Utf8Str (d->name));
    864             if (RT_FAILURE (vrc)) break;
     864//            vrc = aClient->write (Utf8Str (d->name));
     865//            if (RT_FAILURE (vrc)) break;
    865866
    866867            /* wait for a reply */
     
    879880                        /* read the GUID */
    880881                        Guid guid;
     882                        Utf8Str name;
     883                        vrc = aClient->read (name);
     884                        if (RT_FAILURE (vrc)) break;
    881885                        vrc = aClient->read (guid);
    882886                        if (RT_FAILURE (vrc)) break;
     
    886890                        /* initialize the object returned to the caller by
    887891                         * CreateHostOnlyNetworkInterface() */
    888                         rc = d->iface->init (d->name, guid, HostNetworkInterfaceType_HostOnly);
     892                        rc = d->iface->init (Bstr(name), guid, HostNetworkInterfaceType_HostOnly);
    889893                        endLoop = true;
    890894                        break;
     
    12731277/* static */
    12741278static int createNetworkInterface (SVCHlpClient *aClient,
    1275                                   const Utf8Str &aName,
     1279                                  BSTR * pName,
    12761280                                  Guid &aGUID, Utf8Str &aErrMsg)
    12771281{
    12781282    LogFlowFuncEnter();
    1279     LogFlowFunc (("Network connection name = '%s'\n", aName.raw()));
     1283//    LogFlowFunc (("Network connection name = '%s'\n", aName.raw()));
    12801284
    12811285    AssertReturn (aClient, VERR_INVALID_POINTER);
    1282     AssertReturn (!aName.isNull(), VERR_INVALID_PARAMETER);
     1286//    AssertReturn (!aName.isNull(), VERR_INVALID_PARAMETER);
    12831287
    12841288    int vrc = VINF_SUCCESS;
     
    15091513                               &dwValueType, (LPBYTE) pCfgGuidString, &cbSize);
    15101514        RegCloseKey (hkey);
    1511 
    1512         ret = RenameConnection (pCfgGuidString, Bstr (aName));
    1513         if (FAILED (ret))
    1514             SetErrBreak (("Failed to set interface name (ret=0x%08X, "
    1515                           "pCfgGuidString='%ls', cbSize=%d)",
    1516                            ret, pCfgGuidString, cbSize));
    15171515    }
    15181516    while (0);
     
    15481546        LogFlowFunc (("Network connection GUID = {%RTuuid}\n", aGUID.raw()));
    15491547        Assert (!aGUID.isEmpty());
     1548
     1549        INetCfg              *pNc;
     1550        INetCfgComponent     *pMpNcc;
     1551        LPWSTR               lpszApp;
     1552
     1553        HRESULT hr = VBoxNetCfgWinQueryINetCfg( FALSE,
     1554                           VBOX_APP_NAME,
     1555                           &pNc,
     1556                           &lpszApp );
     1557        if(hr == S_OK)
     1558        {
     1559            hr = VBoxNetCfgWinGetComponentByGuid(pNc,
     1560                                            &GUID_DEVCLASS_NET,
     1561                                            aGUID.asOutParam(),
     1562                                            &pMpNcc);
     1563            if(hr == S_OK)
     1564            {
     1565                LPWSTR name;
     1566                hr = pMpNcc->GetDisplayName(&name);
     1567                if(hr == S_OK)
     1568                {
     1569                    Bstr str(name);
     1570                    str.detachTo(pName);
     1571
     1572                    CoTaskMemFree (name);
     1573                }
     1574
     1575                VBoxNetCfgWinReleaseRef(pMpNcc);
     1576            }
     1577            VBoxNetCfgWinReleaseINetCfg(pNc, FALSE);
     1578        }
     1579
     1580        if(hr != S_OK)
     1581        {
     1582            vrc = VERR_GENERAL_FAILURE;
     1583        }
     1584
    15501585    }
    15511586
     
    17851820            LogFlowFunc (("CreateHostOnlyNetworkInterface:\n"));
    17861821
    1787             Utf8Str name;
    1788             vrc = aClient->read (name);
    1789             if (RT_FAILURE (vrc)) break;
     1822//            Utf8Str name;
     1823//            vrc = aClient->read (name);
     1824//            if (RT_FAILURE (vrc)) break;
    17901825
    17911826            Guid guid;
    17921827            Utf8Str errMsg;
    1793             vrc = createNetworkInterface (aClient, name, guid, errMsg);
     1828            Bstr name;
     1829            vrc = createNetworkInterface (aClient, name.asOutParam(), guid, errMsg);
    17941830
    17951831            if (RT_SUCCESS (vrc))
     
    17971833                /* write success followed by GUID */
    17981834                vrc = aClient->write (SVCHlpMsg::CreateHostOnlyNetworkInterface_OK);
     1835                if (RT_FAILURE (vrc)) break;
     1836                vrc = aClient->write (Utf8Str (name));
    17991837                if (RT_FAILURE (vrc)) break;
    18001838                vrc = aClient->write (guid);
     
    20062044
    20072045/* end */
    2008 
    2009 # define VBOX_APP_NAME L"VirtualBox"
    20102046
    20112047static int vboxNetWinAddComponent(std::list <ComObjPtr <HostNetworkInterface> > * pPist, INetCfgComponent * pncc, HostNetworkInterfaceType enmType)
     
    21432179}
    21442180
    2145 int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVBox, IN_BSTR aName,
     2181int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVBox,
    21462182                                  IHostNetworkInterface **aHostNetworkInterface,
    21472183                                  IProgress **aProgress)
     
    21742210
    21752211            d->msgCode = SVCHlpMsg::CreateHostOnlyNetworkInterface;
    2176             d->name = aName;
     2212//            d->name = aName;
    21772213            d->iface = iface;
    21782214
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