1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
/* $Id: USBDeviceFilterImpl.h $ */
/** @file
* Declaration of USBDeviceFilter and HostUSBDeviceFilter.
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_USBDEVICEFILTERIMPL
#define ____H_USBDEVICEFILTERIMPL
#include "VirtualBoxBase.h"
#include "Matching.h"
#include <VBox/usbfilter.h>
class USBDeviceFilters;
class Host;
namespace settings
{
struct USBDeviceFilter;
}
// USBDeviceFilter
////////////////////////////////////////////////////////////////////////////////
class ATL_NO_VTABLE USBDeviceFilter :
public VirtualBoxBase,
VBOX_SCRIPTABLE_IMPL(IUSBDeviceFilter)
{
public:
struct Data
{
typedef matching::Matchable <matching::ParsedBoolFilter> BOOLFilter;
Data() : mActive (FALSE), mMaskedIfs (0), mId (NULL) {}
Data (const Data &aThat) : mName (aThat.mName), mActive (aThat.mActive),
mRemote (aThat.mRemote), mMaskedIfs (aThat.mMaskedIfs) , mId (aThat.mId)
{
USBFilterClone (&mUSBFilter, &aThat.mUSBFilter);
}
/** The filter name. */
Bstr mName;
/** Indicates whether the filter is active or not. */
BOOL mActive;
/** Remote or local matching criterion. */
BOOLFilter mRemote;
/** The filter data blob. */
USBFILTER mUSBFilter;
/** Interface masking bit mask that should be applied to matching devices. */
ULONG mMaskedIfs;
/** Arbitrary ID field (not used by the class itself) */
void *mId;
};
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(USBDeviceFilter, IUSBDeviceFilter)
DECLARE_NOT_AGGREGATABLE(USBDeviceFilter)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(USBDeviceFilter)
VBOX_DEFAULT_INTERFACE_ENTRIES (IUSBDeviceFilter)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR (USBDeviceFilter)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init(USBDeviceFilters *aParent,
const settings::USBDeviceFilter &data);
HRESULT init(USBDeviceFilters *aParent, IN_BSTR aName);
HRESULT init(USBDeviceFilters *aParent, USBDeviceFilter *aThat,
bool aReshare = false);
HRESULT initCopy(USBDeviceFilters *aParent, USBDeviceFilter *aThat);
void uninit();
// IUSBDeviceFilter properties
STDMETHOD(COMGETTER(Name)) (BSTR *aName);
STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
STDMETHOD(COMGETTER(Active)) (BOOL *aActive);
STDMETHOD(COMSETTER(Active)) (BOOL aActive);
STDMETHOD(COMGETTER(VendorId)) (BSTR *aVendorId);
STDMETHOD(COMSETTER(VendorId)) (IN_BSTR aVendorId);
STDMETHOD(COMGETTER(ProductId)) (BSTR *aProductId);
STDMETHOD(COMSETTER(ProductId)) (IN_BSTR aProductId);
STDMETHOD(COMGETTER(Revision)) (BSTR *aRevision);
STDMETHOD(COMSETTER(Revision)) (IN_BSTR aRevision);
STDMETHOD(COMGETTER(Manufacturer)) (BSTR *aManufacturer);
STDMETHOD(COMSETTER(Manufacturer)) (IN_BSTR aManufacturer);
STDMETHOD(COMGETTER(Product)) (BSTR *aProduct);
STDMETHOD(COMSETTER(Product)) (IN_BSTR aProduct);
STDMETHOD(COMGETTER(SerialNumber)) (BSTR *aSerialNumber);
STDMETHOD(COMSETTER(SerialNumber)) (IN_BSTR aSerialNumber);
STDMETHOD(COMGETTER(Port)) (BSTR *aPort);
STDMETHOD(COMSETTER(Port)) (IN_BSTR aPort);
STDMETHOD(COMGETTER(Remote)) (BSTR *aRemote);
STDMETHOD(COMSETTER(Remote)) (IN_BSTR aRemote);
STDMETHOD(COMGETTER(MaskedInterfaces)) (ULONG *aMaskedIfs);
STDMETHOD(COMSETTER(MaskedInterfaces)) (ULONG aMaskedIfs);
// public methods only for internal purposes
bool isModified();
void rollback();
void commit();
void unshare();
// public methods for internal purposes only
// (ensure there is a caller and a read lock before calling them!)
void *& getId() { return mData.data()->mId; }
const Data& getData() { return *mData.data(); }
ComObjPtr<USBDeviceFilter> peer() { return mPeer; }
// tr() wants to belong to a class it seems, thus this one here.
static HRESULT usbFilterFieldFromString(PUSBFILTER aFilter,
USBFILTERIDX aIdx,
const Utf8Str &aValue,
Utf8Str &aErrStr);
static const char* describeUSBFilterIdx(USBFILTERIDX aIdx);
private:
HRESULT usbFilterFieldGetter(USBFILTERIDX aIdx, BSTR *aStr);
HRESULT usbFilterFieldSetter(USBFILTERIDX aIdx, IN_BSTR aStr);
HRESULT usbFilterFieldSetter(USBFILTERIDX aIdx, const Utf8Str &strNew);
USBDeviceFilters * const mParent;
USBDeviceFilter * const mPeer;
Backupable<Data> mData;
bool m_fModified;
/** Used externally to indicate this filter is in the list
(not touched by the class itself except that in init()/uninit()) */
bool mInList;
friend class USBDeviceFilters;
};
// HostUSBDeviceFilter
////////////////////////////////////////////////////////////////////////////////
class ATL_NO_VTABLE HostUSBDeviceFilter :
public VirtualBoxBase,
VBOX_SCRIPTABLE_IMPL(IHostUSBDeviceFilter)
{
public:
struct Data : public USBDeviceFilter::Data
{
Data() {}
};
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(HostUSBDeviceFilter, IHostUSBDeviceFilter)
DECLARE_NOT_AGGREGATABLE(HostUSBDeviceFilter)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(HostUSBDeviceFilter)
COM_INTERFACE_ENTRY(IUSBDeviceFilter)
VBOX_DEFAULT_INTERFACE_ENTRIES(IHostUSBDeviceFilter)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR (HostUSBDeviceFilter)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init(Host *aParent,
const settings::USBDeviceFilter &data);
HRESULT init(Host *aParent, IN_BSTR aName);
void uninit();
// IUSBDeviceFilter properties
STDMETHOD(COMGETTER(Name)) (BSTR *aName);
STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
STDMETHOD(COMGETTER(Active)) (BOOL *aActive);
STDMETHOD(COMSETTER(Active)) (BOOL aActive);
STDMETHOD(COMGETTER(VendorId)) (BSTR *aVendorId);
STDMETHOD(COMSETTER(VendorId)) (IN_BSTR aVendorId);
STDMETHOD(COMGETTER(ProductId)) (BSTR *aProductId);
STDMETHOD(COMSETTER(ProductId)) (IN_BSTR aProductId);
STDMETHOD(COMGETTER(Revision)) (BSTR *aRevision);
STDMETHOD(COMSETTER(Revision)) (IN_BSTR aRevision);
STDMETHOD(COMGETTER(Manufacturer)) (BSTR *aManufacturer);
STDMETHOD(COMSETTER(Manufacturer)) (IN_BSTR aManufacturer);
STDMETHOD(COMGETTER(Product)) (BSTR *aProduct);
STDMETHOD(COMSETTER(Product)) (IN_BSTR aProduct);
STDMETHOD(COMGETTER(SerialNumber)) (BSTR *aSerialNumber);
STDMETHOD(COMSETTER(SerialNumber)) (IN_BSTR aSerialNumber);
STDMETHOD(COMGETTER(Port)) (BSTR *aPort);
STDMETHOD(COMSETTER(Port)) (IN_BSTR aPort);
STDMETHOD(COMGETTER(Remote)) (BSTR *aRemote);
STDMETHOD(COMSETTER(Remote)) (IN_BSTR aRemote);
STDMETHOD(COMGETTER(MaskedInterfaces)) (ULONG *aMaskedIfs);
STDMETHOD(COMSETTER(MaskedInterfaces)) (ULONG aMaskedIfs);
// IHostUSBDeviceFilter properties
STDMETHOD(COMGETTER(Action)) (USBDeviceFilterAction_T *aAction);
STDMETHOD(COMSETTER(Action)) (USBDeviceFilterAction_T aAction);
// public methods for internal purposes only
// (ensure there is a caller and a read lock before calling them!)
void saveSettings(settings::USBDeviceFilter &data);
void*& getId() { return mData.data()->mId; }
const Data& getData() { return *mData.data(); }
// util::Lockable interface
RWLockHandle *lockHandle() const;
private:
HRESULT usbFilterFieldGetter(USBFILTERIDX aIdx, BSTR *aStr);
HRESULT usbFilterFieldSetter(USBFILTERIDX aIdx, Bstr aStr);
Host * const mParent;
Backupable<Data> mData;
/** Used externally to indicate this filter is in the list
(not touched by the class itself except that in init()/uninit()) */
bool mInList;
friend class Host;
};
#endif // ____H_USBDEVICEFILTERIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
|