VirtualBox

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

Last change on this file since 18622 was 17336, checked in by vboxsync, 16 years ago

#3551: “Main: Replace remaining collections with safe arrays”
Converted USBFilterCollection. Tested with filters in the GUI.

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