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