1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
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_HOSTIMPL
|
---|
23 | #define ____H_HOSTIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 | #include "HostUSBDeviceImpl.h"
|
---|
27 | #include "USBDeviceFilterImpl.h"
|
---|
28 |
|
---|
29 | #ifdef __WIN__
|
---|
30 | #include "win32/svchlp.h"
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <VBox/cfgldr.h>
|
---|
34 |
|
---|
35 | class VirtualBox;
|
---|
36 | class SessionMachine;
|
---|
37 | class HostDVDDrive;
|
---|
38 | class Progress;
|
---|
39 |
|
---|
40 | #include <list>
|
---|
41 |
|
---|
42 | class ATL_NO_VTABLE Host :
|
---|
43 | public VirtualBoxBaseWithChildren,
|
---|
44 | public VirtualBoxSupportErrorInfoImpl <Host, IHost>,
|
---|
45 | public VirtualBoxSupportTranslation <Host>,
|
---|
46 | public IHost
|
---|
47 | {
|
---|
48 | public:
|
---|
49 |
|
---|
50 | DECLARE_NOT_AGGREGATABLE(Host)
|
---|
51 |
|
---|
52 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
53 |
|
---|
54 | BEGIN_COM_MAP(Host)
|
---|
55 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
56 | COM_INTERFACE_ENTRY(IHost)
|
---|
57 | END_COM_MAP()
|
---|
58 |
|
---|
59 | NS_DECL_ISUPPORTS
|
---|
60 |
|
---|
61 | HRESULT FinalConstruct();
|
---|
62 | void FinalRelease();
|
---|
63 |
|
---|
64 | // public initializer/uninitializer for internal purposes only
|
---|
65 | HRESULT init (VirtualBox *parent);
|
---|
66 | void uninit();
|
---|
67 |
|
---|
68 | // IHost properties
|
---|
69 | STDMETHOD(COMGETTER(DVDDrives))(IHostDVDDriveCollection **drives);
|
---|
70 | STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
|
---|
71 | STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
|
---|
72 | STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters);
|
---|
73 | #ifdef __WIN__
|
---|
74 | STDMETHOD(COMGETTER(NetworkInterfaces))(IHostNetworkInterfaceCollection **networkInterfaces);
|
---|
75 | #endif
|
---|
76 | STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
|
---|
77 | STDMETHOD(COMGETTER(ProcessorSpeed))(ULONG *speed);
|
---|
78 | STDMETHOD(COMGETTER(ProcessorDescription))(BSTR *description);
|
---|
79 | STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
|
---|
80 | STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
|
---|
81 | STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
|
---|
82 | STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
|
---|
83 | STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
|
---|
84 |
|
---|
85 | // IHost methods
|
---|
86 | #ifdef __WIN__
|
---|
87 | STDMETHOD(CreateHostNetworkInterface) (INPTR BSTR aName,
|
---|
88 | IHostNetworkInterface **aHostNetworkInterface,
|
---|
89 | IProgress **aProgress);
|
---|
90 | STDMETHOD(RemoveHostNetworkInterface) (INPTR GUIDPARAM aId,
|
---|
91 | IHostNetworkInterface **aHostNetworkInterface,
|
---|
92 | IProgress **aProgress);
|
---|
93 | #endif
|
---|
94 | STDMETHOD(CreateUSBDeviceFilter) (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter);
|
---|
95 | STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
|
---|
96 | STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
|
---|
97 |
|
---|
98 | // public methods only for internal purposes
|
---|
99 |
|
---|
100 | HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter,
|
---|
101 | BOOL aActiveChanged = FALSE);
|
---|
102 |
|
---|
103 | HRESULT loadSettings (CFGNODE aGlobal);
|
---|
104 | HRESULT saveSettings (CFGNODE aGlobal);
|
---|
105 |
|
---|
106 | HRESULT captureUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId,
|
---|
107 | IUSBDevice **aHostDevice);
|
---|
108 | HRESULT releaseUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId);
|
---|
109 | HRESULT autoCaptureUSBDevices (SessionMachine *aMachine,
|
---|
110 | IUSBDeviceCollection **aHostDevices);
|
---|
111 | HRESULT releaseAllUSBDevices (SessionMachine *aMachine);
|
---|
112 |
|
---|
113 | void onUSBDeviceAttached (HostUSBDevice *aDevice);
|
---|
114 | void onUSBDeviceDetached (HostUSBDevice *aDevice);
|
---|
115 | void onUSBDeviceStateChanged (HostUSBDevice *aDevice);
|
---|
116 |
|
---|
117 | HRESULT checkUSBProxyService();
|
---|
118 |
|
---|
119 | /* must be called from under this object's lock */
|
---|
120 | USBProxyService *usbProxyService() { return mUSBProxyService; }
|
---|
121 |
|
---|
122 | #ifdef __WIN__
|
---|
123 | static int networkInterfaceHelperServer (SVCHlpClient *aClient,
|
---|
124 | SVCHlpMsg::Code aMsgCode);
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | // for VirtualBoxSupportErrorInfoImpl
|
---|
128 | static const wchar_t *getComponentName() { return L"Host"; }
|
---|
129 |
|
---|
130 | private:
|
---|
131 |
|
---|
132 | #ifdef __LINUX__
|
---|
133 | void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
|
---|
134 | bool validateDevice(char *deviceNode, bool isCDROM);
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | /** specialization for IHostUSBDeviceFilter */
|
---|
138 | ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
|
---|
139 | {
|
---|
140 | VirtualBoxBase *child = VirtualBoxBaseWithChildren::
|
---|
141 | getDependentChild (ComPtr <IUnknown> (aFilter));
|
---|
142 | return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
|
---|
143 | : NULL;
|
---|
144 | }
|
---|
145 |
|
---|
146 | HRESULT applyAllUSBFilters (ComObjPtr <HostUSBDevice> &aDevice,
|
---|
147 | SessionMachine *aMachine = NULL);
|
---|
148 | void applyMachineUSBFilters (SessionMachine *aMachine,
|
---|
149 | ComObjPtr <HostUSBDevice> &aDevice);
|
---|
150 |
|
---|
151 | #ifdef __WIN__
|
---|
152 | static int createNetworkInterface (SVCHlpClient *aClient,
|
---|
153 | const Utf8Str &aName,
|
---|
154 | Guid &aGUID, Utf8Str &aErrMsg);
|
---|
155 | static int removeNetworkInterface (SVCHlpClient *aClient,
|
---|
156 | const Guid &aGUID,
|
---|
157 | Utf8Str &aErrMsg);
|
---|
158 | static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
|
---|
159 | Progress *aProgress,
|
---|
160 | void *aUser, int *aVrc);
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | ComObjPtr <VirtualBox, ComWeakRef> mParent;
|
---|
164 |
|
---|
165 | typedef std::list <ComObjPtr <HostUSBDevice> > USBDeviceList;
|
---|
166 | USBDeviceList mUSBDevices;
|
---|
167 |
|
---|
168 | typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
|
---|
169 | USBDeviceFilterList mUSBDeviceFilters;
|
---|
170 |
|
---|
171 | /** Pointer to the USBProxyService object. */
|
---|
172 | USBProxyService *mUSBProxyService;
|
---|
173 | };
|
---|
174 |
|
---|
175 | #endif // ____H_HOSTIMPL
|
---|