VirtualBox

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

Last change on this file since 7964 was 7964, checked in by vboxsync, 17 years ago

Attempt at making OSE build again.

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