VirtualBox

Changeset 47376 in vbox


Ignore:
Timestamp:
Jul 24, 2013 3:13:52 PM (11 years ago)
Author:
vboxsync
Message:

Main/USB: USB Controller implementation rework. Moved filter handling into a separate interface

Location:
trunk
Files:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/log.h

    r47218 r47376  
    492492    /** Main group, IUSBDeviceFilter. */
    493493    LOG_GROUP_MAIN_USBDEVICEFILTER,
     494    /** Main group, IUSBDeviceFilters. */
     495    LOG_GROUP_MAIN_USBDEVICEFILTERS,
    494496    /** Main group, IUSBDeviceStateChangedEvent. */
    495497    LOG_GROUP_MAIN_USBDEVICESTATECHANGEDEVENT,
     
    893895    "MAIN_USBDEVICE", \
    894896    "MAIN_USBDEVICEFILTER", \
     897    "MAIN_USBDEVICEFILTERS", \
    895898    "MAIN_USBDEVICESTATECHANGEDEVENT", \
    896899    "MAIN_VBOXSVCAVAILABILITYCHANGEDEVENT", \
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r47246 r47376  
    17701770        else
    17711771            RTPrintf("EHCI:            %s\n", fEHCIEnabled ? "enabled" : "disabled");
    1772 
     1772    }
     1773
     1774    ComPtr<IUSBDeviceFilters> USBFlts;
     1775    rc = machine->COMGETTER(USBDeviceFilters)(USBFlts.asOutParam());
     1776    if (SUCCEEDED(rc))
     1777    {
    17731778        SafeIfaceArray <IUSBDeviceFilter> Coll;
    1774         rc = USBCtl->COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll));
     1779        rc = USBFlts->COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll));
    17751780        if (SUCCEEDED(rc))
    17761781        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp

    r46658 r47376  
    400400
    401401    ComPtr <IHost> host;
    402     ComPtr <IUSBController> ctl;
     402    ComPtr <IUSBDeviceFilters> flts;
    403403    if (cmd.mGlobal)
    404404        CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1);
     
    409409        /* get the mutable session machine */
    410410        a->session->COMGETTER(Machine)(cmd.mMachine.asOutParam());
    411         /* and get the USB controller */
    412         CHECK_ERROR_RET(cmd.mMachine, COMGETTER(USBController)(ctl.asOutParam()), 1);
     411        /* and get the USB device filters */
     412        CHECK_ERROR_RET(cmd.mMachine, COMGETTER(USBDeviceFilters)(flts.asOutParam()), 1);
    413413    }
    414414
     
    446446            {
    447447                ComPtr <IUSBDeviceFilter> flt;
    448                 CHECK_ERROR_BREAK(ctl, CreateDeviceFilter(f.mName.raw(),
     448                CHECK_ERROR_BREAK(flts, CreateDeviceFilter(f.mName.raw(),
    449449                                                          flt.asOutParam()));
    450450
     
    466466                    CHECK_ERROR_BREAK(flt, COMSETTER(MaskedInterfaces)(f.mMaskedInterfaces));
    467467
    468                 CHECK_ERROR_BREAK(ctl, InsertDeviceFilter(cmd.mIndex, flt));
     468                CHECK_ERROR_BREAK(flts, InsertDeviceFilter(cmd.mIndex, flt));
    469469            }
    470470            break;
     
    502502            {
    503503                SafeIfaceArray <IUSBDeviceFilter> coll;
    504                 CHECK_ERROR_BREAK(ctl, COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(coll)));
     504                CHECK_ERROR_BREAK(flts, COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(coll)));
    505505
    506506                ComPtr <IUSBDeviceFilter> flt = coll[cmd.mIndex];
     
    537537            {
    538538                ComPtr <IUSBDeviceFilter> flt;
    539                 CHECK_ERROR_BREAK(ctl, RemoveDeviceFilter(cmd.mIndex, flt.asOutParam()));
     539                CHECK_ERROR_BREAK(flts, RemoveDeviceFilter(cmd.mIndex, flt.asOutParam()));
    540540            }
    541541            break;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r47170 r47376  
    9393#include "CSystemProperties.h"
    9494#include "CUSBDevice.h"
     95#include "CUSBDeviceFilters.h"
    9596#include "CUSBDeviceFilter.h"
    9697#include "CBIOSSettings.h"
     
    15121513
    15131514        CUSBController ctl = aMachine.GetUSBController();
     1515        CUSBDeviceFilters flts = aMachine.GetUSBDeviceFilters();
    15141516        if (   !ctl.isNull()
     1517            && !flts.isNull()
    15151518            && ctl.GetProxyAvailable())
    15161519        {
     
    15191522            if (ctl.GetEnabled())
    15201523            {
    1521                 CUSBDeviceFilterVector coll = ctl.GetDeviceFilters();
     1524                CUSBDeviceFilterVector coll = flts.GetDeviceFilters();
    15221525                uint active = 0;
    15231526                for (int i = 0; i < coll.size(); ++i)
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r47355 r47376  
    4242#include "CParallelPort.h"
    4343#include "CUSBController.h"
     44#include "CUSBDeviceFilters.h"
    4445#include "CUSBDeviceFilter.h"
    4546#include "CSharedFolder.h"
     
    891892            if (!ctl.isNull() && ctl.GetProxyAvailable())
    892893            {
    893                 if (ctl.GetEnabled())
     894                const CUSBDeviceFilters &flts = machine().GetUSBDeviceFilters();
     895                if (!flts.isNull() && ctl.GetEnabled())
    894896                {
    895                     const CUSBDeviceFilterVector &coll = ctl.GetDeviceFilters();
     897                    const CUSBDeviceFilterVector &coll = flts.GetDeviceFilters();
    896898                    uint uActive = 0;
    897899                    for (int i = 0; i < coll.size(); ++i)
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r45358 r47376  
    3636#include "CConsole.h"
    3737#include "CUSBController.h"
     38#include "CUSBDeviceFilters.h"
    3839#include "CUSBDevice.h"
    3940#include "CUSBDeviceFilter.h"
     
    301302
    302303                /* For each USB filter: */
    303                 const CUSBDeviceFilterVector &filters = controller.GetDeviceFilters();
    304                 for (int iFilterIndex = 0; iFilterIndex < filters.size(); ++iFilterIndex)
     304                const CUSBDeviceFilters &filters = m_machine.GetUSBDeviceFilters();
     305                if (!filters.isNull())
    305306                {
    306                     /* Prepare USB filter data: */
    307                     UIDataSettingsMachineUSBFilter usbFilterData;
    308 
    309                     /* Check if filter is valid: */
    310                     const CUSBDeviceFilter &filter = filters[iFilterIndex];
    311                     if (!filter.isNull())
     307                    const CUSBDeviceFilterVector &coll = filters.GetDeviceFilters();
     308                    for (int iFilterIndex = 0; iFilterIndex < coll.size(); ++iFilterIndex)
    312309                    {
    313                         usbFilterData.m_fActive = filter.GetActive();
    314                         usbFilterData.m_strName = filter.GetName();
    315                         usbFilterData.m_strVendorId = filter.GetVendorId();
    316                         usbFilterData.m_strProductId = filter.GetProductId();
    317                         usbFilterData.m_strRevision = filter.GetRevision();
    318                         usbFilterData.m_strManufacturer = filter.GetManufacturer();
    319                         usbFilterData.m_strProduct = filter.GetProduct();
    320                         usbFilterData.m_strSerialNumber = filter.GetSerialNumber();
    321                         usbFilterData.m_strPort = filter.GetPort();
    322                         usbFilterData.m_strRemote = filter.GetRemote();
     310                        /* Prepare USB filter data: */
     311                        UIDataSettingsMachineUSBFilter usbFilterData;
     312
     313                        /* Check if filter is valid: */
     314                        const CUSBDeviceFilter &filter = coll[iFilterIndex];
     315                        if (!filter.isNull())
     316                        {
     317                            usbFilterData.m_fActive = filter.GetActive();
     318                            usbFilterData.m_strName = filter.GetName();
     319                            usbFilterData.m_strVendorId = filter.GetVendorId();
     320                            usbFilterData.m_strProductId = filter.GetProductId();
     321                            usbFilterData.m_strRevision = filter.GetRevision();
     322                            usbFilterData.m_strManufacturer = filter.GetManufacturer();
     323                            usbFilterData.m_strProduct = filter.GetProduct();
     324                            usbFilterData.m_strSerialNumber = filter.GetSerialNumber();
     325                            usbFilterData.m_strPort = filter.GetPort();
     326                            usbFilterData.m_strRemote = filter.GetRemote();
     327                        }
     328
     329                        /* Cache USB filter data: */
     330                        m_cache.child(iFilterIndex).cacheInitialData(usbFilterData);
    323331                    }
    324 
    325                     /* Cache USB filter data: */
    326                     m_cache.child(iFilterIndex).cacheInitialData(usbFilterData);
    327332                }
    328333            }
     
    490495                {
    491496                    /* Get USB data from cache: */
     497                    CUSBDeviceFilters filters = m_machine.GetUSBDeviceFilters();
    492498                    const UIDataSettingsMachineUSB &usbData = m_cache.data();
    493499                    /* Store USB data: */
     
    498504                    }
    499505                    /* Store USB filters data: */
    500                     if (isMachineInValidMode())
     506                    if (   isMachineInValidMode()
     507                        && !filters.isNull())
    501508                    {
    502509                        /* For each USB filter data set: */
     
    511518                                if (usbFilterCache.wasRemoved() || usbFilterCache.wasUpdated())
    512519                                {
    513                                     controller.RemoveDeviceFilter(iOperationPosition);
     520                                    filters.RemoveDeviceFilter(iOperationPosition);
    514521                                    if (usbFilterCache.wasRemoved())
    515522                                        --iOperationPosition;
     
    522529                                    const UIDataSettingsMachineUSBFilter &usbFilterData = usbFilterCache.data();
    523530                                    /* Store USB filter data: */
    524                                     CUSBDeviceFilter filter = controller.CreateDeviceFilter(usbFilterData.m_strName);
     531                                    CUSBDeviceFilter filter = filters.CreateDeviceFilter(usbFilterData.m_strName);
    525532                                    filter.SetActive(usbFilterData.m_fActive);
    526533                                    filter.SetVendorId(usbFilterData.m_strVendorId);
     
    532539                                    filter.SetPort(usbFilterData.m_strPort);
    533540                                    filter.SetRemote(usbFilterData.m_strRemote);
    534                                     controller.InsertDeviceFilter(iOperationPosition, filter);
     541                                    filters.InsertDeviceFilter(iOperationPosition, filter);
    535542                                }
    536543                            }
  • trunk/src/VBox/Main/Makefile.kmk

    r47018 r47376  
    357357        src-server/SystemPropertiesImpl.cpp \
    358358        src-server/USBControllerImpl.cpp \
     359        src-server/USBDeviceFiltersImpl.cpp \
    359360        src-server/VFSExplorerImpl.cpp \
    360361        src-server/VirtualBoxImpl.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r47338 r47376  
    41274127  <interface
    41284128    name="IMachine" extends="$unknown"
    4129     uuid="f6258810-a760-11e2-9e96-0800200c9a66"
     4129    uuid="00daa773-1d35-40ae-ac06-336aa64959ef"
    41304130    wsmap="managed"
    41314131    >
     
    45354535    </attribute>
    45364536
     4537    <attribute name="USBDeviceFilters" type="IUSBDeviceFilters" readonly="yes">
     4538      <desc>
     4539        Associated USB device filters object.
     4540
     4541        <note>
     4542          If USB functionality is not available in the given edition of
     4543          VirtualBox, this method will set the result code to @c E_NOTIMPL.
     4544        </note>
     4545      </desc>
     4546    </attribute>
     4547
    45374548    <attribute name="audioAdapter" type="IAudioAdapter" readonly="yes">
    45384549      <desc>Associated audio adapter, always present.</desc>
     
    76147625        be returned if the host computer refuses to release it for some reason.
    76157626
    7616         <see><link to="IUSBController::deviceFilters"/>,
     7627        <see><link to="IUSBDeviceFilters::deviceFilters"/>,
    76177628          <link to="USBDeviceState"/></see>
    76187629        <result name="VBOX_E_INVALID_VM_STATE">
     
    76387649        a possible automatic re-attachment.
    76397650
    7640         <see><link to="IUSBController::deviceFilters"/>,
     7651        <see><link to="IUSBDeviceFilters::deviceFilters"/>,
    76417652          <link to="USBDeviceState"/></see>
    76427653
     
    82248235        Unless the device is ignored by these filters, filters of all
    82258236        currently running virtual machines
    8226         (<link to="IUSBController::deviceFilters"/>) are applied to it.
     8237        (<link to="IUSBDeviceFilters::deviceFilters"/>) are applied to it.
    82278238
    82288239        <note>
     
    1631116322
    1631216323  <!--
    16313   // IUSBController
     16324  // IUSBDeviceFilters
    1631416325  /////////////////////////////////////////////////////////////////////////
    1631516326  -->
    1631616327
    1631716328  <interface
    16318     name="IUSBController" extends="$unknown"
    16319     uuid="01e6f13a-0580-452f-a40f-74e32a5e4921"
     16329    name="IUSBDeviceFilters" extends="$unknown"
     16330    uuid="2ab550b2-53cc-4c2e-ae07-0adf4114e75c"
    1632016331    wsmap="managed"
    1632116332    >
    16322     <attribute name="enabled" type="boolean">
    16323       <desc>
    16324         Flag whether the USB controller is present in the
    16325         guest system. If disabled, the virtual guest hardware will
    16326         not contain any USB controller. Can only be changed when
    16327         the VM is powered off.
    16328       </desc>
    16329     </attribute>
    16330 
    16331     <attribute name="enabledEHCI" type="boolean">
    16332       <desc>
    16333         Flag whether the USB EHCI controller is present in the
    16334         guest system. If disabled, the virtual guest hardware will
    16335         not contain a USB EHCI controller. Can only be changed when
    16336         the VM is powered off.
    16337       </desc>
    16338     </attribute>
    16339 
    16340     <attribute name="proxyAvailable" type="boolean" readonly="yes">
    16341       <desc>
    16342         Flag whether there is an USB proxy available.
    16343       </desc>
    16344     </attribute>
    16345 
    16346     <attribute name="USBStandard" type="unsigned short" readonly="yes">
    16347       <desc>
    16348         USB standard version which the controller implements.
    16349         This is a BCD which means that the major version is in the
    16350         high byte and minor version is in the low byte.
    16351       </desc>
    16352     </attribute>
    1635316333
    1635416334    <attribute name="deviceFilters" type="IUSBDeviceFilter" readonly="yes" safearray="yes">
     
    1646416444      </param>
    1646516445    </method>
     16446
     16447  </interface>
     16448
     16449  <!--
     16450  // IUSBController
     16451  /////////////////////////////////////////////////////////////////////////
     16452  -->
     16453
     16454  <interface
     16455    name="IUSBController" extends="$unknown"
     16456    uuid="f12e6dda-2bad-40c4-8f2e-2d08fe8b74d4"
     16457    wsmap="managed"
     16458    >
     16459    <attribute name="enabled" type="boolean">
     16460      <desc>
     16461        Flag whether the USB controller is present in the
     16462        guest system. If disabled, the virtual guest hardware will
     16463        not contain any USB controller. Can only be changed when
     16464        the VM is powered off.
     16465      </desc>
     16466    </attribute>
     16467
     16468    <attribute name="enabledEHCI" type="boolean">
     16469      <desc>
     16470        Flag whether the USB EHCI controller is present in the
     16471        guest system. If disabled, the virtual guest hardware will
     16472        not contain a USB EHCI controller. Can only be changed when
     16473        the VM is powered off.
     16474      </desc>
     16475    </attribute>
     16476
     16477    <attribute name="proxyAvailable" type="boolean" readonly="yes">
     16478      <desc>
     16479        Flag whether there is an USB proxy available.
     16480      </desc>
     16481    </attribute>
     16482
     16483    <attribute name="USBStandard" type="unsigned short" readonly="yes">
     16484      <desc>
     16485        USB standard version which the controller implements.
     16486        This is a BCD which means that the major version is in the
     16487        high byte and minor version is in the low byte.
     16488      </desc>
     16489    </attribute>
    1646616490
    1646716491  </interface>
     
    1663216656      </note>
    1663316657
    16634       <see><link to="IUSBController::deviceFilters"/>,
     16658      <see><link to="IUSBDeviceFilters::deviceFilters"/>,
    1663516659        <link to="IHostUSBDeviceFilter"/></see>
    1663616660    </desc>
     
    1674716771      either ignore the device, or put it to USBDeviceState_Held state, or do
    1674816772      nothing. Unless the device is ignored by global filters, filters of all
    16749       currently running guests (<link to="IUSBController::deviceFilters"/>) are
     16773      currently running guests (<link to="IUSBDeviceFilters::deviceFilters"/>) are
    1675016774      activated that can put it to USBDeviceState_Captured state.
    1675116775
     
    1687816902        The <link to="IUSBDeviceFilter::remote"/> attribute is ignored by this type of
    1687916903        filters, because it makes sense only for
    16880         <link to="IUSBController::deviceFilters">machine USB filters</link>.
     16904        <link to="IUSBDeviceFilters::deviceFilters">machine USB filters</link>.
    1688116905      </note>
    1688216906
  • trunk/src/VBox/Main/include/MachineImpl.h

    r46667 r47376  
    6565class MachineDebugger;
    6666class USBController;
     67class USBDeviceFilters;
    6768class Snapshot;
    6869class SharedFolder;
     
    457458    STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
    458459    STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
     460    STDMETHOD(COMGETTER(USBDeviceFilters))(IUSBDeviceFilters * *aUSBDeviceFilters);
    459461    STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
    460462    STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
     
    755757    void getDefaultVideoCaptureFile(Utf8Str &strFile);
    756758
     759    bool isUSBControllerPresent();
     760
    757761    HRESULT launchVMProcess(IInternalSessionControl *aControl,
    758762                            const Utf8Str &strType,
     
    990994    // so they cannot be a part of HWData
    991995
    992     const ComObjPtr<VRDEServer>     mVRDEServer;
    993     const ComObjPtr<SerialPort>     mSerialPorts[SchemaDefs::SerialPortCount];
    994     const ComObjPtr<ParallelPort>   mParallelPorts[SchemaDefs::ParallelPortCount];
    995     const ComObjPtr<AudioAdapter>   mAudioAdapter;
    996     const ComObjPtr<USBController>  mUSBController;
    997     const ComObjPtr<BIOSSettings>   mBIOSSettings;
     996    const ComObjPtr<VRDEServer>        mVRDEServer;
     997    const ComObjPtr<SerialPort>        mSerialPorts[SchemaDefs::SerialPortCount];
     998    const ComObjPtr<ParallelPort>      mParallelPorts[SchemaDefs::ParallelPortCount];
     999    const ComObjPtr<AudioAdapter>      mAudioAdapter;
     1000    const ComObjPtr<USBController>     mUSBController;
     1001    const ComObjPtr<USBDeviceFilters>  mUSBDeviceFilters;
     1002    const ComObjPtr<BIOSSettings>      mBIOSSettings;
    9981003    typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
    9991004    NetworkAdapterVector            mNetworkAdapters;
  • trunk/src/VBox/Main/include/USBControllerImpl.h

    r42551 r47376  
    6464    STDMETHOD(COMGETTER(ProxyAvailable))(BOOL *aEnabled);
    6565    STDMETHOD(COMGETTER(USBStandard))(USHORT *aUSBStandard);
    66     STDMETHOD(COMGETTER(DeviceFilters))(ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters));
    67 
    68     // IUSBController methods
    69     STDMETHOD(CreateDeviceFilter)(IN_BSTR aName, IUSBDeviceFilter **aFilter);
    70     STDMETHOD(InsertDeviceFilter)(ULONG aPosition, IUSBDeviceFilter *aFilter);
    71     STDMETHOD(RemoveDeviceFilter)(ULONG aPosition, IUSBDeviceFilter **aFilter);
    7266
    7367    // public methods only for internal purposes
     
    7973    void commit();
    8074    void copyFrom(USBController *aThat);
    81 
    82 #ifdef VBOX_WITH_USB
    83     HRESULT onDeviceFilterChange(USBDeviceFilter *aFilter,
    84                                  BOOL aActiveChanged = FALSE);
    85 
    86     bool hasMatchingFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
    87     bool hasMatchingFilter(IUSBDevice *aUSBDevice, ULONG *aMaskedIfs);
    88 
    89     HRESULT notifyProxy(bool aInsertFilters);
    90 #endif /* VBOX_WITH_USB */
    91 
    92     // public methods for internal purposes only
    93     // (ensure there is a caller and a read lock before calling them!)
    94     Machine* getMachine();
    9575
    9676private:
  • trunk/src/VBox/Main/include/USBDeviceFilterImpl.h

    r44528 r47376  
    2424#include <VBox/usbfilter.h>
    2525
    26 class USBController;
     26class USBDeviceFilters;
    2727class Host;
    2828namespace settings
     
    8383
    8484    // public initializer/uninitializer for internal purposes only
    85     HRESULT init(USBController *aParent,
     85    HRESULT init(USBDeviceFilters *aParent,
    8686                 const settings::USBDeviceFilter &data);
    87     HRESULT init(USBController *aParent, IN_BSTR aName);
    88     HRESULT init(USBController *aParent, USBDeviceFilter *aThat,
     87    HRESULT init(USBDeviceFilters *aParent, IN_BSTR aName);
     88    HRESULT init(USBDeviceFilters *aParent, USBDeviceFilter *aThat,
    8989                 bool aReshare = false);
    90     HRESULT initCopy(USBController *aParent, USBDeviceFilter *aThat);
     90    HRESULT initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat);
    9191    void uninit();
    9292
     
    143143    HRESULT usbFilterFieldSetter(USBFILTERIDX aIdx, const Utf8Str &strNew);
    144144
    145     USBController * const       mParent;
    146     USBDeviceFilter * const     mPeer;
     145    USBDeviceFilters * const     mParent;
     146    USBDeviceFilter  * const     mPeer;
    147147
    148148    Backupable<Data> mData;
     
    154154    bool mInList;
    155155
    156     friend class USBController;
     156    friend class USBDeviceFilters;
    157157};
    158158
  • trunk/src/VBox/Main/include/USBDeviceFiltersImpl.h

    r47360 r47376  
    33/** @file
    44 *
    5  * VBox USBController COM Class declaration.
     5 * VBox USBDeviceFilters COM Class declaration.
    66 */
    77
    88/*
    9  * Copyright (C) 2005-2012 Oracle Corporation
     9 * Copyright (C) 2013 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 #ifndef ____H_USBCONTROLLERIMPL
    21 #define ____H_USBCONTROLLERIMPL
     20#ifndef ____H_USBDEVICEFILTERSIMPL
     21#define ____H_USBDEVICEFILTERSIMPL
    2222
    2323#include "VirtualBoxBase.h"
     
    3131}
    3232
    33 class ATL_NO_VTABLE USBController :
     33class ATL_NO_VTABLE USBDeviceFilters :
    3434    public VirtualBoxBase,
    35     VBOX_SCRIPTABLE_IMPL(IUSBController)
     35    VBOX_SCRIPTABLE_IMPL(IUSBDeviceFilters)
    3636{
    3737public:
    38     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(USBController, IUSBController)
     38    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(USBDeviceFilters, IUSBDeviceFilters)
    3939
    40     DECLARE_NOT_AGGREGATABLE(USBController)
     40    DECLARE_NOT_AGGREGATABLE(USBDeviceFilters)
    4141
    4242    DECLARE_PROTECT_FINAL_CONSTRUCT()
    4343
    4444    BEGIN_COM_MAP(USBController)
    45         VBOX_DEFAULT_INTERFACE_ENTRIES(IUSBController)
     45        VBOX_DEFAULT_INTERFACE_ENTRIES(IUSBDeviceFilters)
    4646    END_COM_MAP()
    4747
    48     DECLARE_EMPTY_CTOR_DTOR(USBController)
     48    DECLARE_EMPTY_CTOR_DTOR(USBDeviceFilters)
    4949
    5050    HRESULT FinalConstruct();
     
    5353    // public initializer/uninitializer for internal purposes only
    5454    HRESULT init(Machine *aParent);
    55     HRESULT init(Machine *aParent, USBController *aThat);
    56     HRESULT initCopy(Machine *aParent, USBController *aThat);
     55    HRESULT init(Machine *aParent, USBDeviceFilters *aThat);
     56    HRESULT initCopy(Machine *aParent, USBDeviceFilters *aThat);
    5757    void uninit();
    5858
    59     // IUSBController properties
    60     STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
    61     STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
    62     STDMETHOD(COMGETTER(EnabledEHCI))(BOOL *aEnabled);
    63     STDMETHOD(COMSETTER(EnabledEHCI))(BOOL aEnabled);
    64     STDMETHOD(COMGETTER(ProxyAvailable))(BOOL *aEnabled);
    65     STDMETHOD(COMGETTER(USBStandard))(USHORT *aUSBStandard);
     59    // IUSBDeviceFilters attributes
    6660    STDMETHOD(COMGETTER(DeviceFilters))(ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters));
    6761
    68     // IUSBController methods
     62    // IUSBDeviceFilters methods
    6963    STDMETHOD(CreateDeviceFilter)(IN_BSTR aName, IUSBDeviceFilter **aFilter);
    7064    STDMETHOD(InsertDeviceFilter)(ULONG aPosition, IUSBDeviceFilter *aFilter);
     
    7872    void rollback();
    7973    void commit();
    80     void copyFrom(USBController *aThat);
     74    void copyFrom(USBDeviceFilters *aThat);
    8175
    8276#ifdef VBOX_WITH_USB
     
    10296};
    10397
    104 #endif //!____H_USBCONTROLLERIMPL
     98#endif //!____H_USBDEVICEFILTERSIMPL
    10599/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r46825 r47376  
    4141#include "MediumLock.h"
    4242#include "USBControllerImpl.h"
     43#include "USBDeviceFiltersImpl.h"
    4344#include "HostImpl.h"
    4445#include "SharedFolderImpl.h"
     
    4950#include "DisplayImpl.h"
    5051#include "DisplayUtils.h"
    51 #include "BandwidthControlImpl.h"
    5252#include "MachineImplCloneVM.h"
    5353#include "AutostartDb.h"
     
    27652765     * (w/o treating it as a failure), for example, as in OSE */
    27662766    NOREF(aUSBController);
     2767    ReturnComNotImplemented();
     2768#endif /* VBOX_WITH_VUSB */
     2769}
     2770
     2771STDMETHODIMP Machine::COMGETTER(USBDeviceFilters)(IUSBDeviceFilters **aUSBDeviceFilters)
     2772{
     2773#ifdef VBOX_WITH_VUSB
     2774    CheckComArgOutPointerValid(aUSBDeviceFilters);
     2775
     2776    AutoCaller autoCaller(this);
     2777    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     2778
     2779    clearError();
     2780    MultiResult rc(S_OK);
     2781
     2782# ifdef VBOX_WITH_USB
     2783    rc = mParent->host()->checkUSBProxyService();
     2784    if (FAILED(rc)) return rc;
     2785# endif
     2786
     2787    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     2788
     2789    return rc = mUSBDeviceFilters.queryInterfaceTo(aUSBDeviceFilters);
     2790#else
     2791    /* Note: The GUI depends on this method returning E_NOTIMPL with no
     2792     * extended error info to indicate that USB is simply not available
     2793     * (w/o treating it as a failure), for example, as in OSE */
     2794    NOREF(aUSBDeviceFilters);
    27672795    ReturnComNotImplemented();
    27682796#endif /* VBOX_WITH_VUSB */
     
    77067734    strFile.stripExt();                         // path/to/machinesfolder/vmname/vmname
    77077735    strFile.append(".webm");                    // path/to/machinesfolder/vmname/vmname.webm
     7736}
     7737
     7738/**
     7739 * Returns whether at least one USB controller is present for the VM.
     7740 */
     7741bool Machine::isUSBControllerPresent()
     7742{
     7743    AutoCaller autoCaller(this);
     7744    AssertComRCReturn(autoCaller.rc(), false);
     7745
     7746    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     7747
     7748    BOOL fEnabled = FALSE;
     7749    HRESULT rc = mUSBController->COMGETTER(Enabled)(&fEnabled);
     7750    if (SUCCEEDED(rc))
     7751        return !!fEnabled;
     7752    else
     7753        return false;
    77087754}
    77097755
     
    84728518    mUSBController->init(this);
    84738519
     8520    /* create the USB device filters object (always present) */
     8521    unconst(mUSBDeviceFilters).createObject();
     8522    mUSBDeviceFilters->init(this);
     8523
    84748524    /* create associated network adapter objects */
    84758525    mNetworkAdapters.resize(Global::getMaxNetworkAdapters(mHWData->mChipsetType));
     
    85238573        mUSBController->uninit();
    85248574        unconst(mUSBController).setNull();
     8575    }
     8576
     8577    if (mUSBDeviceFilters)
     8578    {
     8579        mUSBDeviceFilters->uninit();
     8580        unconst(mUSBDeviceFilters).setNull();
    85258581    }
    85268582
     
    91209176        /* USB Controller */
    91219177        rc = mUSBController->loadSettings(data.usbController);
     9178        if (FAILED(rc)) return rc;
     9179
     9180        /* USB device filters */
     9181        rc = mUSBDeviceFilters->loadSettings(data.usbController);
    91229182        if (FAILED(rc)) return rc;
    91239183
     
    1035910419        if (FAILED(rc)) throw rc;
    1036010420
     10421        /* USB device filters (required) */
     10422        rc = mUSBDeviceFilters->saveSettings(data.usbController);
     10423        if (FAILED(rc)) throw rc;
     10424
    1036110425        /* Network adapters (required) */
    1036210426        uint32_t uMaxNICs = RT_MIN(Global::getMaxNetworkAdapters(mHWData->mChipsetType), mNetworkAdapters.size());
     
    1176411828        mUSBController->rollback();
    1176511829
     11830    if (mUSBDeviceFilters && (mData->flModifications & IsModified_USB))
     11831        mUSBDeviceFilters->rollback();
     11832
    1176611833    if (mBandwidthControl && (mData->flModifications & IsModified_BandwidthControl))
    1176711834        mBandwidthControl->rollback();
     
    1186811935    mAudioAdapter->commit();
    1186911936    mUSBController->commit();
     11937    mUSBDeviceFilters->commit();
    1187011938    mBandwidthControl->commit();
    1187111939
     
    1204612114    mAudioAdapter->copyFrom(aThat->mAudioAdapter);
    1204712115    mUSBController->copyFrom(aThat->mUSBController);
     12116    mUSBDeviceFilters->copyFrom(aThat->mUSBDeviceFilters);
    1204812117    mBandwidthControl->copyFrom(aThat->mBandwidthControl);
    1204912118
     
    1247412543    mUSBController->init(this, aMachine->mUSBController);
    1247512544
     12545    /* create another USB device filters object that will be mutable */
     12546    unconst(mUSBDeviceFilters).createObject();
     12547    mUSBDeviceFilters->init(this, aMachine->mUSBDeviceFilters);
     12548
    1247612549    /* create a list of network adapters that will be mutable */
    1247712550    mNetworkAdapters.resize(aMachine->mNetworkAdapters.size());
     
    1257912652         * This is identical to SessionMachine::DetachAllUSBDevices except
    1258012653         * for the aAbnormal argument. */
    12581         HRESULT rc = mUSBController->notifyProxy(false /* aInsertFilters */);
     12654        HRESULT rc = mUSBDeviceFilters->notifyProxy(false /* aInsertFilters */);
    1258212655        AssertComRC(rc);
    1258312656        NOREF(rc);
     
    1304313116
    1304413117#ifdef VBOX_WITH_USB
    13045     *aMatched = mUSBController->hasMatchingFilter(aUSBDevice, aMaskedIfs);
     13118    *aMatched = mUSBDeviceFilters->hasMatchingFilter(aUSBDevice, aMaskedIfs);
    1304613119#else
    1304713120    NOREF(aUSBDevice);
     
    1311513188
    1311613189#ifdef VBOX_WITH_USB
    13117     HRESULT rc = mUSBController->notifyProxy(true /* aInsertFilters */);
     13190    HRESULT rc = mUSBDeviceFilters->notifyProxy(true /* aInsertFilters */);
    1311813191    AssertComRC(rc);
    1311913192    NOREF(rc);
     
    1314513218
    1314613219#ifdef VBOX_WITH_USB
    13147     HRESULT rc = mUSBController->notifyProxy(false /* aInsertFilters */);
     13220    HRESULT rc = mUSBDeviceFilters->notifyProxy(false /* aInsertFilters */);
    1314813221    AssertComRC(rc);
    1314913222    NOREF(rc);
     
    1412114194         *        elsewhere... */
    1412214195            alock.release();
    14123             return mUSBController->hasMatchingFilter(aDevice, aMaskedIfs);
     14196            return mUSBDeviceFilters->hasMatchingFilter(aDevice, aMaskedIfs);
    1412414197        default: break;
    1412514198    }
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r46720 r47376  
    3030#include "SharedFolderImpl.h"
    3131#include "USBControllerImpl.h"
     32#include "USBDeviceFiltersImpl.h"
    3233#include "VirtualBoxImpl.h"
    3334
     
    10791080    unconst(mUSBController).createObject();
    10801081    mUSBController->initCopy(this, pMachine->mUSBController);
     1082
     1083    unconst(mUSBDeviceFilters).createObject();
     1084    mUSBDeviceFilters->initCopy(this, pMachine->mUSBDeviceFilters);
    10811085
    10821086    mNetworkAdapters.resize(pMachine->mNetworkAdapters.size());
     
    11781182    unconst(mUSBController).createObject();
    11791183    mUSBController->init(this);
     1184
     1185    unconst(mUSBDeviceFilters).createObject();
     1186    mUSBDeviceFilters->init(this);
    11801187
    11811188    mNetworkAdapters.resize(Global::getMaxNetworkAdapters(mHWData->mChipsetType));
  • trunk/src/VBox/Main/src-server/USBControllerImpl.cpp

    r46820 r47376  
    2222#include "VirtualBoxImpl.h"
    2323#include "HostImpl.h"
    24 #ifdef VBOX_WITH_USB
    25 # include "USBDeviceImpl.h"
    26 # include "HostUSBDeviceImpl.h"
    27 # include "USBProxyService.h"
    28 # include "USBDeviceFilterImpl.h"
    29 #endif
    3024
    3125#include <iprt/string.h>
     
    4438// defines
    4539/////////////////////////////////////////////////////////////////////////////
    46 
    47 typedef std::list< ComObjPtr<USBDeviceFilter> > DeviceFilterList;
    4840
    4941struct BackupableUSBData
     
    6153{
    6254    Data(Machine *pMachine)
    63         : pParent(pMachine),
    64           pHost(pMachine->getVirtualBox()->host())
     55        : pParent(pMachine)
    6556    { }
    6657
     
    6960
    7061    Machine * const                 pParent;
    71     Host * const                    pHost;
    7262
    7363    // peer machine's USB controller
     
    7565
    7666    Backupable<BackupableUSBData>   bd;
    77 #ifdef VBOX_WITH_USB
    78     // the following fields need special backup/rollback/commit handling,
    79     // so they cannot be a part of BackupableData
    80     Backupable<DeviceFilterList>    llDeviceFilters;
    81 #endif
    8267};
    8368
     
    124109
    125110    m->bd.allocate();
    126 #ifdef VBOX_WITH_USB
    127     m->llDeviceFilters.allocate();
    128 #endif
    129111
    130112    /* Confirm a successful initialization */
     
    163145    m->bd.share(aPeer->m->bd);
    164146
    165 #ifdef VBOX_WITH_USB
    166     /* create copies of all filters */
    167     m->llDeviceFilters.allocate();
    168     DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin();
    169     while (it != aPeer->m->llDeviceFilters->end())
    170     {
    171         ComObjPtr<USBDeviceFilter> filter;
    172         filter.createObject();
    173         filter->init(this, *it);
    174         m->llDeviceFilters->push_back(filter);
    175         ++it;
    176     }
    177 #endif /* VBOX_WITH_USB */
    178 
    179147    /* Confirm a successful initialization */
    180148    autoInitSpan.setSucceeded();
     
    205173    AutoWriteLock thatlock(aPeer COMMA_LOCKVAL_SRC_POS);
    206174    m->bd.attachCopy(aPeer->m->bd);
    207 
    208 #ifdef VBOX_WITH_USB
    209     /* create private copies of all filters */
    210     m->llDeviceFilters.allocate();
    211     DeviceFilterList::const_iterator it = aPeer->m->llDeviceFilters->begin();
    212     while (it != aPeer->m->llDeviceFilters->end())
    213     {
    214         ComObjPtr<USBDeviceFilter> filter;
    215         filter.createObject();
    216         filter->initCopy(this, *it);
    217         m->llDeviceFilters->push_back(filter);
    218         ++it;
    219     }
    220 #endif /* VBOX_WITH_USB */
    221175
    222176    /* Confirm a successful initialization */
     
    240194        return;
    241195
    242 #ifdef VBOX_WITH_USB
    243     // uninit all device filters on the list (it's a standard std::list not an ObjectsList
    244     // so we must uninit() manually)
    245     for (DeviceFilterList::iterator it = m->llDeviceFilters->begin();
    246          it != m->llDeviceFilters->end();
    247          ++it)
    248         (*it)->uninit();
    249 
    250     m->llDeviceFilters.free();
    251 #endif
    252196    m->bd.free();
    253197
     
    385329
    386330    return S_OK;
    387 }
    388 
    389 #ifndef VBOX_WITH_USB
    390 /**
    391  * Fake class for build without USB.
    392  * We need an empty collection & enum for deviceFilters, that's all.
    393  */
    394 class ATL_NO_VTABLE USBDeviceFilter :
    395     public VirtualBoxBase,
    396     VBOX_SCRIPTABLE_IMPL(IUSBDeviceFilter)
    397 {
    398 public:
    399     DECLARE_NOT_AGGREGATABLE(USBDeviceFilter)
    400     DECLARE_PROTECT_FINAL_CONSTRUCT()
    401     BEGIN_COM_MAP(USBDeviceFilter)
    402         VBOX_DEFAULT_INTERFACE_ENTRIES(IUSBDeviceFilter)
    403     END_COM_MAP()
    404 
    405     DECLARE_EMPTY_CTOR_DTOR(USBDeviceFilter)
    406 
    407     // IUSBDeviceFilter properties
    408     STDMETHOD(COMGETTER(Name))(BSTR *aName);
    409     STDMETHOD(COMSETTER(Name))(IN_BSTR aName);
    410     STDMETHOD(COMGETTER(Active))(BOOL *aActive);
    411     STDMETHOD(COMSETTER(Active))(BOOL aActive);
    412     STDMETHOD(COMGETTER(VendorId))(BSTR *aVendorId);
    413     STDMETHOD(COMSETTER(VendorId))(IN_BSTR aVendorId);
    414     STDMETHOD(COMGETTER(ProductId))(BSTR *aProductId);
    415     STDMETHOD(COMSETTER(ProductId))(IN_BSTR aProductId);
    416     STDMETHOD(COMGETTER(Revision))(BSTR *aRevision);
    417     STDMETHOD(COMSETTER(Revision))(IN_BSTR aRevision);
    418     STDMETHOD(COMGETTER(Manufacturer))(BSTR *aManufacturer);
    419     STDMETHOD(COMSETTER(Manufacturer))(IN_BSTR aManufacturer);
    420     STDMETHOD(COMGETTER(Product))(BSTR *aProduct);
    421     STDMETHOD(COMSETTER(Product))(IN_BSTR aProduct);
    422     STDMETHOD(COMGETTER(SerialNumber))(BSTR *aSerialNumber);
    423     STDMETHOD(COMSETTER(SerialNumber))(IN_BSTR aSerialNumber);
    424     STDMETHOD(COMGETTER(Port))(BSTR *aPort);
    425     STDMETHOD(COMSETTER(Port))(IN_BSTR aPort);
    426     STDMETHOD(COMGETTER(Remote))(BSTR *aRemote);
    427     STDMETHOD(COMSETTER(Remote))(IN_BSTR aRemote);
    428     STDMETHOD(COMGETTER(MaskedInterfaces))(ULONG *aMaskedIfs);
    429     STDMETHOD(COMSETTER(MaskedInterfaces))(ULONG aMaskedIfs);
    430 };
    431 #endif /* !VBOX_WITH_USB */
    432 
    433 
    434 STDMETHODIMP USBController::COMGETTER(DeviceFilters)(ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters))
    435 {
    436 #ifdef VBOX_WITH_USB
    437     CheckComArgOutSafeArrayPointerValid(aDevicesFilters);
    438 
    439     AutoCaller autoCaller(this);
    440     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    441 
    442     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    443 
    444     SafeIfaceArray<IUSBDeviceFilter> collection(*m->llDeviceFilters.data());
    445     collection.detachTo(ComSafeArrayOutArg(aDevicesFilters));
    446 
    447     return S_OK;
    448 #else
    449     NOREF(aDevicesFilters);
    450 # ifndef RT_OS_WINDOWS
    451     NOREF(aDevicesFiltersSize);
    452 # endif
    453     ReturnComNotImplemented();
    454 #endif
    455 }
    456 
    457 // IUSBController methods
    458 /////////////////////////////////////////////////////////////////////////////
    459 
    460 STDMETHODIMP USBController::CreateDeviceFilter(IN_BSTR aName,
    461                                                IUSBDeviceFilter **aFilter)
    462 {
    463 #ifdef VBOX_WITH_USB
    464     CheckComArgOutPointerValid(aFilter);
    465 
    466     CheckComArgStrNotEmptyOrNull(aName);
    467 
    468     AutoCaller autoCaller(this);
    469     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    470 
    471     /* the machine needs to be mutable */
    472     AutoMutableStateDependency adep(m->pParent);
    473     if (FAILED(adep.rc())) return adep.rc();
    474 
    475     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    476 
    477     ComObjPtr<USBDeviceFilter> filter;
    478     filter.createObject();
    479     HRESULT rc = filter->init(this, aName);
    480     ComAssertComRCRetRC(rc);
    481     rc = filter.queryInterfaceTo(aFilter);
    482     AssertComRCReturnRC(rc);
    483 
    484     return S_OK;
    485 #else
    486     NOREF(aName);
    487     NOREF(aFilter);
    488     ReturnComNotImplemented();
    489 #endif
    490 }
    491 
    492 STDMETHODIMP USBController::InsertDeviceFilter(ULONG aPosition,
    493                                                IUSBDeviceFilter *aFilter)
    494 {
    495 #ifdef VBOX_WITH_USB
    496 
    497     CheckComArgNotNull(aFilter);
    498 
    499     AutoCaller autoCaller(this);
    500     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    501 
    502     /* the machine needs to be mutable */
    503     AutoMutableStateDependency adep(m->pParent);
    504     if (FAILED(adep.rc())) return adep.rc();
    505 
    506     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    507 
    508     ComObjPtr<USBDeviceFilter> filter = static_cast<USBDeviceFilter*>(aFilter);
    509     // @todo r=dj make sure the input object is actually from us
    510 //     if (!filter)
    511 //         return setError(E_INVALIDARG,
    512 //             tr("The given USB device filter is not created within "
    513 //                 "this VirtualBox instance"));
    514 
    515     if (filter->mInList)
    516         return setError(VBOX_E_INVALID_OBJECT_STATE,
    517                         tr("The given USB device filter is already in the list"));
    518 
    519     /* backup the list before modification */
    520     m->llDeviceFilters.backup();
    521 
    522     /* iterate to the position... */
    523     DeviceFilterList::iterator it;
    524     if (aPosition < m->llDeviceFilters->size())
    525     {
    526         it = m->llDeviceFilters->begin();
    527         std::advance(it, aPosition);
    528     }
    529     else
    530         it = m->llDeviceFilters->end();
    531     /* ...and insert */
    532     m->llDeviceFilters->insert(it, filter);
    533     filter->mInList = true;
    534 
    535     /* notify the proxy (only when it makes sense) */
    536     if (filter->getData().mActive && Global::IsOnline(adep.machineState())
    537         && filter->getData().mRemote.isMatch(false))
    538     {
    539         USBProxyService *service = m->pHost->usbProxyService();
    540         ComAssertRet(service, E_FAIL);
    541 
    542         ComAssertRet(filter->getId() == NULL, E_FAIL);
    543         filter->getId() = service->insertFilter(&filter->getData().mUSBFilter);
    544     }
    545 
    546     alock.release();
    547     AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
    548     m->pParent->setModified(Machine::IsModified_USB);
    549     mlock.release();
    550 
    551     return S_OK;
    552 
    553 #else /* VBOX_WITH_USB */
    554 
    555     NOREF(aPosition);
    556     NOREF(aFilter);
    557     ReturnComNotImplemented();
    558 
    559 #endif /* VBOX_WITH_USB */
    560 }
    561 
    562 STDMETHODIMP USBController::RemoveDeviceFilter(ULONG aPosition,
    563                                                IUSBDeviceFilter **aFilter)
    564 {
    565 #ifdef VBOX_WITH_USB
    566 
    567     CheckComArgOutPointerValid(aFilter);
    568 
    569     AutoCaller autoCaller(this);
    570     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    571 
    572     /* the machine needs to be mutable */
    573     AutoMutableStateDependency adep(m->pParent);
    574     if (FAILED(adep.rc())) return adep.rc();
    575 
    576     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    577 
    578     if (!m->llDeviceFilters->size())
    579         return setError(E_INVALIDARG,
    580                         tr("The USB device filter list is empty"));
    581 
    582     if (aPosition >= m->llDeviceFilters->size())
    583         return setError(E_INVALIDARG,
    584                         tr("Invalid position: %lu (must be in range [0, %lu])"),
    585                         aPosition, m->llDeviceFilters->size() - 1);
    586 
    587     /* backup the list before modification */
    588     m->llDeviceFilters.backup();
    589 
    590     ComObjPtr<USBDeviceFilter> filter;
    591     {
    592         /* iterate to the position... */
    593         DeviceFilterList::iterator it = m->llDeviceFilters->begin();
    594         std::advance(it, aPosition);
    595         /* ...get an element from there... */
    596         filter = *it;
    597         /* ...and remove */
    598         filter->mInList = false;
    599         m->llDeviceFilters->erase(it);
    600     }
    601 
    602     /* cancel sharing (make an independent copy of data) */
    603     filter->unshare();
    604 
    605     filter.queryInterfaceTo(aFilter);
    606 
    607     /* notify the proxy (only when it makes sense) */
    608     if (filter->getData().mActive && Global::IsOnline(adep.machineState())
    609         && filter->getData().mRemote.isMatch(false))
    610     {
    611         USBProxyService *service = m->pHost->usbProxyService();
    612         ComAssertRet(service, E_FAIL);
    613 
    614         ComAssertRet(filter->getId() != NULL, E_FAIL);
    615         service->removeFilter(filter->getId());
    616         filter->getId() = NULL;
    617     }
    618 
    619     alock.release();
    620     AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
    621     m->pParent->setModified(Machine::IsModified_USB);
    622     mlock.release();
    623 
    624     return S_OK;
    625 
    626 #else /* VBOX_WITH_USB */
    627 
    628     NOREF(aPosition);
    629     NOREF(aFilter);
    630     ReturnComNotImplemented();
    631 
    632 #endif /* VBOX_WITH_USB */
    633331}
    634332
     
    663361    m->bd->fEnabledEHCI = data.fEnabledEHCI;
    664362
    665 #ifdef VBOX_WITH_USB
    666     for (settings::USBDeviceFiltersList::const_iterator it = data.llDeviceFilters.begin();
    667          it != data.llDeviceFilters.end();
    668          ++it)
    669     {
    670         const settings::USBDeviceFilter &f = *it;
    671         ComObjPtr<USBDeviceFilter> pFilter;
    672         pFilter.createObject();
    673         HRESULT rc = pFilter->init(this,        // parent
    674                                    f);
    675         if (FAILED(rc)) return rc;
    676 
    677         m->llDeviceFilters->push_back(pFilter);
    678         pFilter->mInList = true;
    679     }
    680 #endif /* VBOX_WITH_USB */
    681 
    682363    return S_OK;
    683364}
     
    699380    data.fEnabled = !!m->bd->fEnabled;
    700381    data.fEnabledEHCI = !!m->bd->fEnabledEHCI;
    701 
    702 #ifdef VBOX_WITH_USB
    703     data.llDeviceFilters.clear();
    704 
    705     for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    706          it != m->llDeviceFilters->end();
    707          ++it)
    708     {
    709         AutoWriteLock filterLock(*it COMMA_LOCKVAL_SRC_POS);
    710         const USBDeviceFilter::Data &filterData = (*it)->getData();
    711 
    712         Bstr str;
    713 
    714         settings::USBDeviceFilter f;
    715         f.strName = filterData.mName;
    716         f.fActive = !!filterData.mActive;
    717         (*it)->COMGETTER(VendorId)(str.asOutParam());
    718         f.strVendorId = str;
    719         (*it)->COMGETTER(ProductId)(str.asOutParam());
    720         f.strProductId = str;
    721         (*it)->COMGETTER(Revision)(str.asOutParam());
    722         f.strRevision = str;
    723         (*it)->COMGETTER(Manufacturer)(str.asOutParam());
    724         f.strManufacturer = str;
    725         (*it)->COMGETTER(Product)(str.asOutParam());
    726         f.strProduct = str;
    727         (*it)->COMGETTER(SerialNumber)(str.asOutParam());
    728         f.strSerialNumber = str;
    729         (*it)->COMGETTER(Port)(str.asOutParam());
    730         f.strPort = str;
    731         f.strRemote = filterData.mRemote.string();
    732         f.ulMaskedInterfaces = filterData.mMaskedIfs;
    733 
    734         data.llDeviceFilters.push_back(f);
    735     }
    736 #endif /* VBOX_WITH_USB */
    737382
    738383    return S_OK;
     
    752397
    753398    m->bd.rollback();
    754 
    755 #ifdef VBOX_WITH_USB
    756 
    757     if (m->llDeviceFilters.isBackedUp())
    758     {
    759         USBProxyService *service = m->pHost->usbProxyService();
    760         Assert(service);
    761 
    762         /* uninitialize all new filters (absent in the backed up list) */
    763         DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    764         DeviceFilterList *backedList = m->llDeviceFilters.backedUpData();
    765         while (it != m->llDeviceFilters->end())
    766         {
    767             if (std::find(backedList->begin(), backedList->end(), *it) ==
    768                 backedList->end())
    769             {
    770                 /* notify the proxy (only when it makes sense) */
    771                 if ((*it)->getData().mActive &&
    772                     Global::IsOnline(adep.machineState())
    773                     && (*it)->getData().mRemote.isMatch(false))
    774                 {
    775                     USBDeviceFilter *filter = *it;
    776                     Assert(filter->getId() != NULL);
    777                     service->removeFilter(filter->getId());
    778                     filter->getId() = NULL;
    779                 }
    780 
    781                 (*it)->uninit();
    782             }
    783             ++it;
    784         }
    785 
    786         if (Global::IsOnline(adep.machineState()))
    787         {
    788             /* find all removed old filters (absent in the new list)
    789              * and insert them back to the USB proxy */
    790             it = backedList->begin();
    791             while (it != backedList->end())
    792             {
    793                 if (std::find(m->llDeviceFilters->begin(), m->llDeviceFilters->end(), *it) ==
    794                     m->llDeviceFilters->end())
    795                 {
    796                     /* notify the proxy (only when necessary) */
    797                     if ((*it)->getData().mActive
    798                             && (*it)->getData().mRemote.isMatch(false))
    799                     {
    800                         USBDeviceFilter *flt = *it; /* resolve ambiguity */
    801                         Assert(flt->getId() == NULL);
    802                         flt->getId() = service->insertFilter(&flt->getData().mUSBFilter);
    803                     }
    804                 }
    805                 ++it;
    806             }
    807         }
    808 
    809         /* restore the list */
    810         m->llDeviceFilters.rollback();
    811     }
    812 
    813     /* here we don't depend on the machine state any more */
    814     adep.release();
    815 
    816     /* rollback any changes to filters after restoring the list */
    817     DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    818     while (it != m->llDeviceFilters->end())
    819     {
    820         if ((*it)->isModified())
    821         {
    822             (*it)->rollback();
    823             /* call this to notify the USB proxy about changes */
    824             onDeviceFilterChange(*it);
    825         }
    826         ++it;
    827     }
    828 
    829 #endif /* VBOX_WITH_USB */
    830399}
    831400
     
    858427        }
    859428    }
    860 
    861 #ifdef VBOX_WITH_USB
    862     bool commitFilters = false;
    863 
    864     if (m->llDeviceFilters.isBackedUp())
    865     {
    866         m->llDeviceFilters.commit();
    867 
    868         /* apply changes to peer */
    869         if (m->pPeer)
    870         {
    871             AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
    872 
    873             /* commit all changes to new filters (this will reshare data with
    874              * peers for those who have peers) */
    875             DeviceFilterList *newList = new DeviceFilterList();
    876             DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    877             while (it != m->llDeviceFilters->end())
    878             {
    879                 (*it)->commit();
    880 
    881                 /* look if this filter has a peer filter */
    882                 ComObjPtr<USBDeviceFilter> peer = (*it)->peer();
    883                 if (!peer)
    884                 {
    885                     /* no peer means the filter is a newly created one;
    886                      * create a peer owning data this filter share it with */
    887                     peer.createObject();
    888                     peer->init(m->pPeer, *it, true /* aReshare */);
    889                 }
    890                 else
    891                 {
    892                     /* remove peer from the old list */
    893                     m->pPeer->m->llDeviceFilters->remove(peer);
    894                 }
    895                 /* and add it to the new list */
    896                 newList->push_back(peer);
    897 
    898                 ++it;
    899             }
    900 
    901             /* uninit old peer's filters that are left */
    902             it = m->pPeer->m->llDeviceFilters->begin();
    903             while (it != m->pPeer->m->llDeviceFilters->end())
    904             {
    905                 (*it)->uninit();
    906                 ++it;
    907             }
    908 
    909             /* attach new list of filters to our peer */
    910             m->pPeer->m->llDeviceFilters.attach(newList);
    911         }
    912         else
    913         {
    914             /* we have no peer (our parent is the newly created machine);
    915              * just commit changes to filters */
    916             commitFilters = true;
    917         }
    918     }
    919     else
    920     {
    921         /* the list of filters itself is not changed,
    922          * just commit changes to filters themselves */
    923         commitFilters = true;
    924     }
    925 
    926     if (commitFilters)
    927     {
    928         DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    929         while (it != m->llDeviceFilters->end())
    930         {
    931             (*it)->commit();
    932             ++it;
    933         }
    934     }
    935 #endif /* VBOX_WITH_USB */
    936429}
    937430
     
    965458    /* this will back up current data */
    966459    m->bd.assignCopy(aThat->m->bd);
    967 
    968 #ifdef VBOX_WITH_USB
    969 
    970     /* Note that we won't inform the USB proxy about new filters since the VM is
    971      * not running when we are here and therefore no need to do so */
    972 
    973     /* create private copies of all filters */
    974     m->llDeviceFilters.backup();
    975     m->llDeviceFilters->clear();
    976     for (DeviceFilterList::const_iterator it = aThat->m->llDeviceFilters->begin();
    977         it != aThat->m->llDeviceFilters->end();
    978         ++it)
    979     {
    980         ComObjPtr<USBDeviceFilter> filter;
    981         filter.createObject();
    982         filter->initCopy(this, *it);
    983         m->llDeviceFilters->push_back(filter);
    984     }
    985 
    986 #endif /* VBOX_WITH_USB */
    987 }
    988 
    989 #ifdef VBOX_WITH_USB
    990 
    991 /**
    992  *  Called by setter methods of all USB device filters.
    993  *
    994  *  @note Locks nothing.
    995  */
    996 HRESULT USBController::onDeviceFilterChange(USBDeviceFilter *aFilter,
    997                                             BOOL aActiveChanged /* = FALSE */)
    998 {
    999     AutoCaller autoCaller(this);
    1000     AssertComRCReturnRC(autoCaller.rc());
    1001 
    1002     /* we need the machine state */
    1003     AutoAnyStateDependency adep(m->pParent);
    1004     AssertComRCReturnRC(adep.rc());
    1005 
    1006     /* nothing to do if the machine isn't running */
    1007     if (!Global::IsOnline(adep.machineState()))
    1008         return S_OK;
    1009 
    1010     /* we don't modify our data fields -- no need to lock */
    1011 
    1012     if (    aFilter->mInList
    1013          && m->pParent->isRegistered())
    1014     {
    1015         USBProxyService *service = m->pHost->usbProxyService();
    1016         ComAssertRet(service, E_FAIL);
    1017 
    1018         if (aActiveChanged)
    1019         {
    1020             if (aFilter->getData().mRemote.isMatch(false))
    1021             {
    1022                 /* insert/remove the filter from the proxy */
    1023                 if (aFilter->getData().mActive)
    1024                 {
    1025                     ComAssertRet(aFilter->getId() == NULL, E_FAIL);
    1026                     aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
    1027                 }
    1028                 else
    1029                 {
    1030                     ComAssertRet(aFilter->getId() != NULL, E_FAIL);
    1031                     service->removeFilter(aFilter->getId());
    1032                     aFilter->getId() = NULL;
    1033                 }
    1034             }
    1035         }
    1036         else
    1037         {
    1038             if (aFilter->getData().mActive)
    1039             {
    1040                 /* update the filter in the proxy */
    1041                 ComAssertRet(aFilter->getId() != NULL, E_FAIL);
    1042                 service->removeFilter(aFilter->getId());
    1043                 if (aFilter->getData().mRemote.isMatch(false))
    1044                 {
    1045                     aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
    1046                 }
    1047             }
    1048         }
    1049     }
    1050 
    1051     return S_OK;
    1052 }
    1053 
    1054 /**
    1055  *  Returns true if the given USB device matches to at least one of
    1056  *  this controller's USB device filters.
    1057  *
    1058  *  A HostUSBDevice specific version.
    1059  *
    1060  *  @note Locks this object for reading.
    1061  */
    1062 bool USBController::hasMatchingFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs)
    1063 {
    1064     AutoCaller autoCaller(this);
    1065     AssertComRCReturn(autoCaller.rc(), false);
    1066 
    1067     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1068 
    1069     /* Disabled USB controllers cannot actually work with USB devices */
    1070     if (!m->bd->fEnabled)
    1071         return false;
    1072 
    1073     /* apply self filters */
    1074     for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    1075          it != m->llDeviceFilters->end();
    1076          ++it)
    1077     {
    1078         AutoWriteLock filterLock(*it COMMA_LOCKVAL_SRC_POS);
    1079         if (aDevice->isMatch((*it)->getData()))
    1080         {
    1081             *aMaskedIfs = (*it)->getData().mMaskedIfs;
    1082             return true;
    1083         }
    1084     }
    1085 
    1086     return false;
    1087 }
    1088 
    1089 /**
    1090  *  Returns true if the given USB device matches to at least one of
    1091  *  this controller's USB device filters.
    1092  *
    1093  *  A generic version that accepts any IUSBDevice on input.
    1094  *
    1095  *  @note
    1096  *      This method MUST correlate with HostUSBDevice::isMatch()
    1097  *      in the sense of the device matching logic.
    1098  *
    1099  *  @note Locks this object for reading.
    1100  */
    1101 bool USBController::hasMatchingFilter(IUSBDevice *aUSBDevice, ULONG *aMaskedIfs)
    1102 {
    1103     LogFlowThisFuncEnter();
    1104 
    1105     AutoCaller autoCaller(this);
    1106     AssertComRCReturn(autoCaller.rc(), false);
    1107 
    1108     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1109 
    1110     /* Disabled USB controllers cannot actually work with USB devices */
    1111     if (!m->bd->fEnabled)
    1112         return false;
    1113 
    1114     HRESULT rc = S_OK;
    1115 
    1116     /* query fields */
    1117     USBFILTER dev;
    1118     USBFilterInit(&dev, USBFILTERTYPE_CAPTURE);
    1119 
    1120     USHORT vendorId = 0;
    1121     rc = aUSBDevice->COMGETTER(VendorId)(&vendorId);
    1122     ComAssertComRCRet(rc, false);
    1123     ComAssertRet(vendorId, false);
    1124     int vrc = USBFilterSetNumExact(&dev, USBFILTERIDX_VENDOR_ID, vendorId, true); AssertRC(vrc);
    1125 
    1126     USHORT productId = 0;
    1127     rc = aUSBDevice->COMGETTER(ProductId)(&productId);
    1128     ComAssertComRCRet(rc, false);
    1129     vrc = USBFilterSetNumExact(&dev, USBFILTERIDX_PRODUCT_ID, productId, true); AssertRC(vrc);
    1130 
    1131     USHORT revision;
    1132     rc = aUSBDevice->COMGETTER(Revision)(&revision);
    1133     ComAssertComRCRet(rc, false);
    1134     vrc = USBFilterSetNumExact(&dev, USBFILTERIDX_DEVICE, revision, true); AssertRC(vrc);
    1135 
    1136     Bstr manufacturer;
    1137     rc = aUSBDevice->COMGETTER(Manufacturer)(manufacturer.asOutParam());
    1138     ComAssertComRCRet(rc, false);
    1139     if (!manufacturer.isEmpty())
    1140         USBFilterSetStringExact(&dev, USBFILTERIDX_MANUFACTURER_STR, Utf8Str(manufacturer).c_str(), true);
    1141 
    1142     Bstr product;
    1143     rc = aUSBDevice->COMGETTER(Product)(product.asOutParam());
    1144     ComAssertComRCRet(rc, false);
    1145     if (!product.isEmpty())
    1146         USBFilterSetStringExact(&dev, USBFILTERIDX_PRODUCT_STR, Utf8Str(product).c_str(), true);
    1147 
    1148     Bstr serialNumber;
    1149     rc = aUSBDevice->COMGETTER(SerialNumber)(serialNumber.asOutParam());
    1150     ComAssertComRCRet(rc, false);
    1151     if (!serialNumber.isEmpty())
    1152         USBFilterSetStringExact(&dev, USBFILTERIDX_SERIAL_NUMBER_STR, Utf8Str(serialNumber).c_str(), true);
    1153 
    1154     Bstr address;
    1155     rc = aUSBDevice->COMGETTER(Address)(address.asOutParam());
    1156     ComAssertComRCRet(rc, false);
    1157 
    1158     USHORT port = 0;
    1159     rc = aUSBDevice->COMGETTER(Port)(&port);
    1160     ComAssertComRCRet(rc, false);
    1161     USBFilterSetNumExact(&dev, USBFILTERIDX_PORT, port, true);
    1162 
    1163     BOOL remote = FALSE;
    1164     rc = aUSBDevice->COMGETTER(Remote)(&remote);
    1165     ComAssertComRCRet(rc, false);
    1166     ComAssertRet(remote == TRUE, false);
    1167 
    1168     bool match = false;
    1169 
    1170     /* apply self filters */
    1171     for (DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    1172          it != m->llDeviceFilters->end();
    1173          ++it)
    1174     {
    1175         AutoWriteLock filterLock(*it COMMA_LOCKVAL_SRC_POS);
    1176         const USBDeviceFilter::Data &aData = (*it)->getData();
    1177 
    1178         if (!aData.mActive)
    1179             continue;
    1180         if (!aData.mRemote.isMatch(remote))
    1181             continue;
    1182         if (!USBFilterMatch(&aData.mUSBFilter, &dev))
    1183             continue;
    1184 
    1185         match = true;
    1186         *aMaskedIfs = aData.mMaskedIfs;
    1187         break;
    1188     }
    1189 
    1190     LogFlowThisFunc(("returns: %d\n", match));
    1191     LogFlowThisFuncLeave();
    1192 
    1193     return match;
    1194 }
    1195 
    1196 /**
    1197  *  Notifies the proxy service about all filters as requested by the
    1198  *  @a aInsertFilters argument.
    1199  *
    1200  *  @param aInsertFilters   @c true to insert filters, @c false to remove.
    1201  *
    1202  *  @note Locks this object for reading.
    1203  */
    1204 HRESULT USBController::notifyProxy(bool aInsertFilters)
    1205 {
    1206     LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters));
    1207 
    1208     AutoCaller autoCaller(this);
    1209     AssertComRCReturn(autoCaller.rc(), false);
    1210 
    1211     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1212 
    1213     USBProxyService *service = m->pHost->usbProxyService();
    1214     AssertReturn(service, E_FAIL);
    1215 
    1216     DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    1217     while (it != m->llDeviceFilters->end())
    1218     {
    1219         USBDeviceFilter *flt = *it; /* resolve ambiguity (for ComPtr below) */
    1220 
    1221         /* notify the proxy (only if the filter is active) */
    1222         if (   flt->getData().mActive
    1223             && flt->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
    1224            )
    1225         {
    1226             if (aInsertFilters)
    1227             {
    1228                 AssertReturn(flt->getId() == NULL, E_FAIL);
    1229                 flt->getId() = service->insertFilter(&flt->getData().mUSBFilter);
    1230             }
    1231             else
    1232             {
    1233                 /* It's possible that the given filter was not inserted the proxy
    1234                  * when this method gets called (as a result of an early VM
    1235                  * process crash for example. So, don't assert that ID != NULL. */
    1236                 if (flt->getId() != NULL)
    1237                 {
    1238                     service->removeFilter(flt->getId());
    1239                     flt->getId() = NULL;
    1240                 }
    1241             }
    1242         }
    1243         ++it;
    1244     }
    1245 
    1246     return S_OK;
    1247 }
    1248 
    1249 Machine* USBController::getMachine()
    1250 {
    1251     return m->pParent;
    1252 }
    1253 
    1254 #endif /* VBOX_WITH_USB */
     460}
    1255461
    1256462// private methods
  • trunk/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp

    r44528 r47376  
    1717
    1818#include "USBDeviceFilterImpl.h"
    19 #include "USBControllerImpl.h"
     19#include "USBDeviceFiltersImpl.h"
    2020#include "MachineImpl.h"
    2121#include "HostImpl.h"
     
    204204 *  @param aParent  Handle of the parent object.
    205205 */
    206 HRESULT USBDeviceFilter::init(USBController *aParent,
     206HRESULT USBDeviceFilter::init(USBDeviceFilters *aParent,
    207207                              const settings::USBDeviceFilter &data)
    208208{
     
    278278 *  @param aParent  Handle of the parent object.
    279279 */
    280 HRESULT USBDeviceFilter::init(USBController *aParent, IN_BSTR aName)
     280HRESULT USBDeviceFilter::init(USBDeviceFilters *aParent, IN_BSTR aName)
    281281{
    282282    LogFlowThisFunc(("aParent=%p\n", aParent));
     
    327327 *  reading if @a aReshare is false.
    328328 */
    329 HRESULT USBDeviceFilter::init (USBController *aParent, USBDeviceFilter *aThat,
     329HRESULT USBDeviceFilter::init (USBDeviceFilters *aParent, USBDeviceFilter *aThat,
    330330                               bool aReshare /* = false */)
    331331{
     
    380380 *  @note Locks @a aThat object for reading.
    381381 */
    382 HRESULT USBDeviceFilter::initCopy (USBController *aParent, USBDeviceFilter *aThat)
     382HRESULT USBDeviceFilter::initCopy (USBDeviceFilters *aParent, USBDeviceFilter *aThat)
    383383{
    384384    LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
  • trunk/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp

    r47360 r47376  
    1616 */
    1717
    18 #include "USBControllerImpl.h"
     18#include "USBDeviceFiltersImpl.h"
    1919
    2020#include "Global.h"
     
    4747typedef std::list< ComObjPtr<USBDeviceFilter> > DeviceFilterList;
    4848
    49 struct BackupableUSBData
    50 {
    51     BackupableUSBData()
    52         : fEnabled(false),
    53           fEnabledEHCI(false)
    54     { }
    55 
    56     BOOL fEnabled;
    57     BOOL fEnabledEHCI;
    58 };
    59 
    60 struct USBController::Data
     49struct USBDeviceFilters::Data
    6150{
    6251    Data(Machine *pMachine)
     
    7160    Host * const                    pHost;
    7261
    73     // peer machine's USB controller
    74     const ComObjPtr<USBController>  pPeer;
    75 
    76     Backupable<BackupableUSBData>   bd;
    77 #ifdef VBOX_WITH_USB
    78     // the following fields need special backup/rollback/commit handling,
    79     // so they cannot be a part of BackupableData
     62    // peer machine's USB device filters list
     63    const ComObjPtr<USBDeviceFilters>  pPeer;
     64
     65#ifdef VBOX_WITH_USB
     66    // List of device filters.
    8067    Backupable<DeviceFilterList>    llDeviceFilters;
    8168#endif
     
    8774/////////////////////////////////////////////////////////////////////////////
    8875
    89 DEFINE_EMPTY_CTOR_DTOR(USBController)
    90 
    91 HRESULT USBController::FinalConstruct()
     76DEFINE_EMPTY_CTOR_DTOR(USBDeviceFilters)
     77
     78HRESULT USBDeviceFilters::FinalConstruct()
    9279{
    9380    return BaseFinalConstruct();
    9481}
    9582
    96 void USBController::FinalRelease()
     83void USBDeviceFilters::FinalRelease()
    9784{
    9885    uninit();
     
    10996 * @param aParent       Pointer to our parent object.
    11097 */
    111 HRESULT USBController::init(Machine *aParent)
     98HRESULT USBDeviceFilters::init(Machine *aParent)
    11299{
    113100    LogFlowThisFunc(("aParent=%p\n", aParent));
     
    122109
    123110    /* mPeer is left null */
    124 
    125     m->bd.allocate();
    126111#ifdef VBOX_WITH_USB
    127112    m->llDeviceFilters.allocate();
     
    135120
    136121/**
    137  * Initializes the USB controller object given another USB controller object
     122 * Initializes the USB devic filters object given another USB filters object
    138123 * (a kind of copy constructor). This object shares data with
    139124 * the object passed as an argument.
     
    146131 * it shares data with is destroyed.
    147132 */
    148 HRESULT USBController::init(Machine *aParent, USBController *aPeer)
     133HRESULT USBDeviceFilters::init(Machine *aParent, USBDeviceFilters *aPeer)
    149134{
    150135    LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer));
     
    161146
    162147    AutoWriteLock thatlock(aPeer COMMA_LOCKVAL_SRC_POS);
    163     m->bd.share(aPeer->m->bd);
    164148
    165149#ifdef VBOX_WITH_USB
     
    169153    while (it != aPeer->m->llDeviceFilters->end())
    170154    {
    171         ComObjPtr<USBDeviceFilter> filter;
    172         filter.createObject();
    173         filter->init(this, *it);
    174         m->llDeviceFilters->push_back(filter);
     155        ComObjPtr<USBDeviceFilter> pFilter;
     156        pFilter.createObject();
     157        pFilter->init(this, *it);
     158        m->llDeviceFilters->push_back(pFilter);
    175159        ++it;
    176160    }
     
    189173 *  of the original object passed as an argument.
    190174 */
    191 HRESULT USBController::initCopy(Machine *aParent, USBController *aPeer)
     175HRESULT USBDeviceFilters::initCopy(Machine *aParent, USBDeviceFilters *aPeer)
    192176{
    193177    LogFlowThisFunc(("aParent=%p, aPeer=%p\n", aParent, aPeer));
     
    204188
    205189    AutoWriteLock thatlock(aPeer COMMA_LOCKVAL_SRC_POS);
    206     m->bd.attachCopy(aPeer->m->bd);
    207190
    208191#ifdef VBOX_WITH_USB
     
    212195    while (it != aPeer->m->llDeviceFilters->end())
    213196    {
    214         ComObjPtr<USBDeviceFilter> filter;
    215         filter.createObject();
    216         filter->initCopy(this, *it);
    217         m->llDeviceFilters->push_back(filter);
     197        ComObjPtr<USBDeviceFilter> pFilter;
     198        pFilter.createObject();
     199        pFilter->initCopy(this, *it);
     200        m->llDeviceFilters->push_back(pFilter);
    218201        ++it;
    219202    }
     
    231214 * Called either from FinalRelease() or by the parent when it gets destroyed.
    232215 */
    233 void USBController::uninit()
     216void USBDeviceFilters::uninit()
    234217{
    235218    LogFlowThisFunc(("\n"));
     
    250233    m->llDeviceFilters.free();
    251234#endif
    252     m->bd.free();
    253235
    254236    unconst(m->pPeer) = NULL;
     
    260242
    261243
    262 // IUSBController properties
     244// IUSBDeviceFilters properties
    263245/////////////////////////////////////////////////////////////////////////////
    264 
    265 STDMETHODIMP USBController::COMGETTER(Enabled)(BOOL *aEnabled)
    266 {
    267     CheckComArgOutPointerValid(aEnabled);
    268 
    269     AutoCaller autoCaller(this);
    270     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    271 
    272     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    273 
    274     *aEnabled = m->bd->fEnabled;
    275 
    276     return S_OK;
    277 }
    278 
    279 
    280 STDMETHODIMP USBController::COMSETTER(Enabled)(BOOL aEnabled)
    281 {
    282     LogFlowThisFunc(("aEnabled=%RTbool\n", aEnabled));
    283 
    284     AutoCaller autoCaller(this);
    285     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    286 
    287     /* the machine needs to be mutable */
    288     AutoMutableStateDependency adep(m->pParent);
    289     if (FAILED(adep.rc())) return adep.rc();
    290 
    291     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    292 
    293     if (m->bd->fEnabled != aEnabled)
    294     {
    295         m->bd.backup();
    296         m->bd->fEnabled = aEnabled;
    297 
    298         // leave the lock for safety
    299         alock.release();
    300 
    301         AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
    302         m->pParent->setModified(Machine::IsModified_USB);
    303         mlock.release();
    304 
    305         m->pParent->onUSBControllerChange();
    306     }
    307 
    308     return S_OK;
    309 }
    310 
    311 STDMETHODIMP USBController::COMGETTER(EnabledEHCI)(BOOL *aEnabled)
    312 {
    313     CheckComArgOutPointerValid(aEnabled);
    314 
    315     AutoCaller autoCaller(this);
    316     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    317 
    318     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    319 
    320     *aEnabled = m->bd->fEnabledEHCI;
    321 
    322     return S_OK;
    323 }
    324 
    325 STDMETHODIMP USBController::COMSETTER(EnabledEHCI)(BOOL aEnabled)
    326 {
    327     LogFlowThisFunc(("aEnabled=%RTbool\n", aEnabled));
    328 
    329     AutoCaller autoCaller(this);
    330     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    331 
    332     /* the machine needs to be mutable */
    333     AutoMutableStateDependency adep(m->pParent);
    334     if (FAILED(adep.rc())) return adep.rc();
    335 
    336     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    337 
    338     if (m->bd->fEnabledEHCI != aEnabled)
    339     {
    340         m->bd.backup();
    341         m->bd->fEnabledEHCI = aEnabled;
    342 
    343         // leave the lock for safety
    344         alock.release();
    345 
    346         AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
    347         m->pParent->setModified(Machine::IsModified_USB);
    348         mlock.release();
    349 
    350         m->pParent->onUSBControllerChange();
    351     }
    352 
    353     return S_OK;
    354 }
    355 
    356 STDMETHODIMP USBController::COMGETTER(ProxyAvailable)(BOOL *aEnabled)
    357 {
    358     CheckComArgOutPointerValid(aEnabled);
    359 
    360     AutoCaller autoCaller(this);
    361     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    362 
    363     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    364 
    365 #ifdef VBOX_WITH_USB
    366     *aEnabled = true;
    367 #else
    368     *aEnabled = false;
    369 #endif
    370 
    371     return S_OK;
    372 }
    373 
    374 STDMETHODIMP USBController::COMGETTER(USBStandard)(USHORT *aUSBStandard)
    375 {
    376     CheckComArgOutPointerValid(aUSBStandard);
    377 
    378     AutoCaller autoCaller(this);
    379     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    380 
    381     /* not accessing data -- no need to lock */
    382 
    383     /** @todo This is no longer correct */
    384     *aUSBStandard = 0x0101;
    385 
    386     return S_OK;
    387 }
    388246
    389247#ifndef VBOX_WITH_USB
     
    432290
    433291
    434 STDMETHODIMP USBController::COMGETTER(DeviceFilters)(ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters))
     292STDMETHODIMP USBDeviceFilters::COMGETTER(DeviceFilters)(ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters))
    435293{
    436294#ifdef VBOX_WITH_USB
     
    455313}
    456314
    457 // IUSBController methods
     315// IUSBDeviceFilters methods
    458316/////////////////////////////////////////////////////////////////////////////
    459317
    460 STDMETHODIMP USBController::CreateDeviceFilter(IN_BSTR aName,
    461                                                IUSBDeviceFilter **aFilter)
     318STDMETHODIMP USBDeviceFilters::CreateDeviceFilter(IN_BSTR aName,
     319                                                  IUSBDeviceFilter **aFilter)
    462320{
    463321#ifdef VBOX_WITH_USB
     
    475333    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    476334
    477     ComObjPtr<USBDeviceFilter> filter;
    478     filter.createObject();
    479     HRESULT rc = filter->init(this, aName);
     335    ComObjPtr<USBDeviceFilter> pFilter;
     336    pFilter.createObject();
     337    HRESULT rc = pFilter->init(this, aName);
    480338    ComAssertComRCRetRC(rc);
    481     rc = filter.queryInterfaceTo(aFilter);
     339    rc = pFilter.queryInterfaceTo(aFilter);
    482340    AssertComRCReturnRC(rc);
    483341
     
    490348}
    491349
    492 STDMETHODIMP USBController::InsertDeviceFilter(ULONG aPosition,
    493                                                IUSBDeviceFilter *aFilter)
     350STDMETHODIMP USBDeviceFilters::InsertDeviceFilter(ULONG aPosition,
     351                                                  IUSBDeviceFilter *aFilter)
    494352{
    495353#ifdef VBOX_WITH_USB
     
    506364    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    507365
    508     ComObjPtr<USBDeviceFilter> filter = static_cast<USBDeviceFilter*>(aFilter);
    509     // @todo r=dj make sure the input object is actually from us
    510 //     if (!filter)
    511 //         return setError(E_INVALIDARG,
    512 //             tr("The given USB device filter is not created within "
    513 //                 "this VirtualBox instance"));
    514 
    515     if (filter->mInList)
     366    ComObjPtr<USBDeviceFilter> pFilter = static_cast<USBDeviceFilter*>(aFilter);
     367
     368    if (pFilter->mInList)
    516369        return setError(VBOX_E_INVALID_OBJECT_STATE,
    517                         tr("The given USB device filter is already in the list"));
     370                        tr("The given USB device pFilter is already in the list"));
    518371
    519372    /* backup the list before modification */
     
    530383        it = m->llDeviceFilters->end();
    531384    /* ...and insert */
    532     m->llDeviceFilters->insert(it, filter);
    533     filter->mInList = true;
     385    m->llDeviceFilters->insert(it, pFilter);
     386    pFilter->mInList = true;
    534387
    535388    /* notify the proxy (only when it makes sense) */
    536     if (filter->getData().mActive && Global::IsOnline(adep.machineState())
    537         && filter->getData().mRemote.isMatch(false))
    538     {
    539         USBProxyService *service = m->pHost->usbProxyService();
    540         ComAssertRet(service, E_FAIL);
    541 
    542         ComAssertRet(filter->getId() == NULL, E_FAIL);
    543         filter->getId() = service->insertFilter(&filter->getData().mUSBFilter);
     389    if (pFilter->getData().mActive && Global::IsOnline(adep.machineState())
     390        && pFilter->getData().mRemote.isMatch(false))
     391    {
     392        USBProxyService *pProxySvc = m->pHost->usbProxyService();
     393        ComAssertRet(pProxySvc, E_FAIL);
     394
     395        ComAssertRet(pFilter->getId() == NULL, E_FAIL);
     396        pFilter->getId() = pProxySvc->insertFilter(&pFilter->getData().mUSBFilter);
    544397    }
    545398
     
    560413}
    561414
    562 STDMETHODIMP USBController::RemoveDeviceFilter(ULONG aPosition,
    563                                                IUSBDeviceFilter **aFilter)
     415STDMETHODIMP USBDeviceFilters::RemoveDeviceFilter(ULONG aPosition,
     416                                                  IUSBDeviceFilter **aFilter)
    564417{
    565418#ifdef VBOX_WITH_USB
     
    578431    if (!m->llDeviceFilters->size())
    579432        return setError(E_INVALIDARG,
    580                         tr("The USB device filter list is empty"));
     433                        tr("The USB device pFilter list is empty"));
    581434
    582435    if (aPosition >= m->llDeviceFilters->size())
     
    588441    m->llDeviceFilters.backup();
    589442
    590     ComObjPtr<USBDeviceFilter> filter;
     443    ComObjPtr<USBDeviceFilter> pFilter;
    591444    {
    592445        /* iterate to the position... */
     
    594447        std::advance(it, aPosition);
    595448        /* ...get an element from there... */
    596         filter = *it;
     449        pFilter = *it;
    597450        /* ...and remove */
    598         filter->mInList = false;
     451        pFilter->mInList = false;
    599452        m->llDeviceFilters->erase(it);
    600453    }
    601454
    602455    /* cancel sharing (make an independent copy of data) */
    603     filter->unshare();
    604 
    605     filter.queryInterfaceTo(aFilter);
     456    pFilter->unshare();
     457
     458    pFilter.queryInterfaceTo(aFilter);
    606459
    607460    /* notify the proxy (only when it makes sense) */
    608     if (filter->getData().mActive && Global::IsOnline(adep.machineState())
    609         && filter->getData().mRemote.isMatch(false))
    610     {
    611         USBProxyService *service = m->pHost->usbProxyService();
    612         ComAssertRet(service, E_FAIL);
    613 
    614         ComAssertRet(filter->getId() != NULL, E_FAIL);
    615         service->removeFilter(filter->getId());
    616         filter->getId() = NULL;
     461    if (pFilter->getData().mActive && Global::IsOnline(adep.machineState())
     462        && pFilter->getData().mRemote.isMatch(false))
     463    {
     464        USBProxyService *pProxySvc = m->pHost->usbProxyService();
     465        ComAssertRet(pProxySvc, E_FAIL);
     466
     467        ComAssertRet(pFilter->getId() != NULL, E_FAIL);
     468        pProxySvc->removeFilter(pFilter->getId());
     469        pFilter->getId() = NULL;
    617470    }
    618471
     
    644497 *  @note Does not lock "this" as Machine::loadHardware, which calls this, does not lock either.
    645498 */
    646 HRESULT USBController::loadSettings(const settings::USBController &data)
     499HRESULT USBDeviceFilters::loadSettings(const settings::USBController &data)
    647500{
    648501    AutoCaller autoCaller(this);
     
    652505     * nodes are assigned in the Data::Data() constructor and don't do it
    653506     * here. It implies that this method may only be called after constructing
    654      * a new BIOSSettings object while all its data fields are in the default
     507     * a new USBDeviceFilters object while all its data fields are in the default
    655508     * values. Exceptions are fields whose creation time defaults don't match
    656509     * values that should be applied when these fields are not explicitly set
     
    660513     * default to B. */
    661514
    662     m->bd->fEnabled = data.fEnabled;
    663     m->bd->fEnabledEHCI = data.fEnabledEHCI;
    664 
    665515#ifdef VBOX_WITH_USB
    666516    for (settings::USBDeviceFiltersList::const_iterator it = data.llDeviceFilters.begin();
     
    690540 *  @note Locks this object for reading.
    691541 */
    692 HRESULT USBController::saveSettings(settings::USBController &data)
     542HRESULT USBDeviceFilters::saveSettings(settings::USBController &data)
    693543{
    694544    AutoCaller autoCaller(this);
     
    696546
    697547    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    698 
    699     data.fEnabled = !!m->bd->fEnabled;
    700     data.fEnabledEHCI = !!m->bd->fEnabledEHCI;
    701548
    702549#ifdef VBOX_WITH_USB
     
    740587
    741588/** @note Locks objects for writing! */
    742 void USBController::rollback()
     589void USBDeviceFilters::rollback()
    743590{
    744591    AutoCaller autoCaller(this);
     
    751598    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    752599
    753     m->bd.rollback();
    754 
    755600#ifdef VBOX_WITH_USB
    756601
    757602    if (m->llDeviceFilters.isBackedUp())
    758603    {
    759         USBProxyService *service = m->pHost->usbProxyService();
    760         Assert(service);
     604        USBProxyService *pProxySvc = m->pHost->usbProxyService();
     605        Assert(pProxySvc);
    761606
    762607        /* uninitialize all new filters (absent in the backed up list) */
     
    773618                    && (*it)->getData().mRemote.isMatch(false))
    774619                {
    775                     USBDeviceFilter *filter = *it;
    776                     Assert(filter->getId() != NULL);
    777                     service->removeFilter(filter->getId());
    778                     filter->getId() = NULL;
     620                    USBDeviceFilter *pFilter = *it;
     621                    Assert(pFilter->getId() != NULL);
     622                    pProxySvc->removeFilter(pFilter->getId());
     623                    pFilter->getId() = NULL;
    779624                }
    780625
     
    798643                            && (*it)->getData().mRemote.isMatch(false))
    799644                    {
    800                         USBDeviceFilter *flt = *it; /* resolve ambiguity */
    801                         Assert(flt->getId() == NULL);
    802                         flt->getId() = service->insertFilter(&flt->getData().mUSBFilter);
     645                        USBDeviceFilter *pFilter = *it; /* resolve ambiguity */
     646                        Assert(pFilter->getId() == NULL);
     647                        pFilter->getId() = pProxySvc->insertFilter(&pFilter->getData().mUSBFilter);
    803648                    }
    804649                }
     
    834679 *  for writing) if there is one.
    835680 */
    836 void USBController::commit()
     681void USBDeviceFilters::commit()
    837682{
    838683    /* sanity */
     
    847692     * first) */
    848693    AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
    849 
    850     if (m->bd.isBackedUp())
    851     {
    852         m->bd.commit();
    853         if (m->pPeer)
    854         {
    855             /* attach new data to the peer and reshare it */
    856             AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
    857             m->pPeer->m->bd.attach(m->bd);
    858         }
    859     }
    860694
    861695#ifdef VBOX_WITH_USB
     
    940774 *  represented by @a aThat (locked for reading).
    941775 */
    942 void USBController::copyFrom(USBController *aThat)
     776void USBDeviceFilters::copyFrom(USBDeviceFilters *aThat)
    943777{
    944778    AssertReturnVoid(aThat != NULL);
     
    962796    AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
    963797    AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
    964 
    965     /* this will back up current data */
    966     m->bd.assignCopy(aThat->m->bd);
    967798
    968799#ifdef VBOX_WITH_USB
     
    978809        ++it)
    979810    {
    980         ComObjPtr<USBDeviceFilter> filter;
    981         filter.createObject();
    982         filter->initCopy(this, *it);
    983         m->llDeviceFilters->push_back(filter);
     811        ComObjPtr<USBDeviceFilter> pFilter;
     812        pFilter.createObject();
     813        pFilter->initCopy(this, *it);
     814        m->llDeviceFilters->push_back(pFilter);
    984815    }
    985816
     
    994825 *  @note Locks nothing.
    995826 */
    996 HRESULT USBController::onDeviceFilterChange(USBDeviceFilter *aFilter,
    997                                             BOOL aActiveChanged /* = FALSE */)
     827HRESULT USBDeviceFilters::onDeviceFilterChange(USBDeviceFilter *aFilter,
     828                                               BOOL aActiveChanged /* = FALSE */)
    998829{
    999830    AutoCaller autoCaller(this);
     
    1013844         && m->pParent->isRegistered())
    1014845    {
    1015         USBProxyService *service = m->pHost->usbProxyService();
    1016         ComAssertRet(service, E_FAIL);
     846        USBProxyService *pProxySvc = m->pHost->usbProxyService();
     847        ComAssertRet(pProxySvc, E_FAIL);
    1017848
    1018849        if (aActiveChanged)
     
    1024855                {
    1025856                    ComAssertRet(aFilter->getId() == NULL, E_FAIL);
    1026                     aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
     857                    aFilter->getId() = pProxySvc->insertFilter(&aFilter->getData().mUSBFilter);
    1027858                }
    1028859                else
    1029860                {
    1030861                    ComAssertRet(aFilter->getId() != NULL, E_FAIL);
    1031                     service->removeFilter(aFilter->getId());
     862                    pProxySvc->removeFilter(aFilter->getId());
    1032863                    aFilter->getId() = NULL;
    1033864                }
     
    1040871                /* update the filter in the proxy */
    1041872                ComAssertRet(aFilter->getId() != NULL, E_FAIL);
    1042                 service->removeFilter(aFilter->getId());
     873                pProxySvc->removeFilter(aFilter->getId());
    1043874                if (aFilter->getData().mRemote.isMatch(false))
    1044875                {
    1045                     aFilter->getId() = service->insertFilter(&aFilter->getData().mUSBFilter);
     876                    aFilter->getId() = pProxySvc->insertFilter(&aFilter->getData().mUSBFilter);
    1046877                }
    1047878            }
     
    1060891 *  @note Locks this object for reading.
    1061892 */
    1062 bool USBController::hasMatchingFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs)
     893bool USBDeviceFilters::hasMatchingFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs)
    1063894{
    1064895    AutoCaller autoCaller(this);
     
    1067898    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1068899
    1069     /* Disabled USB controllers cannot actually work with USB devices */
    1070     if (!m->bd->fEnabled)
     900    /* It is not possible to work with USB device if there is no USB controller present. */
     901    if (!m->pParent->isUSBControllerPresent())
    1071902        return false;
    1072903
     
    1099930 *  @note Locks this object for reading.
    1100931 */
    1101 bool USBController::hasMatchingFilter(IUSBDevice *aUSBDevice, ULONG *aMaskedIfs)
     932bool USBDeviceFilters::hasMatchingFilter(IUSBDevice *aUSBDevice, ULONG *aMaskedIfs)
    1102933{
    1103934    LogFlowThisFuncEnter();
     
    1108939    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1109940
    1110     /* Disabled USB controllers cannot actually work with USB devices */
    1111     if (!m->bd->fEnabled)
     941    /* It is not possible to work with USB device if there is no USB controller present. */
     942    if (!m->pParent->isUSBControllerPresent())
    1112943        return false;
    1113944
     
    11951026
    11961027/**
    1197  *  Notifies the proxy service about all filters as requested by the
     1028 *  Notifies the proxy pProxySvc about all filters as requested by the
    11981029 *  @a aInsertFilters argument.
    11991030 *
     
    12021033 *  @note Locks this object for reading.
    12031034 */
    1204 HRESULT USBController::notifyProxy(bool aInsertFilters)
     1035HRESULT USBDeviceFilters::notifyProxy(bool aInsertFilters)
    12051036{
    12061037    LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters));
     
    12111042    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    12121043
    1213     USBProxyService *service = m->pHost->usbProxyService();
    1214     AssertReturn(service, E_FAIL);
     1044    USBProxyService *pProxySvc = m->pHost->usbProxyService();
     1045    AssertReturn(pProxySvc, E_FAIL);
    12151046
    12161047    DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
    12171048    while (it != m->llDeviceFilters->end())
    12181049    {
    1219         USBDeviceFilter *flt = *it; /* resolve ambiguity (for ComPtr below) */
     1050        USBDeviceFilter *pFilter = *it; /* resolve ambiguity (for ComPtr below) */
    12201051
    12211052        /* notify the proxy (only if the filter is active) */
    1222         if (   flt->getData().mActive
    1223             && flt->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
     1053        if (   pFilter->getData().mActive
     1054            && pFilter->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
    12241055           )
    12251056        {
    12261057            if (aInsertFilters)
    12271058            {
    1228                 AssertReturn(flt->getId() == NULL, E_FAIL);
    1229                 flt->getId() = service->insertFilter(&flt->getData().mUSBFilter);
     1059                AssertReturn(pFilter->getId() == NULL, E_FAIL);
     1060                pFilter->getId() = pProxySvc->insertFilter(&pFilter->getData().mUSBFilter);
    12301061            }
    12311062            else
     
    12341065                 * when this method gets called (as a result of an early VM
    12351066                 * process crash for example. So, don't assert that ID != NULL. */
    1236                 if (flt->getId() != NULL)
     1067                if (pFilter->getId() != NULL)
    12371068                {
    1238                     service->removeFilter(flt->getId());
    1239                     flt->getId() = NULL;
     1069                    pProxySvc->removeFilter(pFilter->getId());
     1070                    pFilter->getId() = NULL;
    12401071                }
    12411072            }
     
    12471078}
    12481079
    1249 Machine* USBController::getMachine()
     1080Machine* USBDeviceFilters::getMachine()
    12501081{
    12511082    return m->pParent;
  • trunk/src/VBox/Main/src-server/xpcom/server.cpp

    r47018 r47376  
    8585#include "SystemPropertiesImpl.h"
    8686#include "USBControllerImpl.h"
     87#include "USBDeviceFiltersImpl.h"
    8788#include "VFSExplorerImpl.h"
    8889#include "VirtualBoxImpl.h"
     
    173174NS_DECL_CLASSINFO(USBController)
    174175NS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBController, IUSBController)
     176
     177NS_DECL_CLASSINFO(USBDeviceFilters)
     178NS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBDeviceFilters, IUSBDeviceFilters)
    175179
    176180NS_DECL_CLASSINFO(StorageController)
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