1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox USBController COM Class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung 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 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_USBCONTROLLERIMPL
|
---|
23 | #define ____H_USBCONTROLLERIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 | #include "USBDeviceFilterImpl.h"
|
---|
27 |
|
---|
28 | #include <VBox/cfgldr.h>
|
---|
29 |
|
---|
30 | #include <list>
|
---|
31 |
|
---|
32 | class Machine;
|
---|
33 | class HostUSBDevice;
|
---|
34 |
|
---|
35 | class ATL_NO_VTABLE USBController :
|
---|
36 | public VirtualBoxBaseWithChildren,
|
---|
37 | public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>,
|
---|
38 | public VirtualBoxSupportTranslation<USBController>,
|
---|
39 | public IUSBController
|
---|
40 | {
|
---|
41 | private:
|
---|
42 |
|
---|
43 | struct Data
|
---|
44 | {
|
---|
45 | /* Constructor. */
|
---|
46 | Data() : m_fEnabled(FALSE) { }
|
---|
47 |
|
---|
48 | bool operator== (const Data &that) const
|
---|
49 | {
|
---|
50 | return this == &that || m_fEnabled == that.m_fEnabled;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /** Enabled indicator. */
|
---|
54 | BOOL m_fEnabled;
|
---|
55 | };
|
---|
56 |
|
---|
57 | public:
|
---|
58 |
|
---|
59 | DECLARE_NOT_AGGREGATABLE(USBController)
|
---|
60 |
|
---|
61 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
62 |
|
---|
63 | BEGIN_COM_MAP(USBController)
|
---|
64 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
65 | COM_INTERFACE_ENTRY(IUSBController)
|
---|
66 | END_COM_MAP()
|
---|
67 |
|
---|
68 | NS_DECL_ISUPPORTS
|
---|
69 |
|
---|
70 | HRESULT FinalConstruct();
|
---|
71 | void FinalRelease();
|
---|
72 |
|
---|
73 | // public initializer/uninitializer for internal purposes only
|
---|
74 | HRESULT init (Machine *parent);
|
---|
75 | HRESULT init (Machine *parent, USBController *that);
|
---|
76 | HRESULT initCopy (Machine *parent, USBController *that);
|
---|
77 | void uninit();
|
---|
78 |
|
---|
79 | // IUSBController properties
|
---|
80 | STDMETHOD(COMGETTER(Enabled))(BOOL *a_pfEnabled);
|
---|
81 | STDMETHOD(COMSETTER(Enabled))(BOOL a_fEnabled);
|
---|
82 | STDMETHOD(COMGETTER(USBStandard))(USHORT *a_pusUSBStandard);
|
---|
83 | STDMETHOD(COMGETTER(DeviceFilters))(IUSBDeviceFilterCollection **aDevicesFilters);
|
---|
84 |
|
---|
85 | // IUSBController methods
|
---|
86 | STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
|
---|
87 | STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
|
---|
88 | STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
|
---|
89 |
|
---|
90 | // public methods only for internal purposes
|
---|
91 |
|
---|
92 | ComObjPtr <Machine, ComWeakRef> &parent() { return m_Parent; };
|
---|
93 |
|
---|
94 | HRESULT loadSettings (CFGNODE aMachine);
|
---|
95 | HRESULT saveSettings (CFGNODE aMachine);
|
---|
96 |
|
---|
97 | bool isModified();
|
---|
98 | bool isReallyModified();
|
---|
99 | bool rollback();
|
---|
100 | void commit();
|
---|
101 | void copyFrom (USBController *aThat);
|
---|
102 |
|
---|
103 | const Backupable<Data> &data() { return m_Data; }
|
---|
104 |
|
---|
105 | HRESULT onMachineRegistered (BOOL aRegistered);
|
---|
106 |
|
---|
107 | HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
|
---|
108 | BOOL aActiveChanged = FALSE);
|
---|
109 |
|
---|
110 | bool hasMatchingFilter (ComObjPtr <HostUSBDevice> &aDevice);
|
---|
111 | bool hasMatchingFilter (IUSBDevice *aUSBDevice);
|
---|
112 |
|
---|
113 | // for VirtualBoxSupportErrorInfoImpl
|
---|
114 | static const wchar_t *getComponentName() { return L"USBController"; }
|
---|
115 |
|
---|
116 | private:
|
---|
117 |
|
---|
118 | /** specialization for IUSBDeviceFilter */
|
---|
119 | ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
|
---|
120 | {
|
---|
121 | VirtualBoxBase *child = VirtualBoxBaseWithChildren::
|
---|
122 | getDependentChild (ComPtr <IUnknown> (aFilter));
|
---|
123 | return child ? static_cast <USBDeviceFilter *> (child)
|
---|
124 | : NULL;
|
---|
125 | }
|
---|
126 |
|
---|
127 | void printList();
|
---|
128 |
|
---|
129 | /** Parent object. */
|
---|
130 | ComObjPtr<Machine, ComWeakRef> m_Parent;
|
---|
131 | /** Peer object. */
|
---|
132 | ComObjPtr<USBController> m_Peer;
|
---|
133 | /** Data. */
|
---|
134 | Backupable<Data> m_Data;
|
---|
135 |
|
---|
136 | // the following fields need special backup/rollback/commit handling,
|
---|
137 | // so they cannot be a part of Data
|
---|
138 |
|
---|
139 | typedef std::list <ComObjPtr <USBDeviceFilter> > DeviceFilterList;
|
---|
140 | Backupable <DeviceFilterList> m_DeviceFilters;
|
---|
141 | };
|
---|
142 |
|
---|
143 | #endif //!____H_USBCONTROLLERIMPL
|
---|