Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 17335)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 17336)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2008 Sun Microsystems, Inc.
+ * Copyright (C) 2006-2009 Sun Microsystems, Inc.
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -1120,17 +1120,10 @@
             RTPrintf("\nUSB Device Filters:\n\n");
 
-        ComPtr<IUSBDeviceFilterCollection> Coll;
-        CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(Coll.asOutParam()), rc);
-
-        ComPtr<IUSBDeviceFilterEnumerator> Enum;
-        CHECK_ERROR_RET (Coll, Enumerate(Enum.asOutParam()), rc);
-
-        ULONG index = 0;
-        BOOL fMore = FALSE;
-        ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
-        if (FAILED(rc))
-            return rc;
-
-        if (!fMore)
+        SafeIfaceArray <IUSBDeviceFilter> Coll;
+        CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll)), rc);
+
+        size_t index = 0; // Also used after the "for" below.
+
+        if (Coll.size() == 0)
         {
             if (details != VMINFO_MACHINEREADABLE)
@@ -1138,78 +1131,71 @@
         }
         else
-        while (fMore)
-        {
-            ComPtr<IUSBDeviceFilter> DevPtr;
-            ASSERT(SUCCEEDED(rc = Enum->GetNext(DevPtr.asOutParam())));
-            if (FAILED(rc))
-                return rc;
-
-            /* Query info. */
-
-            if (details != VMINFO_MACHINEREADABLE)
-                RTPrintf("Index:            %lu\n", index);
-
-            BOOL bActive = FALSE;
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterActive%d=\"%s\"\n", index + 1, bActive ? "on" : "off");
-            else
-                RTPrintf("Active:           %s\n", bActive ? "yes" : "no");
-
-            Bstr bstr;
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterName%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Name:             %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterVendorId%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("VendorId:         %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterProductId%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("ProductId:        %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterRevision%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Revision:         %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Manufacturer:     %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterProduct%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Product:          %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterRemote%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Remote:           %lS\n", bstr.raw());
-            CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
-            if (details == VMINFO_MACHINEREADABLE)
-                RTPrintf("USBFilterSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
-            else
-                RTPrintf("Serial Number:    %lS\n", bstr.raw());
-            if (details != VMINFO_MACHINEREADABLE)
-            {
-                ULONG fMaskedIfs;
-                CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
-                if (fMaskedIfs)
-                    RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
-                RTPrintf("\n");
-            }
-
-            ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
-            if (FAILED(rc))
-                return rc;
-
-            index ++;
+        {
+            for (; index < Coll.size(); ++index)
+            {
+                ComPtr<IUSBDeviceFilter> DevPtr = Coll[index];
+
+                /* Query info. */
+
+                if (details != VMINFO_MACHINEREADABLE)
+                    RTPrintf("Index:            %zu\n", index);
+
+                BOOL bActive = FALSE;
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterActive%zu=\"%s\"\n", index + 1, bActive ? "on" : "off");
+                else
+                    RTPrintf("Active:           %s\n", bActive ? "yes" : "no");
+
+                Bstr bstr;
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterName%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Name:             %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterVendorId%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("VendorId:         %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterProductId%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("ProductId:        %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterRevision%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Revision:         %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Manufacturer:     %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Product:          %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterRemote%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Remote:           %lS\n", bstr.raw());
+                CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
+                if (details == VMINFO_MACHINEREADABLE)
+                    RTPrintf("USBFilterSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
+                else
+                    RTPrintf("Serial Number:    %lS\n", bstr.raw());
+                if (details != VMINFO_MACHINEREADABLE)
+                {
+                    ULONG fMaskedIfs;
+                    CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
+                    if (fMaskedIfs)
+                        RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
+                    RTPrintf("\n");
+                }
+            }
         }
 
@@ -1962,3 +1948,3 @@
 
 #endif /* !VBOX_ONLY_DOCS */
-
+/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp	(revision 17335)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp	(revision 17336)
@@ -499,9 +499,8 @@
             else
             {
-                ComPtr <IUSBDeviceFilterCollection> coll;
-                CHECK_ERROR_BREAK (ctl, COMGETTER(DeviceFilters) (coll.asOutParam()));
-
-                ComPtr <IUSBDeviceFilter> flt;
-                CHECK_ERROR_BREAK (coll, GetItemAt (cmd.mIndex, flt.asOutParam()));
+                SafeIfaceArray <IUSBDeviceFilter> coll;
+                CHECK_ERROR_BREAK (ctl, COMGETTER(DeviceFilters) (ComSafeArrayAsOutParam(coll)));
+
+                ComPtr <IUSBDeviceFilter> flt = coll[cmd.mIndex];
 
                 if (!f.mName.isNull())
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp	(revision 17335)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp	(revision 17336)
@@ -2517,9 +2517,8 @@
                 if (ctl.GetEnabled())
                 {
-                    CUSBDeviceFilterCollection coll = ctl.GetDeviceFilters();
-                    CUSBDeviceFilterEnumerator en = coll.Enumerate();
+                    CUSBDeviceFilterVector coll = ctl.GetDeviceFilters();
                     uint active = 0;
-                    while (en.HasMore())
-                        if (en.GetNext().GetActive())
+                    for (int i = 0; i < coll.size(); ++i)
+                        if (coll[i].GetActive())
                             active ++;
 
@@ -2527,5 +2526,5 @@
                         .arg (tr ("Device Filters", "details report (USB)"),
                               tr ("%1 (%2 active)", "details report (USB)")
-                                  .arg (coll.GetCount()).arg (active));
+                                  .arg (coll.size()).arg (active));
                 }
                 else
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsUSB.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsUSB.cpp	(revision 17335)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsUSB.cpp	(revision 17336)
@@ -184,7 +184,7 @@
     if (!ctl.isNull())
     {
-        CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate();
-        while (en.HasMore())
-            addUSBFilter (en.GetNext(), false /* isNew */);
+        CUSBDeviceFilterVector filtvec = ctl.GetDeviceFilters();
+        for (int i = 0; i < filtvec.size(); ++i)
+            addUSBFilter (filtvec[i], false /* isNew */);
     }
 
@@ -204,5 +204,5 @@
         {
             /* First, remove all old filters */
-            for (ulong count = ctl.GetDeviceFilters().GetCount(); count; -- count)
+            for (ulong count = ctl.GetDeviceFilters().size(); count; -- count)
                 ctl.RemoveDeviceFilter (0);
 
Index: /trunk/src/VBox/Main/USBControllerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/USBControllerImpl.cpp	(revision 17335)
+++ /trunk/src/VBox/Main/USBControllerImpl.cpp	(revision 17336)
@@ -362,7 +362,7 @@
 
 
-STDMETHODIMP USBController::COMGETTER(DeviceFilters) (IUSBDeviceFilterCollection **aDevicesFilters)
-{
-    CheckComArgOutPointerValid(aDevicesFilters);
+STDMETHODIMP USBController::COMGETTER(DeviceFilters) (ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters))
+{
+    CheckComArgOutSafeArrayPointerValid(aDevicesFilters);
 
     AutoCaller autoCaller (this);
@@ -371,10 +371,10 @@
     AutoReadLock alock (this);
 
-    ComObjPtr <USBDeviceFilterCollection> collection;
-    collection.createObject();
-#ifdef VBOX_WITH_USB
-    collection->init (*mDeviceFilters.data());
+#ifdef VBOX_WITH_USB
+    SafeIfaceArray <IUSBDeviceFilter> collection (*mDeviceFilters.data());
+#else
+    SafeIfaceArray <IUSBDeviceFilter> collection;
 #endif
-    collection.queryInterfaceTo (aDevicesFilters);
+    collection.detachTo (ComSafeArrayOutArg (aDevicesFilters));
 
     return S_OK;
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 17335)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 17336)
@@ -10811,5 +10811,5 @@
   <interface
      name="IUSBController" extends="$unknown"
-     uuid="f4c2d3dc-f109-4da7-93b1-ec28973ac89f"
+     uuid="238540fa-4b73-435a-a38e-4e1d9eab5c17"
      wsmap="managed"
      >
@@ -10840,5 +10840,5 @@
     </attribute>
 
-    <attribute name="deviceFilters" type="IUSBDeviceFilterCollection" readonly="yes">
+    <attribute name="deviceFilters" type="IUSBDeviceFilter" readonly="yes" safearray="yes">
       <desc>
         List of USB device filters associated with the machine.
@@ -11100,16 +11100,4 @@
   /////////////////////////////////////////////////////////////////////////
   -->
-
-  <enumerator
-     name="IUSBDeviceFilterEnumerator" type="IUSBDeviceFilter"
-     uuid="d5109c61-93e7-4726-926b-0dee1020da56"
-     />
-
-  <collection
-     name="IUSBDeviceFilterCollection" type="IUSBDeviceFilter"
-     enumerator="IUSBDeviceFilterEnumerator"
-     uuid="4fa3fc99-ceb1-4bf5-a9cb-e962d825c1ef"
-     readonly="yes"
-     />
 
   <interface
Index: /trunk/src/VBox/Main/include/USBControllerImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/USBControllerImpl.h	(revision 17335)
+++ /trunk/src/VBox/Main/include/USBControllerImpl.h	(revision 17336)
@@ -99,5 +99,5 @@
     STDMETHOD(COMSETTER(EnabledEhci)) (BOOL aEnabled);
     STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
-    STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
+    STDMETHOD(COMGETTER(DeviceFilters)) (ComSafeArrayOut (IUSBDeviceFilter *, aDevicesFilters));
 
     // IUSBController methods
Index: /trunk/src/VBox/Main/xpcom/server.cpp
===================================================================
--- /trunk/src/VBox/Main/xpcom/server.cpp	(revision 17335)
+++ /trunk/src/VBox/Main/xpcom/server.cpp	(revision 17336)
@@ -245,5 +245,4 @@
 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostUSBDevice)
 COM_IMPL_READONLY_ENUM_AND_COLLECTION(HostUSBDeviceFilter)
-COM_IMPL_READONLY_ENUM_AND_COLLECTION(USBDeviceFilter)
 #endif
 
