VirtualBox

Changeset 17255 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 2, 2009 3:42:10 PM (16 years ago)
Author:
vboxsync
Message:

#3551: “Main: Replace remaining collections with safe arrays”
Replaced HostFloppyDriveCollection; tested by lelik with (GASP!) real floppy hardware.

Location:
trunk/src/VBox
Files:
13 edited

Legend:

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

    r17238 r17255  
    733733                ComPtr<IHost> host;
    734734                CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    735                 ComPtr<IHostFloppyDriveCollection> hostFloppies;
    736                 CHECK_ERROR(host, COMGETTER(FloppyDrives)(hostFloppies.asOutParam()));
     735                com::SafeIfaceArray <IHostFloppyDrive> hostFloppies;
     736                rc = host->COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies));
     737                                CheckComRCReturnRC (rc);
    737738                ComPtr<IHostFloppyDrive> hostFloppyDrive;
    738                 rc = hostFloppies->FindByName(Bstr(a->argv[2] + 5), hostFloppyDrive.asOutParam());
     739                host->FindHostFloppyDrive(Bstr(a->argv[2] + 5), hostFloppyDrive.asOutParam());
    739740                if (!hostFloppyDrive)
    740741                {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r17238 r17255  
    264264            ComPtr<IHost> host;
    265265            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    266             ComPtr<IHostFloppyDriveCollection> coll;
    267             ComPtr<IHostFloppyDriveEnumerator> enumerator;
    268             CHECK_ERROR(host, COMGETTER(FloppyDrives)(coll.asOutParam()));
    269             if (SUCCEEDED(rc) && coll)
    270             {
    271                 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
    272                 BOOL hasMore;
    273                 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
    274                 {
    275                     ComPtr<IHostFloppyDrive> floppyDrive;
    276                     CHECK_ERROR_BREAK(enumerator, GetNext(floppyDrive.asOutParam()));
     266            com::SafeIfaceArray <IHostFloppyDrive> coll;
     267            CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
     268            if (SUCCEEDED(rc))
     269            {
     270                for (size_t i = 0; i < coll.size(); ++i)
     271                {
     272                    ComPtr<IHostFloppyDrive> floppyDrive = coll[i];
    277273                    Bstr name;
    278274                    floppyDrive->COMGETTER(Name)(name.asOutParam());
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r17238 r17255  
    11961196                    ComPtr<IHost> host;
    11971197                    CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
    1198                     ComPtr<IHostFloppyDriveCollection> hostFloppies;
    1199                     CHECK_ERROR(host, COMGETTER(FloppyDrives)(hostFloppies.asOutParam()));
     1198                    com::SafeIfaceArray <IHostFloppyDrive> hostFloppies;
     1199                    CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies)));
    12001200                    ComPtr<IHostFloppyDrive> hostFloppyDrive;
    1201                     rc = hostFloppies->FindByName(Bstr(floppy + 5), hostFloppyDrive.asOutParam());
     1201                    rc = host->FindHostFloppyDrive(Bstr(floppy + 5), hostFloppyDrive.asOutParam());
    12021202                    if (!hostFloppyDrive)
    12031203                    {
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r17238 r17255  
    17111711            ComPtr <IHost> host;
    17121712            CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam()));
    1713             ComPtr <IHostFloppyDriveCollection> coll;
    1714             CHECK_ERROR_BREAK (host, COMGETTER(FloppyDrives)(coll.asOutParam()));
     1713            com::SafeIfaceArray <IHostFloppyDrive> coll;
     1714            CHECK_ERROR_BREAK (host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
    17151715            ComPtr <IHostFloppyDrive> hostDrive;
    1716             rc = coll->FindByName (medium, hostDrive.asOutParam());
     1716            rc = host->FindHostFloppyDrive (medium, hostDrive.asOutParam());
    17171717            if (SUCCEEDED (rc))
    17181718            {
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r17238 r17255  
    30173017
    30183018    hostFloppyMap.clear();
    3019     CHostFloppyDriveEnumerator en =
    3020         vboxGlobal().virtualBox().GetHost().GetFloppyDrives().Enumerate();
    3021     while (en.HasMore())
    3022     {
    3023         CHostFloppyDrive hostFloppy = en.GetNext();
     3019    CHostFloppyDriveVector drvvec =
     3020        vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
     3021    for (int i = 0; i < drvvec.size(); ++i)
     3022    {
     3023        CHostFloppyDrive hostFloppy = drvvec[i];
    30243024        /** @todo set icon */
    30253025        QString drvName = hostFloppy.GetName();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMFirstRunWzd.cpp

    r17238 r17255  
    198198    {
    199199        /* Search for the host floppy-drives */
    200         CHostFloppyDriveCollection coll =
     200        CHostFloppyDriveVector coll =
    201201            vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
    202         mHostFloppys.resize (coll.GetCount());
    203         int id = 0;
    204         CHostFloppyDriveEnumerator en = coll.Enumerate();
    205         while (en.HasMore())
    206         {
    207             CHostFloppyDrive hostFloppy = en.GetNext();
     202        mHostFloppys.resize (coll.size());
     203
     204        for (int id = 0; id < coll.size(); ++id)
     205        {
     206            CHostFloppyDrive hostFloppy = coll[id];
    208207            QString name = hostFloppy.GetName();
    209208            QString description = hostFloppy.GetDescription();
     
    212211            mCbHost->insertItem (id, fullName);
    213212            mHostFloppys [id] = hostFloppy;
    214             ++ id;
    215213        }
    216214
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsFD.cpp

    r16867 r17255  
    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
     
    6060
    6161    /* Read out the host floppy drive list and prepare the combobox */
    62     CHostFloppyDriveCollection coll =
     62    CHostFloppyDriveVector coll =
    6363        vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
    64     mHostFDs.resize (coll.GetCount());
     64    mHostFDs.resize (coll.size());
    6565    mCbHostFD->clear();
    66     int id = 0;
    67     CHostFloppyDriveEnumerator en = coll.Enumerate();
    68     while (en.HasMore())
    69     {
    70         CHostFloppyDrive hostFloppy = en.GetNext();
     66
     67    for (int id = 0; id < coll.size(); ++id)
     68    {
     69        CHostFloppyDrive hostFloppy = coll[id];
    7170        /** @todo set icon? */
    7271        QString name = hostFloppy.GetName();
     
    7776        mCbHostFD->insertItem (id, fullName);
    7877        mHostFDs [id] = hostFloppy;
    79         ++ id;
    8078    }
    8179
     
    9189                name :
    9290                QString ("%1 (%2)").arg (description, name);
    93             if (coll.FindByName (name).isNull())
     91            if (vboxGlobal().virtualBox().GetHost().FindHostFloppyDrive (name).isNull())
    9492            {
    9593                /* If the floppy drive is not currently available, add it to
  • trunk/src/VBox/Main/FloppyDriveImpl.cpp

    r16867 r17255  
    77
    88/*
    9  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    459459        Bstr src = typeNode.stringValue ("src");
    460460
    461         /* find the correspoding object */
     461        /* find the corresponding object */
    462462        ComObjPtr <Host> host = mParent->virtualBox()->host();
    463463
    464         ComPtr <IHostFloppyDriveCollection> coll;
    465         rc = host->COMGETTER(FloppyDrives) (coll.asOutParam());
     464        com::SafeIfaceArray <IHostFloppyDrive> coll;
     465        rc = host->COMGETTER(FloppyDrives) (ComSafeArrayAsOutParam(coll));
    466466        AssertComRC (rc);
    467467
    468468        ComPtr <IHostFloppyDrive> drive;
    469         rc = coll->FindByName (src, drive.asOutParam());
     469        rc = host->FindHostFloppyDrive (src, drive.asOutParam());
     470
    470471        if (SUCCEEDED (rc))
    471472        {
  • trunk/src/VBox/Main/HostImpl.cpp

    r17238 r17255  
    410410 * @param drives address of result pointer
    411411 */
    412 STDMETHODIMP Host::COMGETTER(FloppyDrives) (IHostFloppyDriveCollection **aDrives)
     412STDMETHODIMP Host::COMGETTER(FloppyDrives) (ComSafeArrayOut (IHostFloppyDrive *, aDrives))
    413413{
    414414    CheckComArgOutPointerValid(aDrives);
     
    462462#endif
    463463
    464     ComObjPtr<HostFloppyDriveCollection> collection;
    465     collection.createObject();
    466     collection->init (list);
    467     collection.queryInterfaceTo(aDrives);
     464    SafeIfaceArray<IHostFloppyDrive> collection (list);
     465    collection.detachTo(ComSafeArrayOutArg (aDrives));
    468466    return rc;
    469467}
     
    33553353}
    33563354
     3355STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IHostFloppyDrive **aDrive)
     3356{
     3357    CheckComArgNotNull(aName);
     3358    CheckComArgOutPointerValid(aDrive);
     3359
     3360    *aDrive = NULL;
     3361
     3362    SafeIfaceArray <IHostFloppyDrive> drivevec;
     3363    HRESULT rc = COMGETTER(FloppyDrives) (ComSafeArrayAsOutParam(drivevec));
     3364    CheckComRCReturnRC (rc);
     3365
     3366    for (size_t i = 0; i < drivevec.size(); ++i)
     3367    {
     3368        Bstr name;
     3369        rc = drivevec[i]->COMGETTER(Name) (name.asOutParam());
     3370        CheckComRCReturnRC (rc);
     3371        if (name == aName)
     3372        {
     3373            ComObjPtr<HostFloppyDrive> found;
     3374            found.createObject();
     3375            Bstr udi, description;
     3376            rc = drivevec[i]->COMGETTER(Udi) (udi.asOutParam());
     3377            CheckComRCReturnRC (rc);
     3378            rc = drivevec[i]->COMGETTER(Description) (description.asOutParam());
     3379            CheckComRCReturnRC (rc);
     3380            found->init(name, udi, description);
     3381            return found.queryInterfaceTo(aDrive);
     3382        }
     3383    }
     3384
     3385    return setError (VBOX_E_OBJECT_NOT_FOUND, HostFloppyDrive::tr (
     3386        "The host floppy drive named '%ls' could not be found"), aName);
     3387}
     3388
    33573389STDMETHODIMP Host::FindHostNetworkInterfaceByName(IN_BSTR name, IHostNetworkInterface **networkInterface)
    33583390{
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17238 r17255  
    63746374  </interface>
    63756375
    6376   <enumerator
    6377      name="IHostFloppyDriveEnumerator" type="IHostFloppyDrive"
    6378      uuid="ce04c924-4f54-432a-9dec-11fddc3ea875"
    6379      />
    6380 
    6381   <collection
    6382      name="IHostFloppyDriveCollection" type="IHostFloppyDrive"
    6383      enumerator="IHostFloppyDriveEnumerator"
    6384      uuid="fd84bb86-c59a-4037-a557-755ff263a460"
    6385      readonly="yes"
    6386      >
    6387     <method name="findByName">
    6388       <desc>
    6389         Searches this collection for a host drive with the given name.
    6390         <note>
    6391           The method returns an error if the given name does not
    6392           correspond to any host drive in the collection.
    6393         </note>
    6394       </desc>
    6395       <param name="name" type="wstring" dir="in">
    6396         <desc>Name of the host drive to search for</desc>
    6397       </param>
    6398       <param name="drive" type="IHostFloppyDrive" dir="return">
    6399         <desc>Found host drive object</desc>
    6400       </param>
    6401     </method>
    6402   </collection>
    6403 
    64046376  <enum
    64056377    name="HostNetworkInterfaceType"
     
    65346506    </attribute>
    65356507
    6536     <attribute name="floppyDrives" type="IHostFloppyDriveCollection" readonly="yes">
     6508    <attribute name="floppyDrives" type="IHostFloppyDrive" readonly="yes" safearray="yes">
    65376509      <desc>List of floppy drives available on the host.</desc>
    65386510    </attribute>
     
    68196791      <param name="drive" type="IHostDVDDrive" dir="return">
    68206792        <desc>Found host drive object</desc>
     6793      </param>
     6794    </method>
     6795
     6796    <method name="findHostFloppyDrive">
     6797      <desc>
     6798        Searches for a host floppy drive with the given @c name.
     6799
     6800        <result name="VBOX_E_OBJECT_NOT_FOUND">
     6801          Given @c name does not correspond to any host floppy drive.
     6802        </result>
     6803
     6804      </desc>
     6805      <param name="name" type="wstring" dir="in">
     6806        <desc>Name of the host floppy drive to search for</desc>
     6807      </param>
     6808      <param name="drive" type="IHostFloppyDrive" dir="return">
     6809        <desc>Found host floppy drive object</desc>
    68216810      </param>
    68226811    </method>
  • trunk/src/VBox/Main/include/HostFloppyDriveImpl.h

    r15051 r17255  
    2424
    2525#include "VirtualBoxBase.h"
    26 #include "Collection.h"
    2726
    2827class ATL_NO_VTABLE HostFloppyDrive :
     
    8382};
    8483
    85 COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostFloppyDrive)
    86 
    87     STDMETHOD(FindByName) (IN_BSTR aName, IHostFloppyDrive **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, HostFloppyDriveCollection::tr (
    108                 "The host floppy drive named '%ls' could not be found"), aName);
    109 
    110         return found.queryInterfaceTo (aDrive);
    111     }
    112 
    113 COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostFloppyDrive)
    114 
    11584#endif // ____H_HOSTFLOPPYDRIVEIMPL
    11685/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/HostImpl.h

    r17238 r17255  
    8282    // IHost properties
    8383    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IHostDVDDrive*, drives));
    84     STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
     84    STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IHostFloppyDrive*, drives));
    8585    STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
    8686    STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters);
     
    112112
    113113    STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IHostDVDDrive **aDrive);
     114    STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IHostFloppyDrive **aDrive);
    114115    STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
    115116    STDMETHOD(FindHostNetworkInterfaceById) (IN_GUID id, IHostNetworkInterface **networkInterface);
  • trunk/src/VBox/Main/xpcom/server.cpp

    r17238 r17255  
    243243
    244244COM_IMPL_READONLY_ENUM_AND_COLLECTION(Snapshot)
    245 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostFloppyDrive)
    246245#ifdef VBOX_WITH_USB
    247246COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostUSBDevice)
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