1 | /* $Id: HostImpl.h 26044 2010-01-26 12:21:34Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Implemenation of IHost.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_HOSTIMPL
|
---|
23 | #define ____H_HOSTIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 |
|
---|
27 | class HostUSBDeviceFilter;
|
---|
28 | class USBProxyService;
|
---|
29 | class SessionMachine;
|
---|
30 | class Progress;
|
---|
31 | class PerformanceCollector;
|
---|
32 |
|
---|
33 | namespace settings
|
---|
34 | {
|
---|
35 | struct Host;
|
---|
36 | }
|
---|
37 |
|
---|
38 | #include <list>
|
---|
39 |
|
---|
40 | class ATL_NO_VTABLE Host :
|
---|
41 | public VirtualBoxBase,
|
---|
42 | public VirtualBoxSupportErrorInfoImpl<Host, IHost>,
|
---|
43 | public VirtualBoxSupportTranslation<Host>,
|
---|
44 | VBOX_SCRIPTABLE_IMPL(IHost)
|
---|
45 | {
|
---|
46 | public:
|
---|
47 |
|
---|
48 | DECLARE_NOT_AGGREGATABLE(Host)
|
---|
49 |
|
---|
50 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
51 |
|
---|
52 | BEGIN_COM_MAP(Host)
|
---|
53 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
54 | COM_INTERFACE_ENTRY(IHost)
|
---|
55 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
56 | END_COM_MAP()
|
---|
57 |
|
---|
58 | HRESULT FinalConstruct();
|
---|
59 | void FinalRelease();
|
---|
60 |
|
---|
61 | // public initializer/uninitializer for internal purposes only
|
---|
62 | HRESULT init(VirtualBox *aParent);
|
---|
63 | void uninit();
|
---|
64 |
|
---|
65 | // IHost properties
|
---|
66 | STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IMedium *, drives));
|
---|
67 | STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IMedium *, drives));
|
---|
68 | STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
|
---|
69 | STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
|
---|
70 | STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
|
---|
71 | STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
|
---|
72 | STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
|
---|
73 | STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
|
---|
74 | STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
|
---|
75 | STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
|
---|
76 | STDMETHOD(GetProcessorCpuIdLeaf)(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX);
|
---|
77 | STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
|
---|
78 | STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
|
---|
79 | STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
|
---|
80 | STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
|
---|
81 | STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
|
---|
82 | STDMETHOD(COMGETTER(Acceleration3DAvailable))(BOOL *aSupported);
|
---|
83 |
|
---|
84 | // IHost methods
|
---|
85 | STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
|
---|
86 | IProgress **aProgress);
|
---|
87 | STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_BSTR aId, IProgress **aProgress);
|
---|
88 | STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
|
---|
89 | STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
|
---|
90 | STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition);
|
---|
91 |
|
---|
92 | STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IMedium **aDrive);
|
---|
93 | STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IMedium **aDrive);
|
---|
94 | STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
|
---|
95 | STDMETHOD(FindHostNetworkInterfaceById) (IN_BSTR id, IHostNetworkInterface **networkInterface);
|
---|
96 | STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
|
---|
97 | STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
|
---|
98 | STDMETHOD(FindUSBDeviceById) (IN_BSTR aId, IHostUSBDevice **aDevice);
|
---|
99 |
|
---|
100 | // public methods only for internal purposes
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Simple run-time type identification without having to enable C++ RTTI.
|
---|
104 | * The class IDs are defined in VirtualBoxBase.h.
|
---|
105 | * @return
|
---|
106 | */
|
---|
107 | virtual VBoxClsID getClassID() const
|
---|
108 | {
|
---|
109 | return clsidHost;
|
---|
110 | }
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Override of the default locking class to be used for validating lock
|
---|
114 | * order with the standard member lock handle.
|
---|
115 | */
|
---|
116 | virtual VBoxLockingClass getLockingClass() const
|
---|
117 | {
|
---|
118 | return LOCKCLASS_HOSTOBJECT;
|
---|
119 | }
|
---|
120 |
|
---|
121 | HRESULT loadSettings(const settings::Host &data);
|
---|
122 | HRESULT saveSettings(settings::Host &data);
|
---|
123 |
|
---|
124 | HRESULT getDVDDrives(MediaList &ll);
|
---|
125 | HRESULT getFloppyDrives(MediaList &ll);
|
---|
126 |
|
---|
127 | #ifdef VBOX_WITH_USB
|
---|
128 | typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
|
---|
129 |
|
---|
130 | /** Must be called from under this object's lock. */
|
---|
131 | USBProxyService* usbProxyService();
|
---|
132 |
|
---|
133 | HRESULT addChild(HostUSBDeviceFilter *pChild);
|
---|
134 | HRESULT removeChild(HostUSBDeviceFilter *pChild);
|
---|
135 | VirtualBox* parent();
|
---|
136 |
|
---|
137 | HRESULT onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
|
---|
138 | void getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
|
---|
139 | HRESULT checkUSBProxyService();
|
---|
140 | #endif /* !VBOX_WITH_USB */
|
---|
141 |
|
---|
142 | // for VirtualBoxSupportErrorInfoImpl
|
---|
143 | static const wchar_t *getComponentName() { return L"Host"; }
|
---|
144 |
|
---|
145 | private:
|
---|
146 |
|
---|
147 | #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
|
---|
148 | bool getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
149 | bool getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | #if defined(RT_OS_SOLARIS)
|
---|
153 | void parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
|
---|
154 | bool validateDevice(const char *deviceNode, bool isCDROM);
|
---|
155 | #endif
|
---|
156 |
|
---|
157 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
158 | void registerMetrics (PerformanceCollector *aCollector);
|
---|
159 | void unregisterMetrics (PerformanceCollector *aCollector);
|
---|
160 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
161 |
|
---|
162 | struct Data; // opaque data structure, defined in HostImpl.cpp
|
---|
163 | Data *m;
|
---|
164 | };
|
---|
165 |
|
---|
166 | #endif // ____H_HOSTIMPL
|
---|
167 |
|
---|