VirtualBox

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

Last change on this file since 22162 was 21878, checked in by vboxsync, 15 years ago

Main: coding style: have Main obey the standard VirtualBox coding style rules (no functional changes)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/* $Id: USBControllerImpl.h 21878 2009-07-30 12:42:08Z 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 VBOX_SCRIPTABLE_IMPL(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 COM_INTERFACE_ENTRY2 (IDispatch, IUSBController)
81 END_COM_MAP()
82
83 NS_DECL_ISUPPORTS
84
85 DECLARE_EMPTY_CTOR_DTOR (USBController)
86
87 HRESULT FinalConstruct();
88 void FinalRelease();
89
90 // public initializer/uninitializer for internal purposes only
91 HRESULT init (Machine *aParent);
92 HRESULT init (Machine *aParent, USBController *aThat);
93 HRESULT initCopy (Machine *aParent, USBController *aThat);
94 void uninit();
95
96 // IUSBController properties
97 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
98 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
99 STDMETHOD(COMGETTER(EnabledEhci)) (BOOL *aEnabled);
100 STDMETHOD(COMSETTER(EnabledEhci)) (BOOL aEnabled);
101 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
102 STDMETHOD(COMGETTER(DeviceFilters)) (ComSafeArrayOut (IUSBDeviceFilter *, aDevicesFilters));
103
104 // IUSBController methods
105 STDMETHOD(CreateDeviceFilter) (IN_BSTR aName, IUSBDeviceFilter **aFilter);
106 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
107 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
108
109 // public methods only for internal purposes
110
111 HRESULT loadSettings (const settings::Key &aMachineNode);
112 HRESULT saveSettings (settings::Key &aMachineNode);
113
114 bool isModified();
115 bool isReallyModified();
116 bool rollback();
117 void commit();
118 void copyFrom (USBController *aThat);
119
120#ifdef VBOX_WITH_USB
121 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
122 BOOL aActiveChanged = FALSE);
123
124 bool hasMatchingFilter (const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
125 bool hasMatchingFilter (IUSBDevice *aUSBDevice, ULONG *aMaskedIfs);
126
127 HRESULT notifyProxy (bool aInsertFilters);
128#endif /* VBOX_WITH_USB */
129
130 // public methods for internal purposes only
131 // (ensure there is a caller and a read lock before calling them!)
132
133 /** @note this doesn't require a read lock since mParent is constant. */
134 const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; };
135
136 const Backupable<Data> &data() { return mData; }
137
138 // for VirtualBoxSupportErrorInfoImpl
139 static const wchar_t *getComponentName() { return L"USBController"; }
140
141private:
142
143#ifdef VBOX_WITH_USB
144 /** specialization for IUSBDeviceFilter */
145 ComObjPtr<USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
146 {
147 VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT::
148 getDependentChild (ComPtr<IUnknown> (aFilter));
149 return child ? static_cast <USBDeviceFilter *> (child)
150 : NULL;
151 }
152#endif /* VBOX_WITH_USB */
153
154 void printList();
155
156 /** Parent object. */
157 const ComObjPtr<Machine, ComWeakRef> mParent;
158 /** Peer object. */
159 const ComObjPtr<USBController> mPeer;
160 /** Data. */
161 Backupable <Data> mData;
162
163#ifdef VBOX_WITH_USB
164 // the following fields need special backup/rollback/commit handling,
165 // so they cannot be a part of Data
166
167 typedef std::list <ComObjPtr<USBDeviceFilter> > DeviceFilterList;
168 Backupable <DeviceFilterList> mDeviceFilters;
169#endif /* VBOX_WITH_USB */
170};
171
172#endif //!____H_USBCONTROLLERIMPL
173/* 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