1 | /* $Id: HostImpl.h 81305 2019-10-17 10:23:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Implementation of IHost.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef MAIN_INCLUDED_HostImpl_h
|
---|
19 | #define MAIN_INCLUDED_HostImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "HostWrap.h"
|
---|
25 |
|
---|
26 | class HostUSBDeviceFilter;
|
---|
27 | class USBProxyService;
|
---|
28 | class SessionMachine;
|
---|
29 | class Progress;
|
---|
30 | class PerformanceCollector;
|
---|
31 |
|
---|
32 | namespace settings
|
---|
33 | {
|
---|
34 | struct Host;
|
---|
35 | }
|
---|
36 |
|
---|
37 | #include <list>
|
---|
38 |
|
---|
39 | class ATL_NO_VTABLE Host :
|
---|
40 | public HostWrap
|
---|
41 | {
|
---|
42 | public:
|
---|
43 |
|
---|
44 | DECLARE_EMPTY_CTOR_DTOR(Host)
|
---|
45 |
|
---|
46 | HRESULT FinalConstruct();
|
---|
47 | void FinalRelease();
|
---|
48 |
|
---|
49 | // public initializer/uninitializer for internal purposes only
|
---|
50 | HRESULT init(VirtualBox *aParent);
|
---|
51 | void uninit();
|
---|
52 |
|
---|
53 | // public methods only for internal purposes
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Override of the default locking class to be used for validating lock
|
---|
57 | * order with the standard member lock handle.
|
---|
58 | */
|
---|
59 | virtual VBoxLockingClass getLockingClass() const
|
---|
60 | {
|
---|
61 | return LOCKCLASS_HOSTOBJECT;
|
---|
62 | }
|
---|
63 |
|
---|
64 | HRESULT i_loadSettings(const settings::Host &data);
|
---|
65 | HRESULT i_saveSettings(settings::Host &data);
|
---|
66 |
|
---|
67 | void i_updateProcessorFeatures();
|
---|
68 |
|
---|
69 | HRESULT i_getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll, AutoWriteLock &treeLock);
|
---|
70 | HRESULT i_findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
71 | HRESULT i_findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
72 |
|
---|
73 | #ifdef VBOX_WITH_USB
|
---|
74 | typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
|
---|
75 |
|
---|
76 | /** Must be called from under this object's lock. */
|
---|
77 | USBProxyService* i_usbProxyService();
|
---|
78 |
|
---|
79 | HRESULT i_addChild(HostUSBDeviceFilter *pChild);
|
---|
80 | HRESULT i_removeChild(HostUSBDeviceFilter *pChild);
|
---|
81 | VirtualBox* i_parent();
|
---|
82 |
|
---|
83 | HRESULT i_onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
|
---|
84 | void i_getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
|
---|
85 | HRESULT i_checkUSBProxyService();
|
---|
86 | #endif /* !VBOX_WITH_USB */
|
---|
87 |
|
---|
88 | static void i_generateMACAddress(Utf8Str &mac);
|
---|
89 |
|
---|
90 | #ifdef RT_OS_WINDOWS
|
---|
91 | HRESULT i_updatePersistentConfigForHostOnlyAdapters(void);
|
---|
92 | HRESULT i_removePersistentConfig(const Bstr &bstrGuid);
|
---|
93 | #endif /* RT_OS_WINDOWS */
|
---|
94 |
|
---|
95 |
|
---|
96 | private:
|
---|
97 |
|
---|
98 | // wrapped IHost properties
|
---|
99 | HRESULT getDVDDrives(std::vector<ComPtr<IMedium> > &aDVDDrives);
|
---|
100 | HRESULT getFloppyDrives(std::vector<ComPtr<IMedium> > &aFloppyDrives);
|
---|
101 | HRESULT getUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices);
|
---|
102 | HRESULT getUSBDeviceFilters(std::vector<ComPtr<IHostUSBDeviceFilter> > &aUSBDeviceFilters);
|
---|
103 | HRESULT getNetworkInterfaces(std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
|
---|
104 | HRESULT getNameServers(std::vector<com::Utf8Str> &aNameServers);
|
---|
105 | HRESULT getDomainName(com::Utf8Str &aDomainName);
|
---|
106 | HRESULT getSearchStrings(std::vector<com::Utf8Str> &aSearchStrings);
|
---|
107 | HRESULT getProcessorCount(ULONG *aProcessorCount);
|
---|
108 | HRESULT getProcessorOnlineCount(ULONG *aProcessorOnlineCount);
|
---|
109 | HRESULT getProcessorCoreCount(ULONG *aProcessorCoreCount);
|
---|
110 | HRESULT getProcessorOnlineCoreCount(ULONG *aProcessorOnlineCoreCount);
|
---|
111 | HRESULT getMemorySize(ULONG *aMemorySize);
|
---|
112 | HRESULT getMemoryAvailable(ULONG *aMemoryAvailable);
|
---|
113 | HRESULT getOperatingSystem(com::Utf8Str &aOperatingSystem);
|
---|
114 | HRESULT getOSVersion(com::Utf8Str &aOSVersion);
|
---|
115 | HRESULT getUTCTime(LONG64 *aUTCTime);
|
---|
116 | HRESULT getAcceleration3DAvailable(BOOL *aAcceleration3DAvailable);
|
---|
117 | HRESULT getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices);
|
---|
118 |
|
---|
119 | // wrapped IHost methods
|
---|
120 | HRESULT getProcessorSpeed(ULONG aCpuId,
|
---|
121 | ULONG *aSpeed);
|
---|
122 | HRESULT getProcessorFeature(ProcessorFeature_T aFeature,
|
---|
123 | BOOL *aSupported);
|
---|
124 | HRESULT getProcessorDescription(ULONG aCpuId,
|
---|
125 | com::Utf8Str &aDescription);
|
---|
126 | HRESULT getProcessorCPUIDLeaf(ULONG aCpuId,
|
---|
127 | ULONG aLeaf,
|
---|
128 | ULONG aSubLeaf,
|
---|
129 | ULONG *aValEax,
|
---|
130 | ULONG *aValEbx,
|
---|
131 | ULONG *aValEcx,
|
---|
132 | ULONG *aValEdx);
|
---|
133 | HRESULT createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface,
|
---|
134 | ComPtr<IProgress> &aProgress);
|
---|
135 | HRESULT removeHostOnlyNetworkInterface(const com::Guid &aId,
|
---|
136 | ComPtr<IProgress> &aProgress);
|
---|
137 | HRESULT createUSBDeviceFilter(const com::Utf8Str &aName,
|
---|
138 | ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
139 | HRESULT insertUSBDeviceFilter(ULONG aPosition,
|
---|
140 | const ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
141 | HRESULT removeUSBDeviceFilter(ULONG aPosition);
|
---|
142 | HRESULT findHostDVDDrive(const com::Utf8Str &aName,
|
---|
143 | ComPtr<IMedium> &aDrive);
|
---|
144 | HRESULT findHostFloppyDrive(const com::Utf8Str &aName,
|
---|
145 | ComPtr<IMedium> &aDrive);
|
---|
146 | HRESULT findHostNetworkInterfaceByName(const com::Utf8Str &aName,
|
---|
147 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
148 | HRESULT findHostNetworkInterfaceById(const com::Guid &aId,
|
---|
149 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
150 | HRESULT findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType,
|
---|
151 | std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
|
---|
152 | HRESULT findUSBDeviceById(const com::Guid &aId,
|
---|
153 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
154 | HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
|
---|
155 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
156 | HRESULT generateMACAddress(com::Utf8Str &aAddress);
|
---|
157 |
|
---|
158 | HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress,
|
---|
159 | const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues);
|
---|
160 |
|
---|
161 | HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
|
---|
162 |
|
---|
163 | // Internal Methods.
|
---|
164 |
|
---|
165 | HRESULT i_buildDVDDrivesList(MediaList &list);
|
---|
166 | HRESULT i_buildFloppyDrivesList(MediaList &list);
|
---|
167 | HRESULT i_findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium);
|
---|
168 |
|
---|
169 | #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
|
---|
170 | bool i_getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
171 | bool i_getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | #if defined(RT_OS_SOLARIS)
|
---|
175 | void i_getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);
|
---|
176 | void i_parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
|
---|
177 | bool i_validateDevice(const char *deviceNode, bool isCDROM);
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | HRESULT i_updateNetIfList();
|
---|
181 |
|
---|
182 | #ifndef RT_OS_WINDOWS
|
---|
183 | HRESULT i_parseResolvConf();
|
---|
184 | #else
|
---|
185 | HRESULT i_fetchNameResolvingInformation();
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
189 | void i_registerMetrics(PerformanceCollector *aCollector);
|
---|
190 | void i_registerDiskMetrics(PerformanceCollector *aCollector);
|
---|
191 | void i_unregisterMetrics(PerformanceCollector *aCollector);
|
---|
192 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
193 |
|
---|
194 | struct Data; // opaque data structure, defined in HostImpl.cpp
|
---|
195 | Data *m;
|
---|
196 | };
|
---|
197 |
|
---|
198 | #endif /* !MAIN_INCLUDED_HostImpl_h */
|
---|
199 |
|
---|