1 | /* $Id: USBDeviceFilterImpl.h 61667 2016-06-10 18:22:09Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Declaration of USBDeviceFilter and HostUSBDeviceFilter.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_USBDEVICEFILTERIMPL
|
---|
19 | #define ____H_USBDEVICEFILTERIMPL
|
---|
20 |
|
---|
21 | #include <VBox/settings.h>
|
---|
22 | #include "Matching.h"
|
---|
23 | #include <VBox/usbfilter.h>
|
---|
24 | #include "USBDeviceFilterWrap.h"
|
---|
25 |
|
---|
26 | class USBDeviceFilters;
|
---|
27 | class Host;
|
---|
28 | namespace settings
|
---|
29 | {
|
---|
30 | struct USBDeviceFilter;
|
---|
31 | }
|
---|
32 |
|
---|
33 | // USBDeviceFilter
|
---|
34 | ////////////////////////////////////////////////////////////////////////////////
|
---|
35 |
|
---|
36 | class ATL_NO_VTABLE USBDeviceFilter :
|
---|
37 | public USBDeviceFilterWrap
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | struct BackupableUSBDeviceFilterData
|
---|
42 | {
|
---|
43 | typedef matching::Matchable <matching::ParsedBoolFilter> BOOLFilter;
|
---|
44 |
|
---|
45 | BackupableUSBDeviceFilterData() : mId (NULL) {}
|
---|
46 | BackupableUSBDeviceFilterData(const BackupableUSBDeviceFilterData &aThat) :
|
---|
47 | mRemote(aThat.mRemote), mId(aThat.mId)
|
---|
48 | {
|
---|
49 | mData.strName = aThat.mData.strName;
|
---|
50 | mData.fActive = aThat.mData.fActive;
|
---|
51 | mData.ulMaskedInterfaces = aThat.mData.ulMaskedInterfaces;
|
---|
52 | USBFilterClone(&mUSBFilter, &aThat.mUSBFilter);
|
---|
53 | }
|
---|
54 |
|
---|
55 | /** Remote or local matching criterion. */
|
---|
56 | BOOLFilter mRemote;
|
---|
57 |
|
---|
58 | /** The filter data blob. */
|
---|
59 | USBFILTER mUSBFilter;
|
---|
60 |
|
---|
61 | /** Arbitrary ID field (not used by the class itself) */
|
---|
62 | void *mId;
|
---|
63 |
|
---|
64 | settings::USBDeviceFilter mData;
|
---|
65 | };
|
---|
66 |
|
---|
67 | DECLARE_EMPTY_CTOR_DTOR(USBDeviceFilter)
|
---|
68 |
|
---|
69 | HRESULT FinalConstruct();
|
---|
70 | void FinalRelease();
|
---|
71 |
|
---|
72 | // public initializer/uninitializer for internal purposes only
|
---|
73 | HRESULT init(USBDeviceFilters *aParent,
|
---|
74 | const settings::USBDeviceFilter &data);
|
---|
75 | HRESULT init(USBDeviceFilters *aParent, IN_BSTR aName);
|
---|
76 | HRESULT init(USBDeviceFilters *aParent, USBDeviceFilter *aThat,
|
---|
77 | bool aReshare = false);
|
---|
78 | HRESULT initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat);
|
---|
79 | void uninit();
|
---|
80 |
|
---|
81 | // public methods only for internal purposes
|
---|
82 | bool i_isModified();
|
---|
83 | void i_rollback();
|
---|
84 | void i_commit();
|
---|
85 |
|
---|
86 | void unshare();
|
---|
87 |
|
---|
88 | // public methods for internal purposes only
|
---|
89 | // (ensure there is a caller and a read lock before calling them!)
|
---|
90 | void *& i_getId() { return bd->mId; }
|
---|
91 | const BackupableUSBDeviceFilterData& i_getData() { return *bd.data(); }
|
---|
92 | ComObjPtr<USBDeviceFilter> i_peer() { return mPeer; }
|
---|
93 |
|
---|
94 | // tr() wants to belong to a class it seems, thus this one here.
|
---|
95 | static HRESULT i_usbFilterFieldFromString(PUSBFILTER aFilter,
|
---|
96 | USBFILTERIDX aIdx,
|
---|
97 | const Utf8Str &aValue,
|
---|
98 | Utf8Str &aErrStr);
|
---|
99 |
|
---|
100 | static const char* i_describeUSBFilterIdx(USBFILTERIDX aIdx);
|
---|
101 |
|
---|
102 | private:
|
---|
103 |
|
---|
104 | // wrapped IUSBDeviceFilter properties
|
---|
105 | HRESULT getName(com::Utf8Str &aName);
|
---|
106 | HRESULT setName(const com::Utf8Str &aName);
|
---|
107 | HRESULT getActive(BOOL *aActive);
|
---|
108 | HRESULT setActive(BOOL aActive);
|
---|
109 | HRESULT getVendorId(com::Utf8Str &aVendorId);
|
---|
110 | HRESULT setVendorId(const com::Utf8Str &aVendorId);
|
---|
111 | HRESULT getProductId(com::Utf8Str &aProductId);
|
---|
112 | HRESULT setProductId(const com::Utf8Str &aProductId);
|
---|
113 | HRESULT getRevision(com::Utf8Str &aRevision);
|
---|
114 | HRESULT setRevision(const com::Utf8Str &aRevision);
|
---|
115 | HRESULT getManufacturer(com::Utf8Str &aManufacturer);
|
---|
116 | HRESULT setManufacturer(const com::Utf8Str &aManufacturer);
|
---|
117 | HRESULT getProduct(com::Utf8Str &aProduct);
|
---|
118 | HRESULT setProduct(const com::Utf8Str &aProduct);
|
---|
119 | HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
|
---|
120 | HRESULT setSerialNumber(const com::Utf8Str &aSerialNumber);
|
---|
121 | HRESULT getPort(com::Utf8Str &aPort);
|
---|
122 | HRESULT setPort(const com::Utf8Str &aPort);
|
---|
123 | HRESULT getRemote(com::Utf8Str &aRemote);
|
---|
124 | HRESULT setRemote(const com::Utf8Str &aRemote);
|
---|
125 | HRESULT getMaskedInterfaces(ULONG *aMaskedInterfaces);
|
---|
126 | HRESULT setMaskedInterfaces(ULONG aMaskedInterfaces);
|
---|
127 |
|
---|
128 | // wrapped IUSBDeviceFilter methods
|
---|
129 | HRESULT i_usbFilterFieldGetter(USBFILTERIDX aIdx, com::Utf8Str &aStr);
|
---|
130 | HRESULT i_usbFilterFieldSetter(USBFILTERIDX aIdx, const com::Utf8Str &strNew);
|
---|
131 |
|
---|
132 | USBDeviceFilters * const mParent;
|
---|
133 | USBDeviceFilter * const mPeer;
|
---|
134 |
|
---|
135 | Backupable<BackupableUSBDeviceFilterData> bd;
|
---|
136 |
|
---|
137 | bool m_fModified;
|
---|
138 |
|
---|
139 | /** Used externally to indicate this filter is in the list
|
---|
140 | (not touched by the class itself except that in init()/uninit()) */
|
---|
141 | bool mInList;
|
---|
142 |
|
---|
143 | friend class USBDeviceFilters;
|
---|
144 | };
|
---|
145 | #include "HostUSBDeviceFilterWrap.h"
|
---|
146 |
|
---|
147 | // HostUSBDeviceFilter
|
---|
148 | ////////////////////////////////////////////////////////////////////////////////
|
---|
149 |
|
---|
150 | class ATL_NO_VTABLE HostUSBDeviceFilter :
|
---|
151 | public HostUSBDeviceFilterWrap
|
---|
152 | {
|
---|
153 | public:
|
---|
154 |
|
---|
155 | struct BackupableUSBDeviceFilterData : public USBDeviceFilter::BackupableUSBDeviceFilterData
|
---|
156 | {
|
---|
157 | BackupableUSBDeviceFilterData() {}
|
---|
158 | };
|
---|
159 |
|
---|
160 | DECLARE_EMPTY_CTOR_DTOR (HostUSBDeviceFilter)
|
---|
161 |
|
---|
162 | HRESULT FinalConstruct();
|
---|
163 | void FinalRelease();
|
---|
164 |
|
---|
165 | // public initializer/uninitializer for internal purposes only
|
---|
166 | HRESULT init(Host *aParent,
|
---|
167 | const settings::USBDeviceFilter &data);
|
---|
168 | HRESULT init(Host *aParent, IN_BSTR aName);
|
---|
169 | void uninit();
|
---|
170 |
|
---|
171 | // public methods for internal purposes only
|
---|
172 | // (ensure there is a caller and a read lock before calling them!)
|
---|
173 | void i_saveSettings(settings::USBDeviceFilter &data);
|
---|
174 |
|
---|
175 | void*& i_getId() { return bd.data()->mId; }
|
---|
176 |
|
---|
177 | const BackupableUSBDeviceFilterData& i_getData() { return *bd.data(); }
|
---|
178 |
|
---|
179 | // util::Lockable interface
|
---|
180 | RWLockHandle *lockHandle() const;
|
---|
181 |
|
---|
182 | private:
|
---|
183 |
|
---|
184 | // wrapped IHostUSBDeviceFilter properties
|
---|
185 | HRESULT getName(com::Utf8Str &aName);
|
---|
186 | HRESULT setName(const com::Utf8Str &aName);
|
---|
187 | HRESULT getActive(BOOL *aActive);
|
---|
188 | HRESULT setActive(BOOL aActive);
|
---|
189 | HRESULT getVendorId(com::Utf8Str &aVendorId);
|
---|
190 | HRESULT setVendorId(const com::Utf8Str &aVendorId);
|
---|
191 | HRESULT getProductId(com::Utf8Str &aProductId);
|
---|
192 | HRESULT setProductId(const com::Utf8Str &aProductId);
|
---|
193 | HRESULT getRevision(com::Utf8Str &aRevision);
|
---|
194 | HRESULT setRevision(const com::Utf8Str &aRevision);
|
---|
195 | HRESULT getManufacturer(com::Utf8Str &aManufacturer);
|
---|
196 | HRESULT setManufacturer(const com::Utf8Str &aManufacturer);
|
---|
197 | HRESULT getProduct(com::Utf8Str &aProduct);
|
---|
198 | HRESULT setProduct(const com::Utf8Str &aProduct);
|
---|
199 | HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
|
---|
200 | HRESULT setSerialNumber(const com::Utf8Str &aSerialNumber);
|
---|
201 | HRESULT getPort(com::Utf8Str &aPort);
|
---|
202 | HRESULT setPort(const com::Utf8Str &aPort);
|
---|
203 | HRESULT getRemote(com::Utf8Str &aRemote);
|
---|
204 | HRESULT setRemote(const com::Utf8Str &aRemote);
|
---|
205 | HRESULT getMaskedInterfaces(ULONG *aMaskedInterfaces);
|
---|
206 | HRESULT setMaskedInterfaces(ULONG aMaskedInterfaces);
|
---|
207 |
|
---|
208 | // wrapped IHostUSBDeviceFilter properties
|
---|
209 | HRESULT getAction(USBDeviceFilterAction_T *aAction);
|
---|
210 | HRESULT setAction(USBDeviceFilterAction_T aAction);
|
---|
211 |
|
---|
212 | HRESULT i_usbFilterFieldGetter(USBFILTERIDX aIdx, com::Utf8Str &aStr);
|
---|
213 | HRESULT i_usbFilterFieldSetter(USBFILTERIDX aIdx, const com::Utf8Str &aStr);
|
---|
214 |
|
---|
215 | Host * const mParent;
|
---|
216 |
|
---|
217 | Backupable<BackupableUSBDeviceFilterData> bd;
|
---|
218 |
|
---|
219 | /** Used externally to indicate this filter is in the list
|
---|
220 | (not touched by the class itself except that in init()/uninit()) */
|
---|
221 | bool mInList;
|
---|
222 |
|
---|
223 | friend class Host;
|
---|
224 | };
|
---|
225 |
|
---|
226 | #endif // ____H_USBDEVICEFILTERIMPL
|
---|
227 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|