VirtualBox

儲存庫 vbox 的更動 17192


忽略:
時間撮記:
2009-2-27 上午09:17:19 (16 年 以前)
作者:
vboxsync
訊息:

#3551: “Main: Replace remaining collections with safe arrays”
Converted HostDVDDriveCollection.

位置:
trunk/src/VBox
檔案:
修改 14 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r17104 r17192  
    671671                ComPtr<IHost> host;
    672672                CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    673                 ComPtr<IHostDVDDriveCollection> hostDVDs;
    674                 CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
     673                com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
     674                rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
     675
    675676                ComPtr<IHostDVDDrive> hostDVDDrive;
    676                 rc = hostDVDs->FindByName(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam());
     677                rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam());
    677678                if (!hostDVDDrive)
    678679                {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r17091 r17192  
    224224            {
    225225                /*
    226                 * Iterate through the collection.
    227                 */
     226                 * Iterate through the collection.
     227                 */
    228228                for (size_t i = 0; i < coll.size(); ++ i)
    229229                {
     
    245245            ComPtr<IHost> host;
    246246            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    247             ComPtr<IHostDVDDriveCollection> coll;
    248             ComPtr<IHostDVDDriveEnumerator> enumerator;
    249             CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
    250             if (SUCCEEDED(rc) && coll)
    251             {
    252                 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
    253                 BOOL hasMore;
    254                 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
    255                 {
    256                     ComPtr<IHostDVDDrive> dvdDrive;
    257                     CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam()));
     247            com::SafeIfaceArray <IHostDVDDrive> coll;
     248            CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
     249            if (SUCCEEDED(rc))
     250            {
     251                for (size_t i = 0; i < coll.size(); ++ i)
     252                {
     253                    ComPtr<IHostDVDDrive> dvdDrive = coll[i];
    258254                    Bstr name;
    259255                    dvdDrive->COMGETTER(Name)(name.asOutParam());
     
    779775
    780776#endif /* !VBOX_ONLY_DOCS */
    781 
     777/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r16960 r17192  
    2525#ifndef VBOX_ONLY_DOCS
    2626#include <VBox/com/com.h>
     27#include <VBox/com/array.h>
    2728#include <VBox/com/ErrorInfo.h>
    2829#include <VBox/com/errorprint2.h>
     
    10911092                ComPtr<IHost> host;
    10921093                CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    1093                 ComPtr<IHostDVDDriveCollection> hostDVDs;
    1094                 CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
     1094                com::SafeIfaceArray <IHostDVDDrive> hostDVDs;
     1095                rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
     1096
    10951097                ComPtr<IHostDVDDrive> hostDVDDrive;
    1096                 rc = hostDVDs->FindByName(Bstr(dvd + 5), hostDVDDrive.asOutParam());
     1098                rc = host->FindHostDVDDrive(Bstr(dvd + 5), hostDVDDrive.asOutParam());
    10971099                if (!hostDVDDrive)
    10981100                {
     
    11051107                        break;
    11061108                    }
    1107                     rc = hostDVDs->FindByName(Bstr(szPathReal), hostDVDDrive.asOutParam());
     1109                    rc = host->FindHostDVDDrive(Bstr(szPathReal), hostDVDDrive.asOutParam());
    11081110                    if (!hostDVDDrive)
    11091111                    {
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r16867 r17192  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    17721772            ComPtr <IHost> host;
    17731773            CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam()));
    1774             ComPtr <IHostDVDDriveCollection> coll;
    1775             CHECK_ERROR_BREAK (host, COMGETTER(DVDDrives)(coll.asOutParam()));
     1774            SafeIfaceArray <IHostDVDDrive> coll;
     1775            CHECK_ERROR_BREAK (host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
    17761776            ComPtr <IHostDVDDrive> hostDrive;
    1777             rc = coll->FindByName (medium, hostDrive.asOutParam());
     1777            rc = host->FindHostDVDDrive (medium, hostDrive.asOutParam());
    17781778            if (SUCCEEDED (rc))
    17791779            {
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r17175 r17192  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    31333133
    31343134    hostDVDMap.clear();
    3135     CHostDVDDriveEnumerator en =
    3136         vboxGlobal().virtualBox().GetHost().GetDVDDrives().Enumerate();
    3137     while (en.HasMore())
    3138     {
    3139         CHostDVDDrive hostDVD = en.GetNext();
     3135    CHostDVDDriveVector drvvec =
     3136        vboxGlobal().virtualBox().GetHost().GetDVDDrives();
     3137    for (int i = 0; i < drvvec.size(); ++i)
     3138    {
     3139        CHostDVDDrive hostDVD = drvvec[i];
    31403140        /** @todo set icon */
    31413141        QString drvName = hostDVD.GetName();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMFirstRunWzd.cpp

    r16867 r17192  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    176176    {
    177177        /* Search for the host dvd-drives */
    178         CHostDVDDriveCollection coll =
     178        CHostDVDDriveVector coll =
    179179            vboxGlobal().virtualBox().GetHost().GetDVDDrives();
    180         mHostDVDs.resize (coll.GetCount());
    181         int id = 0;
    182         CHostDVDDriveEnumerator en = coll.Enumerate();
    183         while (en.HasMore())
    184         {
    185             CHostDVDDrive hostDVD = en.GetNext();
     180        mHostDVDs.resize (coll.size());
     181
     182        for (int id = 0; id < coll.size(); ++id)
     183        {
     184            CHostDVDDrive hostDVD = coll[id];
    186185            QString name = hostDVD.GetName();
    187186            QString description = hostDVD.GetDescription();
     
    190189            mCbHost->insertItem (id, fullName);
    191190            mHostDVDs [id] = hostDVD;
    192             ++ id;
    193191        }
    194192
     
    222220
    223221    /* Repopulate the media list */
    224         mCbImage->repopulate();
     222    mCbImage->repopulate();
    225223
    226224    /* Revalidate updated page */
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsCD.cpp

    r16853 r17192  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5959
    6060    /* Read out the host DVD drive list and prepare the combobox */
    61     CHostDVDDriveCollection coll =
     61    CHostDVDDriveVector coll =
    6262        vboxGlobal().virtualBox().GetHost().GetDVDDrives();
    63     mHostCDs.resize (coll.GetCount());
     63    mHostCDs.resize (coll.size());
    6464    mCbHostCD->clear();
    65     int id = 0;
    66     CHostDVDDriveEnumerator en = coll.Enumerate();
    67     while (en.HasMore())
    68     {
    69         CHostDVDDrive hostDVD = en.GetNext();
     65
     66    for (int id = 0; id < coll.size(); ++id)
     67    {
     68        CHostDVDDrive hostDVD = coll[id];
    7069        /// @todo (r=dmik) set icon?
    7170        QString name = hostDVD.GetName();
     
    7574        mCbHostCD->insertItem (id, fullName);
    7675        mHostCDs [id] = hostDVD;
    77         ++ id;
    7876    }
    7977
     
    8987                name :
    9088                QString ("%1 (%2)").arg (description, name);
    91             if (coll.FindByName (name).isNull())
     89            if (vboxGlobal().virtualBox().GetHost().FindHostDVDDrive (name).isNull())
    9290            {
    9391                /* If the DVD drive is not currently available,
  • trunk/src/VBox/Main/DVDDriveImpl.cpp

    r16853 r17192  
    77
    88/*
    9  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    452452        Bstr src = typeNode.stringValue ("src");
    453453
    454         /* find the correspoding object */
     454        /* find the corresponding object */
    455455        ComObjPtr <Host> host = mParent->virtualBox()->host();
    456456
    457         ComPtr <IHostDVDDriveCollection> coll;
    458         rc = host->COMGETTER(DVDDrives) (coll.asOutParam());
     457        com::SafeIfaceArray <IHostDVDDrive> coll;
     458        rc = host->COMGETTER(DVDDrives) (ComSafeArrayAsOutParam(coll));
    459459        AssertComRC (rc);
    460460
    461461        ComPtr <IHostDVDDrive> drive;
    462         rc = coll->FindByName (src, drive.asOutParam());
     462        rc = host->FindHostDVDDrive (src, drive.asOutParam());
     463
    463464        if (SUCCEEDED (rc))
    464465        {
  • trunk/src/VBox/Main/HostImpl.cpp

    r16967 r17192  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    291291 * @param drives address of result pointer
    292292 */
    293 STDMETHODIMP Host::COMGETTER(DVDDrives) (IHostDVDDriveCollection **aDrives)
    294 {
    295     CheckComArgOutPointerValid(aDrives);
     293STDMETHODIMP Host::COMGETTER(DVDDrives) (ComSafeArrayOut (IHostDVDDrive *, aDrives))
     294{
     295    CheckComArgOutSafeArrayPointerValid(aDrives);
    296296    AutoWriteLock alock (this);
    297297    CHECK_READY();
     
    399399#endif
    400400
    401     ComObjPtr<HostDVDDriveCollection> collection;
    402     collection.createObject();
    403     collection->init (list);
    404     collection.queryInterfaceTo(aDrives);
     401    SafeIfaceArray <IHostDVDDrive> array (list);
     402    array.detachTo(ComSafeArrayOutArg(aDrives));
    405403    return rc;
    406404}
     
    33233321#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    33243322
     3323STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IHostDVDDrive **aDrive)
     3324{
     3325    CheckComArgNotNull(aName);
     3326    CheckComArgOutPointerValid(aDrive);
     3327    AutoReadLock alock (this);
     3328
     3329    *aDrive = NULL;
     3330
     3331    for (DriveInfoList::const_iterator it = mHostDrives.DVDBegin();
     3332            it != mHostDrives.DVDEnd(); ++it)
     3333    {
     3334        Bstr device (it->mDevice.c_str());
     3335        if (device == aName)
     3336        {
     3337            ComObjPtr<HostDVDDrive> found;
     3338            HRESULT rc = found.createObject();
     3339            CheckComRCReturnRC (rc);
     3340            rc = found->init (device, Bstr (it->mUdi.c_str()), Bstr (it->mDescription.c_str()));
     3341            CheckComRCReturnRC (rc);
     3342            return found.queryInterfaceTo (aDrive);
     3343        }
     3344    }
     3345
     3346    return setError (VBOX_E_OBJECT_NOT_FOUND, HostDVDDrive::tr (
     3347        "The host DVD drive named '%ls' could not be found"), aName);
     3348}
     3349
    33253350STDMETHODIMP Host::FindHostNetworkInterfaceByName(IN_BSTR name, IHostNetworkInterface **networkInterface)
    33263351{
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17099 r17192  
    63416341  </interface>
    63426342
    6343   <enumerator
    6344      name="IHostDVDDriveEnumerator" type="IHostDVDDrive"
    6345      uuid="1ed7cfaf-c363-40df-aa4e-89c1afb7d96b"
    6346      />
    6347 
    6348   <collection
    6349      name="IHostDVDDriveCollection" type="IHostDVDDrive"
    6350      enumerator="IHostDVDDriveEnumerator"
    6351      uuid="1909c533-1a1e-445f-a4e1-a267cffc30ed"
    6352      readonly="yes"
    6353      >
    6354     <method name="findByName">
    6355       <desc>
    6356         Searches this collection for a host drive with the given name.
    6357         <note>
    6358           The method returns an error if the given name does not
    6359           correspond to any host drive in the collection.
    6360         </note>
    6361       </desc>
    6362       <param name="name" type="wstring" dir="in">
    6363         <desc>Name of the host drive to search for</desc>
    6364       </param>
    6365       <param name="drive" type="IHostDVDDrive" dir="return">
    6366         <desc>Found host drive object</desc>
    6367       </param>
    6368     </method>
    6369   </collection>
    6370 
    63716343  <interface
    63726344     name="IHostFloppyDrive" extends="$unknown"
     
    65436515  <interface
    65446516     name="IHost" extends="$unknown"
    6545      uuid="7c172c42-b209-4bdc-9ddf-a84f222bd59a"
     6517     uuid="ba0cb246-478a-4a2b-930e-51ce740ada9c"
    65466518     wsmap="managed"
    65476519     >
     
    65586530
    65596531    </desc>
    6560     <attribute name="DVDDrives" type="IHostDVDDriveCollection" readonly="yes">
     6532    <attribute name="DVDDrives" type="IHostDVDDrive" readonly="yes" safearray="yes">
    65616533      <desc>List of DVD drives available on the host.</desc>
    65626534    </attribute>
     
    68336805    </method>
    68346806
     6807    <method name="findHostDVDDrive">
     6808      <desc>
     6809        Searches for a host DVD drive with the given @c name.
     6810
     6811        <result name="VBOX_E_OBJECT_NOT_FOUND">
     6812          Given @c name does not correspond to any host drive.
     6813        </result>
     6814
     6815      </desc>
     6816      <param name="name" type="wstring" dir="in">
     6817        <desc>Name of the host drive to search for</desc>
     6818      </param>
     6819      <param name="drive" type="IHostDVDDrive" dir="return">
     6820        <desc>Found host drive object</desc>
     6821      </param>
     6822    </method>
     6823
    68356824    <method name="findHostNetworkInterfaceByName">
    68366825      <desc>
    68376826        Searches through all host network interfaces for an interface with
    6838         the given name.
    6839         <note>
    6840           The method returns an error if the given name does not
     6827        the given @c name.
     6828        <note>
     6829          The method returns an error if the given @c name does not
    68416830          correspond to any host network interface.
    68426831        </note>
  • trunk/src/VBox/Main/include/HostDVDDriveImpl.h

    r15051 r17192  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424
    2525#include "VirtualBoxBase.h"
    26 #include "Collection.h"
    2726
    2827class ATL_NO_VTABLE HostDVDDrive :
     
    8382};
    8483
    85 COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostDVDDrive)
    86 
    87     STDMETHOD(FindByName) (IN_BSTR aName, IHostDVDDrive **aDrive)
    88     {
    89         if (!aName)
    90             return E_INVALIDARG;
    91         if (!aDrive)
    92             return E_POINTER;
    93 
    94         *aDrive = NULL;
    95         Vector::value_type found;
    96         Vector::iterator it = vec.begin();
    97         while (it != vec.end() && !found)
    98         {
    99             Bstr n;
    100             (*it)->COMGETTER(Name) (n.asOutParam());
    101             if (n == aName)
    102                 found = *it;
    103             ++ it;
    104         }
    105 
    106         if (!found)
    107             return setError (E_INVALIDARG, HostDVDDriveCollection::tr (
    108                 "The host DVD drive named '%ls' could not be found"), aName);
    109 
    110         return found.queryInterfaceTo (aDrive);
    111     }
    112 
    113 COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostDVDDrive)
    114 
    11584#endif // ____H_HOSTDVDDRIVEIMPL
    11685/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/HostImpl.h

    r16967 r17192  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8181
    8282    // IHost properties
    83     STDMETHOD(COMGETTER(DVDDrives))(IHostDVDDriveCollection **drives);
     83    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IHostDVDDrive*, drives));
    8484    STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
    8585    STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
     
    111111    STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
    112112
     113    STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IHostDVDDrive **aDrive);
    113114    STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
    114115    STDMETHOD(FindHostNetworkInterfaceById) (IN_GUID id, IHostNetworkInterface **networkInterface);
  • trunk/src/VBox/Main/webservice/webtest.cpp

    r16122 r17192  
    44 *      functionality of VBoxManage for testing purposes.
    55 *
    6  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     6 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    233233        {
    234234            unsigned int i,
    235                          c = resp.returnval->array.size();
     235                         c = resp.returnval.size();
    236236            for(i = 0;
    237237                i < c;
    238238                ++i)
    239239            {
    240                 std::cout << "DVD drive " << i << ": objref " << resp.returnval->array[i] << "\n";
     240                std::cout << "DVD drive " << i << ": objref " << resp.returnval[i] << "\n";
    241241            }
    242242        }
  • trunk/src/VBox/Main/xpcom/server.cpp

    r16971 r17192  
    243243
    244244COM_IMPL_READONLY_ENUM_AND_COLLECTION(Snapshot)
    245 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostDVDDrive)
    246245COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostFloppyDrive)
    247246#ifdef VBOX_WITH_USB
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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