VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBControllerImpl.h@ 5713

Last change on this file since 5713 was 5713, checked in by vboxsync, 17 years ago

Added an maskedInterface property to the USB filters. It is used to hide a set of interface from the guest, which means that on Linux we won't capture those and linux can continue using them.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/** @file
2 *
3 * VBox USBController COM Class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_USBCONTROLLERIMPL
19#define ____H_USBCONTROLLERIMPL
20
21#include "VirtualBoxBase.h"
22#include "USBDeviceFilterImpl.h"
23
24#include <VBox/cfgldr.h>
25
26#include <list>
27
28class Machine;
29class HostUSBDevice;
30
31/**
32 * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
33 * base class, because we want a quick (map-based) way of validating
34 * IUSBDeviceFilter pointers passed from outside as method parameters that
35 * VirtualBoxBaseWithChildren::getDependentChild() gives us.
36 */
37
38class ATL_NO_VTABLE USBController :
39 public VirtualBoxBaseWithChildrenNEXT,
40 public VirtualBoxSupportErrorInfoImpl <USBController, IUSBController>,
41 public VirtualBoxSupportTranslation <USBController>,
42 public IUSBController
43{
44private:
45
46 struct Data
47 {
48 /* Constructor. */
49 Data() : mEnabled (FALSE), mEnabledEhci (FALSE) { }
50
51 bool operator== (const Data &that) const
52 {
53 return this == &that || (mEnabled == that.mEnabled && mEnabledEhci == that.mEnabledEhci);
54 }
55
56 /** Enabled indicator. */
57 BOOL mEnabled;
58
59 /** Enabled indicator for EHCI. */
60 BOOL mEnabledEhci;
61 };
62
63public:
64
65 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
66
67 DECLARE_NOT_AGGREGATABLE (USBController)
68
69 DECLARE_PROTECT_FINAL_CONSTRUCT()
70
71 BEGIN_COM_MAP(USBController)
72 COM_INTERFACE_ENTRY (ISupportErrorInfo)
73 COM_INTERFACE_ENTRY (IUSBController)
74 END_COM_MAP()
75
76 NS_DECL_ISUPPORTS
77
78 DECLARE_EMPTY_CTOR_DTOR (USBController)
79
80 HRESULT FinalConstruct();
81 void FinalRelease();
82
83 // public initializer/uninitializer for internal purposes only
84 HRESULT init (Machine *aParent);
85 HRESULT init (Machine *aParent, USBController *aThat);
86 HRESULT initCopy (Machine *aParent, USBController *aThat);
87 void uninit();
88
89 // IUSBController properties
90 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
91 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
92 STDMETHOD(COMGETTER(EnabledEhci)) (BOOL *aEnabled);
93 STDMETHOD(COMSETTER(EnabledEhci)) (BOOL aEnabled);
94 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
95 STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
96
97 // IUSBController methods
98 STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
99 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
100 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
101
102 // public methods only for internal purposes
103
104 HRESULT loadSettings (CFGNODE aMachine);
105 HRESULT saveSettings (CFGNODE aMachine);
106
107 bool isModified();
108 bool isReallyModified();
109 bool rollback();
110 void commit();
111 void copyFrom (USBController *aThat);
112
113 HRESULT onMachineRegistered (BOOL aRegistered);
114
115 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
116 BOOL aActiveChanged = FALSE);
117
118 bool hasMatchingFilter (const ComObjPtr <HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
119 bool hasMatchingFilter (IUSBDevice *aUSBDevice, ULONG *aMaskedIfs);
120
121 HRESULT notifyProxy (bool aInsertFilters);
122
123 // public methods for internal purposes only
124 // (ensure there is a caller and a read lock before calling them!)
125
126 /** @note this doesn't require a read lock since mParent is constant. */
127 const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
128
129 const Backupable<Data> &data() { return mData; }
130
131 // for VirtualBoxSupportErrorInfoImpl
132 static const wchar_t *getComponentName() { return L"USBController"; }
133
134private:
135
136 /** specialization for IUSBDeviceFilter */
137 ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
138 {
139 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
140 getDependentChild (ComPtr <IUnknown> (aFilter));
141 return child ? static_cast <USBDeviceFilter *> (child)
142 : NULL;
143 }
144
145 void printList();
146
147 /** Parent object. */
148 const ComObjPtr<Machine, ComWeakRef> mParent;
149 /** Peer object. */
150 const ComObjPtr <USBController> mPeer;
151 /** Data. */
152 Backupable <Data> mData;
153
154 // the following fields need special backup/rollback/commit handling,
155 // so they cannot be a part of Data
156
157 typedef std::list <ComObjPtr <USBDeviceFilter> > DeviceFilterList;
158 Backupable <DeviceFilterList> mDeviceFilters;
159};
160
161#endif //!____H_USBCONTROLLERIMPL
Note: See TracBrowser for help on using the repository browser.

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