1 | /* $Id: HostImpl.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Implementation of IHost.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 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 | HRESULT getUpdate(ComPtr<IHostUpdate> &aUpdate);
|
---|
119 |
|
---|
120 | // wrapped IHost methods
|
---|
121 | HRESULT getProcessorSpeed(ULONG aCpuId,
|
---|
122 | ULONG *aSpeed);
|
---|
123 | HRESULT getProcessorFeature(ProcessorFeature_T aFeature,
|
---|
124 | BOOL *aSupported);
|
---|
125 | HRESULT getProcessorDescription(ULONG aCpuId,
|
---|
126 | com::Utf8Str &aDescription);
|
---|
127 | HRESULT getProcessorCPUIDLeaf(ULONG aCpuId,
|
---|
128 | ULONG aLeaf,
|
---|
129 | ULONG aSubLeaf,
|
---|
130 | ULONG *aValEax,
|
---|
131 | ULONG *aValEbx,
|
---|
132 | ULONG *aValEcx,
|
---|
133 | ULONG *aValEdx);
|
---|
134 | HRESULT createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface,
|
---|
135 | ComPtr<IProgress> &aProgress);
|
---|
136 | HRESULT removeHostOnlyNetworkInterface(const com::Guid &aId,
|
---|
137 | ComPtr<IProgress> &aProgress);
|
---|
138 | HRESULT createUSBDeviceFilter(const com::Utf8Str &aName,
|
---|
139 | ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
140 | HRESULT insertUSBDeviceFilter(ULONG aPosition,
|
---|
141 | const ComPtr<IHostUSBDeviceFilter> &aFilter);
|
---|
142 | HRESULT removeUSBDeviceFilter(ULONG aPosition);
|
---|
143 | HRESULT findHostDVDDrive(const com::Utf8Str &aName,
|
---|
144 | ComPtr<IMedium> &aDrive);
|
---|
145 | HRESULT findHostFloppyDrive(const com::Utf8Str &aName,
|
---|
146 | ComPtr<IMedium> &aDrive);
|
---|
147 | HRESULT findHostNetworkInterfaceByName(const com::Utf8Str &aName,
|
---|
148 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
149 | HRESULT findHostNetworkInterfaceById(const com::Guid &aId,
|
---|
150 | ComPtr<IHostNetworkInterface> &aNetworkInterface);
|
---|
151 | HRESULT findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType,
|
---|
152 | std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
|
---|
153 | HRESULT findUSBDeviceById(const com::Guid &aId,
|
---|
154 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
155 | HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
|
---|
156 | ComPtr<IHostUSBDevice> &aDevice);
|
---|
157 | HRESULT generateMACAddress(com::Utf8Str &aAddress);
|
---|
158 |
|
---|
159 | HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress,
|
---|
160 | const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues);
|
---|
161 |
|
---|
162 | HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
|
---|
163 |
|
---|
164 | // Internal Methods.
|
---|
165 |
|
---|
166 | HRESULT i_buildDVDDrivesList(MediaList &list);
|
---|
167 | HRESULT i_buildFloppyDrivesList(MediaList &list);
|
---|
168 | HRESULT i_findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium);
|
---|
169 |
|
---|
170 | #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
|
---|
171 | bool i_getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
172 | bool i_getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
173 | #endif
|
---|
174 |
|
---|
175 | #if defined(RT_OS_SOLARIS)
|
---|
176 | void i_getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);
|
---|
177 | void i_parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
|
---|
178 | bool i_validateDevice(const char *deviceNode, bool isCDROM);
|
---|
179 | #endif
|
---|
180 |
|
---|
181 | HRESULT i_updateNetIfList();
|
---|
182 |
|
---|
183 | #ifndef RT_OS_WINDOWS
|
---|
184 | HRESULT i_parseResolvConf();
|
---|
185 | #else
|
---|
186 | HRESULT i_fetchNameResolvingInformation();
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
190 | void i_registerMetrics(PerformanceCollector *aCollector);
|
---|
191 | void i_registerDiskMetrics(PerformanceCollector *aCollector);
|
---|
192 | void i_unregisterMetrics(PerformanceCollector *aCollector);
|
---|
193 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
194 |
|
---|
195 | struct Data; // opaque data structure, defined in HostImpl.cpp
|
---|
196 | Data *m;
|
---|
197 | };
|
---|
198 |
|
---|
199 | #endif /* !MAIN_INCLUDED_HostImpl_h */
|
---|
200 |
|
---|