1 | /* $Id: HostImpl.h 101176 2023-09-19 16:57:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Implementation of IHost.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_HostImpl_h
|
---|
29 | #define MAIN_INCLUDED_HostImpl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "HostWrap.h"
|
---|
35 |
|
---|
36 | class HostUSBDeviceFilter;
|
---|
37 | class USBProxyService;
|
---|
38 | class SessionMachine;
|
---|
39 | class Progress;
|
---|
40 | class PerformanceCollector;
|
---|
41 | class HostDrive;
|
---|
42 | class HostDrivePartition;
|
---|
43 |
|
---|
44 | namespace settings
|
---|
45 | {
|
---|
46 | struct Host;
|
---|
47 | }
|
---|
48 |
|
---|
49 | #include <list>
|
---|
50 |
|
---|
51 | class ATL_NO_VTABLE Host :
|
---|
52 | public HostWrap
|
---|
53 | {
|
---|
54 | public:
|
---|
55 |
|
---|
56 | DECLARE_COMMON_CLASS_METHODS(Host)
|
---|
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 | // public methods only for internal purposes
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Override of the default locking class to be used for validating lock
|
---|
69 | * order with the standard member lock handle.
|
---|
70 | */
|
---|
71 | virtual VBoxLockingClass getLockingClass() const
|
---|
72 | {
|
---|
73 | return LOCKCLASS_HOSTOBJECT;
|
---|
74 | }
|
---|
75 |
|
---|
76 | HRESULT i_loadSettings(const settings::Host &data);
|
---|
77 | HRESULT i_saveSettings(settings::Host &data);
|
---|
78 |
|
---|
79 | void i_updateProcessorFeatures();
|
---|
80 |
|
---|
81 | HRESULT i_getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll, AutoWriteLock &treeLock);
|
---|
82 | HRESULT i_findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
83 | HRESULT i_findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
84 |
|
---|
85 | #ifdef VBOX_WITH_USB
|
---|
86 | typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
|
---|
87 |
|
---|
88 | /** Must be called from under this object's lock. */
|
---|
89 | USBProxyService* i_usbProxyService();
|
---|
90 |
|
---|
91 | HRESULT i_addChild(HostUSBDeviceFilter *pChild);
|
---|
92 | HRESULT i_removeChild(HostUSBDeviceFilter *pChild);
|
---|
93 | VirtualBox* i_parent();
|
---|
94 |
|
---|
95 | HRESULT i_onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
|
---|
96 | void i_getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
|
---|
97 | HRESULT i_checkUSBProxyService();
|
---|
98 | #endif /* !VBOX_WITH_USB */
|
---|
99 |
|
---|
100 | static void i_generateMACAddress(Utf8Str &mac);
|
---|
101 | static PlatformArchitecture_T s_getPlatformArchitecture();
|
---|
102 |
|
---|
103 | #ifdef RT_OS_WINDOWS
|
---|
104 | HRESULT i_updatePersistentConfigForHostOnlyAdapters(void);
|
---|
105 | HRESULT i_removePersistentConfig(const Bstr &bstrGuid);
|
---|
106 | #endif /* RT_OS_WINDOWS */
|
---|
107 |
|
---|
108 |
|
---|
109 | private:
|
---|
110 |
|
---|
111 | // wrapped IHost properties
|
---|
112 | HRESULT getArchitecture(PlatformArchitecture_T *platformArchitecture);
|
---|
113 | HRESULT getDVDDrives(std::vector<ComPtr<IMedium> > &aDVDDrives);
|
---|
114 | HRESULT getFloppyDrives(std::vector<ComPtr<IMedium> > &aFloppyDrives);
|
---|
115 | HRESULT getAudioDevices(std::vector<ComPtr<IHostAudioDevice> > &aAudioDevices);
|
---|
116 | HRESULT getUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices);
|
---|
117 | HRESULT getUSBDeviceFilters(std::vector<ComPtr<IHostUSBDeviceFilter> > &aUSBDeviceFilters);
|
---|
118 | HRESULT getNetworkInterfaces(std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
|
---|
119 | HRESULT getNameServers(std::vector<com::Utf8Str> &aNameServers);
|
---|
120 | HRESULT getDomainName(com::Utf8Str &aDomainName);
|
---|
121 | HRESULT getSearchStrings(std::vector<com::Utf8Str> &aSearchStrings);
|
---|
122 | HRESULT getProcessorCount(ULONG *aProcessorCount);
|
---|
123 | HRESULT getProcessorOnlineCount(ULONG *aProcessorOnlineCount);
|
---|
124 | HRESULT getProcessorCoreCount(ULONG *aProcessorCoreCount);
|
---|
125 | HRESULT getProcessorOnlineCoreCount(ULONG *aProcessorOnlineCoreCount);
|
---|
126 | HRESULT getHostDrives(std::vector<ComPtr<IHostDrive> > &aHostDrives);
|
---|
127 | HRESULT getMemorySize(ULONG *aMemorySize);
|
---|
128 | HRESULT getMemoryAvailable(ULONG *aMemoryAvailable);
|
---|
129 | HRESULT getOperatingSystem(com::Utf8Str &aOperatingSystem);
|
---|
130 | HRESULT getOSVersion(com::Utf8Str &aOSVersion);
|
---|
131 | HRESULT getUTCTime(LONG64 *aUTCTime);
|
---|
132 | HRESULT getAcceleration3DAvailable(BOOL *aAcceleration3DAvailable);
|
---|
133 | HRESULT getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices);
|
---|
134 | HRESULT getUpdateHost(ComPtr<IUpdateAgent> &aUpdate);
|
---|
135 | HRESULT getUpdateExtPack(ComPtr<IUpdateAgent> &aUpdate);
|
---|
136 | HRESULT getUpdateGuestAdditions(ComPtr<IUpdateAgent> &aUpdate);
|
---|
137 | HRESULT getUpdateResponse(BOOL *aUpdateNeeded);
|
---|
138 | HRESULT getUpdateVersion(com::Utf8Str &aUpdateVersion);
|
---|
139 | HRESULT getUpdateURL(com::Utf8Str &aUpdateURL);
|
---|
140 | HRESULT getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded);
|
---|
141 | HRESULT getX86(ComPtr<IHostX86> &aHostX86);
|
---|
142 |
|
---|
143 | // wrapped IHost methods
|
---|
144 | HRESULT getProcessorSpeed(ULONG aCpuId,
|
---|
145 | ULONG *aSpeed);
|
---|
146 | HRESULT getProcessorFeature(ProcessorFeature_T aFeature,
|
---|
147 | BOOL *aSupported);
|
---|
148 | HRESULT getProcessorDescription(ULONG aCpuId,
|
---|
149 | com::Utf8Str &aDescription);
|
---|
150 | HRESULT createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface,
|
---|
151 | ComPtr<IProgress> &aProgress);
|
---|
152 | HRESULT removeHostOnlyNetworkInterface(const com::Guid &aId,
|
---|
153 | ComPtr<IProgress> &aProgress);
|
---|
154 | HRESULT createUSBDeviceFilter(const com::Utf8Str &aName,
|
---|
155 | ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
156 | HRESULT insertUSBDeviceFilter(ULONG aPosition,
|
---|
157 | const ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
158 | HRESULT removeUSBDeviceFilter(ULONG aPosition);
|
---|
159 | HRESULT findHostDVDDrive(const com::Utf8Str &aName,
|
---|
160 | ComPtr<IMedium> &aDrive);
|
---|
161 | HRESULT findHostFloppyDrive(const com::Utf8Str &aName,
|
---|
162 | ComPtr<IMedium> &aDrive);
|
---|
163 | HRESULT findHostNetworkInterfaceByName(const com::Utf8Str &aName,
|
---|
164 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
165 | HRESULT findHostNetworkInterfaceById(const com::Guid &aId,
|
---|
166 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
167 | HRESULT findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType,
|
---|
168 | std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
|
---|
169 | HRESULT findUSBDeviceById(const com::Guid &aId,
|
---|
170 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
171 | HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
|
---|
172 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
173 | HRESULT generateMACAddress(com::Utf8Str &aAddress);
|
---|
174 |
|
---|
175 | HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress,
|
---|
176 | const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues);
|
---|
177 |
|
---|
178 | HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
|
---|
179 |
|
---|
180 | // Internal Methods.
|
---|
181 |
|
---|
182 | HRESULT i_buildDVDDrivesList(MediaList &list);
|
---|
183 | HRESULT i_buildFloppyDrivesList(MediaList &list);
|
---|
184 | HRESULT i_findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium);
|
---|
185 |
|
---|
186 | #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
|
---|
187 | bool i_getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
188 | bool i_getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
189 | HRESULT i_getFixedDrivesFromHal(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &list) RT_NOEXCEPT;
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | #if defined(RT_OS_SOLARIS)
|
---|
193 | void i_getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);
|
---|
194 | void i_parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
|
---|
195 | bool i_validateDevice(const char *deviceNode, bool isCDROM);
|
---|
196 | HRESULT i_getFixedDrivesFromDevTree(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &list) RT_NOEXCEPT;
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | HRESULT i_updateNetIfList();
|
---|
200 |
|
---|
201 | #ifndef RT_OS_WINDOWS
|
---|
202 | HRESULT i_parseResolvConf();
|
---|
203 | #else
|
---|
204 | HRESULT i_fetchNameResolvingInformation();
|
---|
205 | #endif
|
---|
206 |
|
---|
207 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
208 | void i_registerMetrics(PerformanceCollector *aCollector);
|
---|
209 | void i_registerDiskMetrics(PerformanceCollector *aCollector);
|
---|
210 | void i_unregisterMetrics(PerformanceCollector *aCollector);
|
---|
211 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
212 |
|
---|
213 | #ifdef RT_OS_WINDOWS
|
---|
214 | HRESULT i_getFixedDrivesFromGlobalNamespace(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &aDriveList) RT_NOEXCEPT;
|
---|
215 | #endif
|
---|
216 | HRESULT i_getDrivesPathsList(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &aDriveList) RT_NOEXCEPT;
|
---|
217 |
|
---|
218 | struct Data; // opaque data structure, defined in HostImpl.cpp
|
---|
219 | Data *m;
|
---|
220 | };
|
---|
221 |
|
---|
222 | #endif /* !MAIN_INCLUDED_HostImpl_h */
|
---|
223 |
|
---|