VirtualBox

Changeset 17684 in vbox


Ignore:
Timestamp:
Mar 11, 2009 12:15:33 PM (16 years ago)
Author:
vboxsync
Message:

#3551: “Main: Replace remaining collections with safe arrays”
Replaced HostUSBDeviceCollection. Reviewed/Okayed by dmik, sunlover.

Location:
trunk/src/VBox
Files:
1 deleted
19 edited

Legend:

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

    r17553 r17684  
    583583                    ComPtr <IHost> host;
    584584                    CHECK_ERROR_BREAK (a->virtualBox, COMGETTER(Host) (host.asOutParam()));
    585                     ComPtr <IHostUSBDeviceCollection> coll;
    586                     CHECK_ERROR_BREAK (host, COMGETTER(USBDevices) (coll.asOutParam()));
     585                    SafeIfaceArray <IHostUSBDevice> coll;
     586                    CHECK_ERROR_BREAK (host, COMGETTER(USBDevices) (ComSafeArrayAsOutParam(coll)));
    587587                    ComPtr <IHostUSBDevice> dev;
    588                     CHECK_ERROR_BREAK (coll, FindByAddress (Bstr (a->argv [2]), dev.asOutParam()));
     588                    CHECK_ERROR_BREAK (host, FindUSBDeviceByAddress (Bstr (a->argv [2]), dev.asOutParam()));
    589589                    CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam()));
    590590                }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r17669 r17684  
    12141214                    RTPrintf("Available remote USB devices:\n\n");
    12151215
    1216                 ComPtr<IHostUSBDeviceCollection> coll;
    1217                 CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (coll.asOutParam()), rc);
    1218 
    1219                 ComPtr <IHostUSBDeviceEnumerator> en;
    1220                 CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
    1221 
    1222                 BOOL more = FALSE;
    1223                 ASSERT(SUCCEEDED(rc = en->HasMore(&more)));
    1224                 if (FAILED(rc))
    1225                     return rc;
    1226 
    1227                 if (!more)
     1216                SafeIfaceArray <IHostUSBDevice> coll;
     1217                CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (ComSafeArrayAsOutParam(coll)), rc);
     1218
     1219                if (coll.size() == 0)
    12281220                {
    12291221                    if (details != VMINFO_MACHINEREADABLE)
     
    12311223                }
    12321224                else
    1233                 while (more)
    12341225                {
    1235                     ComPtr <IHostUSBDevice> dev;
    1236                     ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam())));
    1237                     if (FAILED(rc))
    1238                         return rc;
    1239 
    1240                     /* Query info. */
    1241                     Guid id;
    1242                     CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
    1243                     USHORT usVendorId;
    1244                     CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
    1245                     USHORT usProductId;
    1246                     CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
    1247                     USHORT bcdRevision;
    1248                     CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
    1249 
    1250                     if (details == VMINFO_MACHINEREADABLE)
    1251                         RTPrintf("USBRemoteUUID%d=\"%S\"\n"
    1252                                  "USBRemoteVendorId%d=\"%#06x\"\n"
    1253                                  "USBRemoteProductId%d=\"%#06x\"\n"
    1254                                  "USBRemoteRevision%d=\"%#04x%02x\"\n",
    1255                                  index + 1, id.toString().raw(),
    1256                                  index + 1, usVendorId,
    1257                                  index + 1, usProductId,
    1258                                  index + 1, bcdRevision >> 8, bcdRevision & 0xff);
    1259                     else
    1260                         RTPrintf("UUID:               %S\n"
    1261                                  "VendorId:           0x%04x (%04X)\n"
    1262                                  "ProductId:          0x%04x (%04X)\n"
    1263                                  "Revision:           %u.%u (%02u%02u)\n",
    1264                                  id.toString().raw(),
    1265                                  usVendorId, usVendorId, usProductId, usProductId,
    1266                                  bcdRevision >> 8, bcdRevision & 0xff,
    1267                                  bcdRevision >> 8, bcdRevision & 0xff);
    1268 
    1269                     /* optional stuff. */
    1270                     Bstr bstr;
    1271                     CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
    1272                     if (!bstr.isEmpty())
     1226                    for (index = 0; index < coll.size(); ++index)
    12731227                    {
     1228                        ComPtr <IHostUSBDevice> dev = coll[index];
     1229
     1230                        /* Query info. */
     1231                        Guid id;
     1232                        CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
     1233                        USHORT usVendorId;
     1234                        CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
     1235                        USHORT usProductId;
     1236                        CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
     1237                        USHORT bcdRevision;
     1238                        CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
     1239
    12741240                        if (details == VMINFO_MACHINEREADABLE)
    1275                             RTPrintf("USBRemoteManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
     1241                            RTPrintf("USBRemoteUUID%zu=\"%S\"\n"
     1242                                     "USBRemoteVendorId%zu=\"%#06x\"\n"
     1243                                     "USBRemoteProductId%zu=\"%#06x\"\n"
     1244                                     "USBRemoteRevision%zu=\"%#04x%02x\"\n",
     1245                                     index + 1, id.toString().raw(),
     1246                                     index + 1, usVendorId,
     1247                                     index + 1, usProductId,
     1248                                     index + 1, bcdRevision >> 8, bcdRevision & 0xff);
    12761249                        else
    1277                             RTPrintf("Manufacturer:       %lS\n", bstr.raw());
     1250                            RTPrintf("UUID:               %S\n"
     1251                                     "VendorId:           0x%04x (%04X)\n"
     1252                                     "ProductId:          0x%04x (%04X)\n"
     1253                                     "Revision:           %u.%u (%02u%02u)\n",
     1254                                     id.toString().raw(),
     1255                                     usVendorId, usVendorId, usProductId, usProductId,
     1256                                     bcdRevision >> 8, bcdRevision & 0xff,
     1257                                     bcdRevision >> 8, bcdRevision & 0xff);
     1258
     1259                        /* optional stuff. */
     1260                        Bstr bstr;
     1261                        CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
     1262                        if (!bstr.isEmpty())
     1263                        {
     1264                            if (details == VMINFO_MACHINEREADABLE)
     1265                                RTPrintf("USBRemoteManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
     1266                            else
     1267                                RTPrintf("Manufacturer:       %lS\n", bstr.raw());
     1268                        }
     1269                        CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
     1270                        if (!bstr.isEmpty())
     1271                        {
     1272                            if (details == VMINFO_MACHINEREADABLE)
     1273                                RTPrintf("USBRemoteProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
     1274                            else
     1275                                RTPrintf("Product:            %lS\n", bstr.raw());
     1276                        }
     1277                        CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
     1278                        if (!bstr.isEmpty())
     1279                        {
     1280                            if (details == VMINFO_MACHINEREADABLE)
     1281                                RTPrintf("USBRemoteSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
     1282                            else
     1283                                RTPrintf("SerialNumber:       %lS\n", bstr.raw());
     1284                        }
     1285                        CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
     1286                        if (!bstr.isEmpty())
     1287                        {
     1288                            if (details == VMINFO_MACHINEREADABLE)
     1289                                RTPrintf("USBRemoteAddress%zu=\"%lS\"\n", index + 1, bstr.raw());
     1290                            else
     1291                                RTPrintf("Address:            %lS\n", bstr.raw());
     1292                        }
     1293
     1294                        if (details != VMINFO_MACHINEREADABLE)
     1295                            RTPrintf("\n");
    12781296                    }
    1279                     CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
    1280                     if (!bstr.isEmpty())
    1281                     {
    1282                         if (details == VMINFO_MACHINEREADABLE)
    1283                             RTPrintf("USBRemoteProduct%d=\"%lS\"\n", index + 1, bstr.raw());
    1284                         else
    1285                             RTPrintf("Product:            %lS\n", bstr.raw());
    1286                     }
    1287                     CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
    1288                     if (!bstr.isEmpty())
    1289                     {
    1290                         if (details == VMINFO_MACHINEREADABLE)
    1291                             RTPrintf("USBRemoteSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
    1292                         else
    1293                             RTPrintf("SerialNumber:       %lS\n", bstr.raw());
    1294                     }
    1295                     CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
    1296                     if (!bstr.isEmpty())
    1297                     {
    1298                         if (details == VMINFO_MACHINEREADABLE)
    1299                             RTPrintf("USBRemoteAddress%d=\"%lS\"\n", index + 1, bstr.raw());
    1300                         else
    1301                             RTPrintf("Address:            %lS\n", bstr.raw());
    1302                     }
    1303 
    1304                     if (details != VMINFO_MACHINEREADABLE)
    1305                         RTPrintf("\n");
    1306 
    1307                     ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
    1308                     if (FAILED(rc))
    1309                         return rc;
    1310 
    1311                     index ++;
    13121297                }
    13131298            }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r17613 r17684  
    586586            CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
    587587
    588             ComPtr<IHostUSBDeviceCollection> CollPtr;
    589             CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(CollPtr.asOutParam()), 1);
    590 
    591             ComPtr<IHostUSBDeviceEnumerator> EnumPtr;
    592             CHECK_ERROR_RET (CollPtr, Enumerate(EnumPtr.asOutParam()), 1);
     588            SafeIfaceArray <IHostUSBDevice> CollPtr;
     589            CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1);
    593590
    594591            RTPrintf("Host USB Devices:\n\n");
    595592
    596             BOOL fMore = FALSE;
    597             ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
    598             if (FAILED(rc))
    599                 return rc;
    600 
    601             if (!fMore)
     593            if (CollPtr.size() == 0)
    602594            {
    603595                RTPrintf("<none>\n\n");
    604596            }
    605597            else
    606             while (fMore)
    607             {
    608                 ComPtr <IHostUSBDevice> dev;
    609                 ASSERT(SUCCEEDED(rc = EnumPtr->GetNext (dev.asOutParam())));
    610                 if (FAILED(rc))
    611                     return rc;
    612 
    613                 /* Query info. */
    614                 Guid id;
    615                 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
    616                 USHORT usVendorId;
    617                 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
    618                 USHORT usProductId;
    619                 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
    620                 USHORT bcdRevision;
    621                 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
    622 
    623                 RTPrintf("UUID:               %S\n"
    624                         "VendorId:           0x%04x (%04X)\n"
    625                         "ProductId:          0x%04x (%04X)\n"
    626                         "Revision:           %u.%u (%02u%02u)\n",
    627                         id.toString().raw(),
    628                         usVendorId, usVendorId, usProductId, usProductId,
    629                         bcdRevision >> 8, bcdRevision & 0xff,
    630                         bcdRevision >> 8, bcdRevision & 0xff);
    631 
    632                 /* optional stuff. */
    633                 Bstr bstr;
    634                 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
    635                 if (!bstr.isEmpty())
    636                     RTPrintf("Manufacturer:       %lS\n", bstr.raw());
    637                 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
    638                 if (!bstr.isEmpty())
    639                     RTPrintf("Product:            %lS\n", bstr.raw());
    640                 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
    641                 if (!bstr.isEmpty())
    642                     RTPrintf("SerialNumber:       %lS\n", bstr.raw());
    643                 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
    644                 if (!bstr.isEmpty())
    645                     RTPrintf("Address:            %lS\n", bstr.raw());
    646 
    647                 /* current state  */
    648                 USBDeviceState_T state;
    649                 CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
    650                 const char *pszState = "?";
    651                 switch (state)
    652                 {
    653                     case USBDeviceState_NotSupported:
    654                         pszState = "Not supported"; break;
    655                     case USBDeviceState_Unavailable:
    656                         pszState = "Unavailable"; break;
    657                     case USBDeviceState_Busy:
    658                         pszState = "Busy"; break;
    659                     case USBDeviceState_Available:
    660                         pszState = "Available"; break;
    661                     case USBDeviceState_Held:
    662                         pszState = "Held"; break;
    663                     case USBDeviceState_Captured:
    664                         pszState = "Captured"; break;
    665                     default:
    666                         ASSERT (false);
    667                         break;
    668                 }
    669                 RTPrintf("Current State:      %s\n\n", pszState);
    670 
    671                 ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
    672                 if (FAILED(rc))
    673                     return rc;
     598            {
     599                for (size_t i = 0; i < CollPtr.size(); ++i)
     600                {
     601                    ComPtr <IHostUSBDevice> dev = CollPtr[i];
     602
     603                    /* Query info. */
     604                    Guid id;
     605                    CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
     606                    USHORT usVendorId;
     607                    CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
     608                    USHORT usProductId;
     609                    CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
     610                    USHORT bcdRevision;
     611                    CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
     612
     613                    RTPrintf("UUID:               %S\n"
     614                            "VendorId:           0x%04x (%04X)\n"
     615                            "ProductId:          0x%04x (%04X)\n"
     616                            "Revision:           %u.%u (%02u%02u)\n",
     617                            id.toString().raw(),
     618                            usVendorId, usVendorId, usProductId, usProductId,
     619                            bcdRevision >> 8, bcdRevision & 0xff,
     620                            bcdRevision >> 8, bcdRevision & 0xff);
     621
     622                    /* optional stuff. */
     623                    Bstr bstr;
     624                    CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
     625                    if (!bstr.isEmpty())
     626                        RTPrintf("Manufacturer:       %lS\n", bstr.raw());
     627                    CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
     628                    if (!bstr.isEmpty())
     629                        RTPrintf("Product:            %lS\n", bstr.raw());
     630                    CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
     631                    if (!bstr.isEmpty())
     632                        RTPrintf("SerialNumber:       %lS\n", bstr.raw());
     633                    CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
     634                    if (!bstr.isEmpty())
     635                        RTPrintf("Address:            %lS\n", bstr.raw());
     636
     637                    /* current state  */
     638                    USBDeviceState_T state;
     639                    CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
     640                    const char *pszState = "?";
     641                    switch (state)
     642                    {
     643                        case USBDeviceState_NotSupported:
     644                            pszState = "Not supported"; break;
     645                        case USBDeviceState_Unavailable:
     646                            pszState = "Unavailable"; break;
     647                        case USBDeviceState_Busy:
     648                            pszState = "Busy"; break;
     649                        case USBDeviceState_Available:
     650                            pszState = "Available"; break;
     651                        case USBDeviceState_Held:
     652                            pszState = "Held"; break;
     653                        case USBDeviceState_Captured:
     654                            pszState = "Captured"; break;
     655                        default:
     656                            ASSERT (false);
     657                            break;
     658                    }
     659                    RTPrintf("Current State:      %s\n\n", pszState);
     660                }
    674661            }
    675662        }
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r17669 r17684  
    55495549    CHost host = vboxGlobal().virtualBox().GetHost();
    55505550
    5551     bool isUSBEmpty = host.GetUSBDevices().GetCount() == 0;
     5551    bool isUSBEmpty = host.GetUSBDevices().size() == 0;
    55525552    if (isUSBEmpty)
    55535553    {
     
    55595559    else
    55605560    {
    5561         CHostUSBDeviceEnumerator en = host.GetUSBDevices().Enumerate();
    5562         while (en.HasMore())
    5563         {
    5564             CHostUSBDevice dev = en.GetNext();
     5561        CHostUSBDeviceVector devvec = host.GetUSBDevices();
     5562        for (int i = 0; i < devvec.size(); ++i)
     5563        {
     5564            CHostUSBDevice dev = devvec[i];
    55655565            CUSBDevice usb (dev);
    55665566            QAction *action = addAction (vboxGlobal().details (usb));
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r17675 r17684  
    12551255}
    12561256
    1257 STDMETHODIMP Console::COMGETTER(RemoteUSBDevices) (IHostUSBDeviceCollection **aRemoteUSBDevices)
    1258 {
    1259     CheckComArgOutPointerValid(aRemoteUSBDevices);
     1257STDMETHODIMP Console::COMGETTER(RemoteUSBDevices) (ComSafeArrayOut (IHostUSBDevice *, aRemoteUSBDevices))
     1258{
     1259    CheckComArgOutSafeArrayPointerValid(aRemoteUSBDevices);
    12601260
    12611261    AutoCaller autoCaller (this);
     
    12641264    AutoReadLock alock (this);
    12651265
    1266     ComObjPtr <RemoteUSBDeviceCollection> collection;
    1267     collection.createObject();
    1268     collection->init (mRemoteUSBDevices);
    1269     collection.queryInterfaceTo (aRemoteUSBDevices);
     1266    SafeIfaceArray <IHostUSBDevice> collection (mRemoteUSBDevices);
     1267    collection.detachTo (ComSafeArrayOutArg(aRemoteUSBDevices));
    12701268
    12711269    return S_OK;
  • trunk/src/VBox/Main/HostImpl.cpp

    r17679 r17684  
    10821082}
    10831083
    1084 STDMETHODIMP Host::COMGETTER(USBDevices)(IHostUSBDeviceCollection **aUSBDevices)
     1084STDMETHODIMP Host::COMGETTER(USBDevices)(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices))
    10851085{
    10861086#ifdef VBOX_WITH_USB
    1087     CheckComArgOutPointerValid(aUSBDevices);
     1087    CheckComArgOutSafeArrayPointerValid(aUSBDevices);
    10881088
    10891089    AutoWriteLock alock (this);
     
    10931093    CheckComRCReturnRC (rc);
    10941094
    1095     return mUSBProxyService->getDeviceCollection (aUSBDevices);
     1095    return mUSBProxyService->getDeviceCollection (ComSafeArrayOutArg(aUSBDevices));
    10961096
    10971097#else
     
    25022502}
    25032503
     2504STDMETHODIMP Host::FindUSBDeviceByAddress (IN_BSTR aAddress, IHostUSBDevice **aDevice)
     2505{
     2506#ifdef VBOX_WITH_USB
     2507    CheckComArgNotNull(aAddress);
     2508    CheckComArgOutPointerValid(aDevice);
     2509
     2510    *aDevice = NULL;
     2511
     2512    SafeIfaceArray <IHostUSBDevice> devsvec;
     2513    HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec));
     2514    CheckComRCReturnRC (rc);
     2515
     2516    for (size_t i = 0; i < devsvec.size(); ++i)
     2517    {
     2518        Bstr address;
     2519        rc = devsvec[i]->COMGETTER(Address) (address.asOutParam());
     2520        CheckComRCReturnRC (rc);
     2521        if (address == aAddress)
     2522        {
     2523            return ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo (aDevice);
     2524        }
     2525    }
     2526
     2527    return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr (
     2528        "Could not find a USB device with address '%ls'"),
     2529        aAddress);
     2530
     2531#else   /* !VBOX_WITH_USB */
     2532    return E_NOTIMPL;
     2533#endif  /* !VBOX_WITH_USB */
     2534}
     2535
     2536STDMETHODIMP Host::FindUSBDeviceById (IN_GUID aId, IHostUSBDevice **aDevice)
     2537{
     2538#ifdef VBOX_WITH_USB
     2539    CheckComArgExpr(aId, Guid (aId).isEmpty() == false);
     2540    CheckComArgOutPointerValid(aDevice);
     2541
     2542    *aDevice = NULL;
     2543
     2544    SafeIfaceArray <IHostUSBDevice> devsvec;
     2545    HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec));
     2546    CheckComRCReturnRC (rc);
     2547
     2548    for (size_t i = 0; i < devsvec.size(); ++i)
     2549    {
     2550        Guid id;
     2551        rc = devsvec[i]->COMGETTER(Id) (id.asOutParam());
     2552        CheckComRCReturnRC (rc);
     2553        if (id == aId)
     2554        {
     2555            return ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo (aDevice);
     2556        }
     2557    }
     2558
     2559    return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr (
     2560        "Could not find a USB device with uuid {%RTuuid}"),
     2561        Guid (aId).raw());
     2562
     2563#else   /* !VBOX_WITH_USB */
     2564    return E_NOTIMPL;
     2565#endif  /* !VBOX_WITH_USB */
     2566}
     2567
    25042568
    25052569/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17679 r17684  
    56005600  <interface
    56015601     name="IConsole" extends="$unknown"
    5602      uuid="3d458cf1-d8aa-4593-84db-41de9e7242d8"
     5602     uuid="9511bc54-15ee-4ddf-808e-472aba03809c"
    56035603     wsmap="managed"
    56045604     >
     
    56925692    </attribute>
    56935693
    5694     <attribute name="remoteUSBDevices" type="IHostUSBDeviceCollection" readonly="yes">
     5694    <attribute name="remoteUSBDevices" type="IHostUSBDevice" readonly="yes" safearray="yes">
    56955695      <desc>
    56965696        List of USB devices currently attached to the remote VRDP client.
     
    66096609  <interface
    66106610     name="IHost" extends="$unknown"
    6611      uuid="651f04ec-b2a6-4008-b979-3a01c0fc72cc"
     6611     uuid="926469ca-9091-42ef-928e-582d78b66c70"
    66126612     wsmap="managed"
    66136613     >
     
    66326632    </attribute>
    66336633
    6634     <attribute name="USBDevices" type="IHostUSBDeviceCollection" readonly="yes">
     6634    <attribute name="USBDevices" type="IHostUSBDevice" readonly="yes" safearray="yes">
    66356635      <desc>
    66366636        List of USB devices currently attached to the host.
     
    69716971      </param>
    69726972    </method>
     6973
     6974    <method name="findUSBDeviceById">
     6975      <desc>
     6976        Searches for a USB device with the given UUID.
     6977
     6978        <result name="VBOX_E_OBJECT_NOT_FOUND">
     6979          Given @id does not correspond to any USB device.
     6980        </result>
     6981
     6982        <see>IHostUSBDevice::id</see>
     6983      </desc>
     6984      <param name="id" type="uuid" dir="in">
     6985        <desc>UUID of the USB device to search for.</desc>
     6986      </param>
     6987      <param name="device" type="IHostUSBDevice" dir="return">
     6988        <desc>Found USB device object.</desc>
     6989      </param>
     6990    </method>
     6991
     6992    <method name="findUSBDeviceByAddress">
     6993      <desc>
     6994        Searches for a USB device with the given host address.
     6995
     6996        <result name="VBOX_E_OBJECT_NOT_FOUND">
     6997          Given @c name does not correspond to any USB device.
     6998        </result>
     6999
     7000        <see>IHostUSBDevice::address</see>
     7001      </desc>
     7002      <param name="name" type="wstring" dir="in">
     7003        <desc>
     7004          Address of the USB device (as assigned by the host) to
     7005          search for.
     7006        </desc>
     7007      </param>
     7008      <param name="device" type="IHostUSBDevice" dir="return">
     7009        <desc>Found USB device object.</desc>
     7010      </param>
     7011    </method>
     7012
    69737013  </interface>
    69747014
     
    1141011450  </enum>
    1141111451
    11412   <enumerator
    11413      name="IHostUSBDeviceEnumerator" type="IHostUSBDevice"
    11414      uuid="a0c55136-939f-4d20-b9d3-4d406f08bfa5"
    11415      />
    11416 
    11417   <collection
    11418      name="IHostUSBDeviceCollection" type="IHostUSBDevice"
    11419      enumerator="IHostUSBDeviceEnumerator"
    11420      uuid="f9d3f96d-b027-4994-b589-70bb9ee0d364"
    11421      readonly="yes"
    11422      >
    11423     <method name="findById">
    11424       <desc>
    11425         Searches this collection for a USB device with the given UUID.
    11426         <note>
    11427           The method returns an error if the given UUID does not
    11428           correspond to any USB device in the collection.
    11429         </note>
    11430         <see>IHostUSBDevice::id</see>
    11431       </desc>
    11432       <param name="id" type="uuid" dir="in">
    11433         <desc>UUID of the USB device to search for.</desc>
    11434       </param>
    11435       <param name="device" type="IHostUSBDevice" dir="return">
    11436         <desc>Found USB device object.</desc>
    11437       </param>
    11438     </method>
    11439 
    11440     <method name="findByAddress">
    11441       <desc>
    11442         Searches this collection for a USB device with the given
    11443         host address.
    11444         <note>
    11445           The method returns an error if the given address does not
    11446           correspond to any USB device in the collection.
    11447         </note>
    11448         <see>IHostUSBDevice::address</see>
    11449       </desc>
    11450       <param name="name" type="wstring" dir="in">
    11451         <desc>
    11452           Address of the USB device (as assigned by the host) to
    11453           search for.
    11454         </desc>
    11455       </param>
    11456       <param name="device" type="IHostUSBDevice" dir="return">
    11457         <desc>Found USB device object.</desc>
    11458       </param>
    11459     </method>
    11460 
    11461   </collection>
    11462 
    1146311452  <interface
    1146411453     name="IHostUSBDevice" extends="IUSBDevice"
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r17669 r17684  
    116116    STDMETHOD(COMGETTER(Debugger)) (IMachineDebugger **aDebugger);
    117117    STDMETHOD(COMGETTER(USBDevices)) (ComSafeArrayOut (IUSBDevice *, aUSBDevices));
    118     STDMETHOD(COMGETTER(RemoteUSBDevices)) (IHostUSBDeviceCollection **aRemoteUSBDevices);
     118    STDMETHOD(COMGETTER(RemoteUSBDevices)) (ComSafeArrayOut (IHostUSBDevice *, aRemoteUSBDevices));
    119119    STDMETHOD(COMGETTER(RemoteDisplayInfo)) (IRemoteDisplayInfo **aRemoteDisplayInfo);
    120120    STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut (ISharedFolder *, aSharedFolders));
  • trunk/src/VBox/Main/include/GuestOSTypeImpl.h

    r16971 r17684  
    2424
    2525#include "VirtualBoxBase.h"
    26 #include "Collection.h"
    2726#include "Global.h"
    2827
  • trunk/src/VBox/Main/include/HostImpl.h

    r17679 r17684  
    7979    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IHostDVDDrive*, drives));
    8080    STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IHostFloppyDrive*, drives));
    81     STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
     81    STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
    8282    STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
    8383    STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
     
    111111    STDMETHOD(FindHostNetworkInterfaceById) (IN_GUID id, IHostNetworkInterface **networkInterface);
    112112    STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
     113    STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
     114    STDMETHOD(FindUSBDeviceById) (IN_GUID aId, IHostUSBDevice **aDevice);
    113115
    114116    // public methods only for internal purposes
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r17613 r17684  
    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
     
    2626
    2727#include "VirtualBoxBase.h"
    28 #include "Collection.h"
    2928#include "VirtualBoxImpl.h"
    3029
  • trunk/src/VBox/Main/include/MachineImpl.h

    r17673 r17684  
    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
     
    3232#include "FloppyDriveImpl.h"
    3333#include "HardDiskAttachmentImpl.h"
    34 #include "Collection.h"
    3534#include "NetworkAdapterImpl.h"
    3635#include "AudioAdapterImpl.h"
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r17387 r17684  
    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
     
    2626
    2727#include "VirtualBoxBase.h"
    28 #include "Collection.h"
    2928
    3029class Machine;
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r16707 r17684  
    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
     
    2525
    2626#include "VirtualBoxBase.h"
    27 #include "Collection.h"
    2827
    2928#include <VBox/com/SupportErrorInfo.h>
  • trunk/src/VBox/Main/include/RemoteUSBDeviceImpl.h

    r15051 r17684  
    88
    99/*
    10  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     10 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2727
    2828#include "VirtualBoxBase.h"
    29 #include "Collection.h"
    3029
    3130struct _VRDPUSBDEVICEDESC;
     
    138137};
    139138
    140 COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN (ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
    141 
    142     STDMETHOD(FindById) (IN_GUID aId, IHostUSBDevice **aDevice)
    143     {
    144         Guid idToFind = aId;
    145         if (idToFind.isEmpty())
    146             return E_INVALIDARG;
    147         if (!aDevice)
    148             return E_POINTER;
    149 
    150         *aDevice = NULL;
    151         Vector::value_type found;
    152         Vector::iterator it = vec.begin();
    153         while (!found && it != vec.end())
    154         {
    155             Guid id;
    156             (*it)->COMGETTER(Id) (id.asOutParam());
    157             if (id == idToFind)
    158                 found = *it;
    159             ++ it;
    160         }
    161 
    162         if (!found)
    163             return setError (E_INVALIDARG, RemoteUSBDeviceCollection::tr (
    164                 "Could not find a USB device with UUID {%s}"),
    165                 idToFind.toString().raw());
    166 
    167         return found.queryInterfaceTo (aDevice);
    168     }
    169 
    170     STDMETHOD(FindByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice)
    171     {
    172         if (!aAddress)
    173             return E_INVALIDARG;
    174         if (!aDevice)
    175             return E_POINTER;
    176 
    177         *aDevice = NULL;
    178         Vector::value_type found;
    179         Vector::iterator it = vec.begin();
    180         while (!found && it != vec.end())
    181         {
    182             Bstr address;
    183             (*it)->COMGETTER(Address) (address.asOutParam());
    184             if (address == aAddress)
    185                 found = *it;
    186             ++ it;
    187         }
    188 
    189         if (!found)
    190             return setError (E_INVALIDARG, RemoteUSBDeviceCollection::tr (
    191                 "Could not find a USB device with address '%ls'"),
    192                 aAddress);
    193 
    194         return found.queryInterfaceTo (aDevice);
    195     }
    196 
    197 COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_END (ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
    198 
    199 
    200139#endif // ____H_REMOTEUSBDEVICEIMPL
    201140/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/SharedFolderImpl.h

    r16966 r17684  
    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#include <VBox/shflsvc.h>
    2827
  • trunk/src/VBox/Main/include/SnapshotImpl.h

    r17260 r17684  
    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
    2827#include <iprt/time.h>
  • trunk/src/VBox/Main/xpcom/module.cpp

    r17553 r17684  
    8383NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
    8484
    85 COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice)
    86 
    8785/**
    8886 *  Singleton class factory that holds a reference to the created instance
  • trunk/src/VBox/Main/xpcom/server.cpp

    r17669 r17684  
    118118#include <AudioAdapterImpl.h>
    119119#include <SystemPropertiesImpl.h>
    120 #include <Collection.h>
    121120
    122121/* implement nsISupports parts of our objects with support for nsIClassInfo */
     
    239238NS_DECL_CLASSINFO(BIOSSettings)
    240239NS_IMPL_THREADSAFE_ISUPPORTS1_CI(BIOSSettings, IBIOSSettings)
    241 
    242 /* collections and enumerators */
    243 
    244 #ifdef VBOX_WITH_USB
    245 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostUSBDevice)
    246 #endif
    247240
    248241////////////////////////////////////////////////////////////////////////////////
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