VirtualBox

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

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

Main: the big XML settings rework. Move XML reading/writing out of interface implementation code into separate layer so it can handle individual settings versions in the future.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: USBControllerImpl.h 22173 2009-08-11 15:38:59Z 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
37namespace settings
38{
39 class USBController;
40}
41
42/**
43 * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
44 * base class, because we want a quick (map-based) way of validating
45 * IUSBDeviceFilter pointers passed from outside as method parameters that
46 * VirtualBoxBaseWithChildren::getDependentChild() gives us.
47 */
48
49class ATL_NO_VTABLE USBController :
50 public VirtualBoxBaseWithChildrenNEXT,
51 public VirtualBoxSupportErrorInfoImpl<USBController, IUSBController>,
52 public VirtualBoxSupportTranslation<USBController>,
53 VBOX_SCRIPTABLE_IMPL(IUSBController)
54{
55private:
56
57 struct Data
58 {
59 /* Constructor. */
60 Data() : mEnabled (FALSE), mEnabledEhci (FALSE) { }
61
62 bool operator== (const Data &that) const
63 {
64 return this == &that || (mEnabled == that.mEnabled && mEnabledEhci == that.mEnabledEhci);
65 }
66
67 /** Enabled indicator. */
68 BOOL mEnabled;
69
70 /** Enabled indicator for EHCI. */
71 BOOL mEnabledEhci;
72 };
73
74public:
75
76 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
77
78 DECLARE_NOT_AGGREGATABLE (USBController)
79
80 DECLARE_PROTECT_FINAL_CONSTRUCT()
81
82 BEGIN_COM_MAP(USBController)
83 COM_INTERFACE_ENTRY (ISupportErrorInfo)
84 COM_INTERFACE_ENTRY (IUSBController)
85 COM_INTERFACE_ENTRY2 (IDispatch, IUSBController)
86 END_COM_MAP()
87
88 NS_DECL_ISUPPORTS
89
90 DECLARE_EMPTY_CTOR_DTOR (USBController)
91
92 HRESULT FinalConstruct();
93 void FinalRelease();
94
95 // public initializer/uninitializer for internal purposes only
96 HRESULT init (Machine *aParent);
97 HRESULT init (Machine *aParent, USBController *aThat);
98 HRESULT initCopy (Machine *aParent, USBController *aThat);
99 void uninit();
100
101 // IUSBController properties
102 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
103 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
104 STDMETHOD(COMGETTER(EnabledEhci)) (BOOL *aEnabled);
105 STDMETHOD(COMSETTER(EnabledEhci)) (BOOL aEnabled);
106 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
107 STDMETHOD(COMGETTER(DeviceFilters)) (ComSafeArrayOut (IUSBDeviceFilter *, aDevicesFilters));
108
109 // IUSBController methods
110 STDMETHOD(CreateDeviceFilter) (IN_BSTR aName, IUSBDeviceFilter **aFilter);
111 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
112 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
113
114 // public methods only for internal purposes
115
116 HRESULT loadSettings(const settings::USBController &data);
117 HRESULT saveSettings(settings::USBController &data);
118
119 bool isModified();
120 bool isReallyModified();
121 bool rollback();
122 void commit();
123 void copyFrom (USBController *aThat);
124
125#ifdef VBOX_WITH_USB
126 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
127 BOOL aActiveChanged = FALSE);
128
129 bool hasMatchingFilter (const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
130 bool hasMatchingFilter (IUSBDevice *aUSBDevice, ULONG *aMaskedIfs);
131
132 HRESULT notifyProxy (bool aInsertFilters);
133#endif /* VBOX_WITH_USB */
134
135 // public methods for internal purposes only
136 // (ensure there is a caller and a read lock before calling them!)
137
138 /** @note this doesn't require a read lock since mParent is constant. */
139 const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; };
140
141 const Backupable<Data> &data() { return mData; }
142
143 // for VirtualBoxSupportErrorInfoImpl
144 static const wchar_t *getComponentName() { return L"USBController"; }
145
146private:
147
148#ifdef VBOX_WITH_USB
149 /** specialization for IUSBDeviceFilter */
150 ComObjPtr<USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
151 {
152 VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT::
153 getDependentChild (ComPtr<IUnknown> (aFilter));
154 return child ? static_cast <USBDeviceFilter *> (child)
155 : NULL;
156 }
157#endif /* VBOX_WITH_USB */
158
159 void printList();
160
161 /** Parent object. */
162 const ComObjPtr<Machine, ComWeakRef> mParent;
163 /** Peer object. */
164 const ComObjPtr<USBController> mPeer;
165 /** Data. */
166 Backupable <Data> mData;
167
168#ifdef VBOX_WITH_USB
169 // the following fields need special backup/rollback/commit handling,
170 // so they cannot be a part of Data
171
172 typedef std::list <ComObjPtr<USBDeviceFilter> > DeviceFilterList;
173 Backupable <DeviceFilterList> mDeviceFilters;
174#endif /* VBOX_WITH_USB */
175};
176
177#endif //!____H_USBCONTROLLERIMPL
178/* 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