1 | /* $Id: HostImpl.h 46969 2013-07-04 06:35:01Z 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 "VirtualBoxBase.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 VirtualBoxBase,
|
---|
38 | VBOX_SCRIPTABLE_IMPL(IHost)
|
---|
39 | {
|
---|
40 | public:
|
---|
41 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Host, IHost)
|
---|
42 |
|
---|
43 | DECLARE_NOT_AGGREGATABLE(Host)
|
---|
44 |
|
---|
45 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
46 |
|
---|
47 | BEGIN_COM_MAP(Host)
|
---|
48 | VBOX_DEFAULT_INTERFACE_ENTRIES(IHost)
|
---|
49 | END_COM_MAP()
|
---|
50 |
|
---|
51 | HRESULT FinalConstruct();
|
---|
52 | void FinalRelease();
|
---|
53 |
|
---|
54 | // public initializer/uninitializer for internal purposes only
|
---|
55 | HRESULT init(VirtualBox *aParent);
|
---|
56 | void uninit();
|
---|
57 |
|
---|
58 | // IHost properties
|
---|
59 | STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut(IMedium *, drives));
|
---|
60 | STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut(IMedium *, drives));
|
---|
61 | STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IHostUSBDevice *, aUSBDevices));
|
---|
62 | STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut(IHostUSBDeviceFilter *, aUSBDeviceFilters));
|
---|
63 | STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
|
---|
64 | STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
|
---|
65 | STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
|
---|
66 | STDMETHOD(COMGETTER(ProcessorCoreCount))(ULONG *count);
|
---|
67 | STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
|
---|
68 | STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
|
---|
69 | STDMETHOD(GetProcessorFeature)(ProcessorFeature_T feature, BOOL *supported);
|
---|
70 | STDMETHOD(GetProcessorCPUIDLeaf)(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX);
|
---|
71 | STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
|
---|
72 | STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
|
---|
73 | STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
|
---|
74 | STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
|
---|
75 | STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
|
---|
76 | STDMETHOD(COMGETTER(Acceleration3DAvailable))(BOOL *aSupported);
|
---|
77 |
|
---|
78 | // IHost methods
|
---|
79 | STDMETHOD(CreateHostOnlyNetworkInterface)(IHostNetworkInterface **aHostNetworkInterface,
|
---|
80 | IProgress **aProgress);
|
---|
81 | STDMETHOD(RemoveHostOnlyNetworkInterface)(IN_BSTR aId, IProgress **aProgress);
|
---|
82 | STDMETHOD(CreateUSBDeviceFilter)(IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
|
---|
83 | STDMETHOD(InsertUSBDeviceFilter)(ULONG aPosition, IHostUSBDeviceFilter *aFilter);
|
---|
84 | STDMETHOD(RemoveUSBDeviceFilter)(ULONG aPosition);
|
---|
85 |
|
---|
86 | STDMETHOD(FindHostDVDDrive)(IN_BSTR aName, IMedium **aDrive);
|
---|
87 | STDMETHOD(FindHostFloppyDrive)(IN_BSTR aName, IMedium **aDrive);
|
---|
88 | STDMETHOD(FindHostNetworkInterfaceByName)(IN_BSTR aName, IHostNetworkInterface **networkInterface);
|
---|
89 | STDMETHOD(FindHostNetworkInterfaceById)(IN_BSTR id, IHostNetworkInterface **networkInterface);
|
---|
90 | STDMETHOD(FindHostNetworkInterfacesOfType)(HostNetworkInterfaceType_T type, ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
|
---|
91 | STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IHostUSBDevice **aDevice);
|
---|
92 | STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IHostUSBDevice **aDevice);
|
---|
93 | STDMETHOD(GenerateMACAddress)(BSTR *aAddress);
|
---|
94 |
|
---|
95 | // public methods only for internal purposes
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Override of the default locking class to be used for validating lock
|
---|
99 | * order with the standard member lock handle.
|
---|
100 | */
|
---|
101 | virtual VBoxLockingClass getLockingClass() const
|
---|
102 | {
|
---|
103 | return LOCKCLASS_HOSTOBJECT;
|
---|
104 | }
|
---|
105 |
|
---|
106 | HRESULT loadSettings(const settings::Host &data);
|
---|
107 | HRESULT saveSettings(settings::Host &data);
|
---|
108 |
|
---|
109 | HRESULT getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll);
|
---|
110 | HRESULT findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
111 | HRESULT findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);
|
---|
112 |
|
---|
113 | #ifdef VBOX_WITH_USB
|
---|
114 | typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
|
---|
115 |
|
---|
116 | /** Must be called from under this object's lock. */
|
---|
117 | USBProxyService* usbProxyService();
|
---|
118 |
|
---|
119 | HRESULT addChild(HostUSBDeviceFilter *pChild);
|
---|
120 | HRESULT removeChild(HostUSBDeviceFilter *pChild);
|
---|
121 | VirtualBox* parent();
|
---|
122 |
|
---|
123 | HRESULT onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
|
---|
124 | void getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
|
---|
125 | HRESULT checkUSBProxyService();
|
---|
126 | #endif /* !VBOX_WITH_USB */
|
---|
127 |
|
---|
128 | static void generateMACAddress(Utf8Str &mac);
|
---|
129 |
|
---|
130 | private:
|
---|
131 |
|
---|
132 | HRESULT buildDVDDrivesList(MediaList &list);
|
---|
133 | HRESULT buildFloppyDrivesList(MediaList &list);
|
---|
134 | HRESULT findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium);
|
---|
135 |
|
---|
136 | #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
|
---|
137 | bool getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
138 | bool getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | #if defined(RT_OS_SOLARIS)
|
---|
142 | void getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);
|
---|
143 | void parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
|
---|
144 | bool validateDevice(const char *deviceNode, bool isCDROM);
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | HRESULT updateNetIfList();
|
---|
148 |
|
---|
149 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
150 | void registerMetrics(PerformanceCollector *aCollector);
|
---|
151 | void registerDiskMetrics(PerformanceCollector *aCollector);
|
---|
152 | void unregisterMetrics(PerformanceCollector *aCollector);
|
---|
153 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
154 |
|
---|
155 | struct Data; // opaque data structure, defined in HostImpl.cpp
|
---|
156 | Data *m;
|
---|
157 | };
|
---|
158 |
|
---|
159 | #endif // ____H_HOSTIMPL
|
---|
160 |
|
---|