VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostImpl.h@ 16560

Last change on this file since 16560 was 16198, checked in by vboxsync, 15 years ago

HostNetIf API: added findHostNetworkInterfaceByName and findHostNetworkInterfaceById to IHost.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/* $Id: HostImpl.h 16198 2009-01-23 12:46:45Z vboxsync $ */
2/** @file
3 * Implemenation of IHost.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_HOSTIMPL
23#define ____H_HOSTIMPL
24
25#include "VirtualBoxBase.h"
26#ifdef VBOX_WITH_USB
27# include "HostUSBDeviceImpl.h"
28# include "USBDeviceFilterImpl.h"
29# include "USBProxyService.h"
30# include "VirtualBoxImpl.h"
31#else
32class USBProxyService;
33#endif
34#include "HostPower.h"
35
36#ifdef RT_OS_WINDOWS
37# include "win/svchlp.h"
38#endif
39
40#ifdef RT_OS_LINUX
41# include <HostHardwareLinux.h>
42#endif
43
44#ifdef VBOX_WITH_RESOURCE_USAGE_API
45# include "PerformanceImpl.h"
46#endif /* VBOX_WITH_RESOURCE_USAGE_API */
47
48class VirtualBox;
49class SessionMachine;
50class HostDVDDrive;
51class HostFloppyDrive;
52class Progress;
53
54#include <list>
55
56class ATL_NO_VTABLE Host :
57 public VirtualBoxBaseWithChildren,
58 public VirtualBoxSupportErrorInfoImpl <Host, IHost>,
59 public VirtualBoxSupportTranslation <Host>,
60 public IHost
61{
62public:
63
64 DECLARE_NOT_AGGREGATABLE(Host)
65
66 DECLARE_PROTECT_FINAL_CONSTRUCT()
67
68 BEGIN_COM_MAP(Host)
69 COM_INTERFACE_ENTRY(ISupportErrorInfo)
70 COM_INTERFACE_ENTRY(IHost)
71 END_COM_MAP()
72
73 NS_DECL_ISUPPORTS
74
75 HRESULT FinalConstruct();
76 void FinalRelease();
77
78 // public initializer/uninitializer for internal purposes only
79 HRESULT init (VirtualBox *aParent);
80 void uninit();
81
82 // IHost properties
83 STDMETHOD(COMGETTER(DVDDrives))(IHostDVDDriveCollection **drives);
84 STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
85 STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
86 STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters);
87 STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
88 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
89 STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
90 STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
91 STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
92 STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
93 STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
94 STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
95 STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
96 STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
97 STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
98
99 // IHost methods
100#ifdef RT_OS_WINDOWS
101 STDMETHOD(CreateHostNetworkInterface) (IN_BSTR aName,
102 IHostNetworkInterface **aHostNetworkInterface,
103 IProgress **aProgress);
104 STDMETHOD(RemoveHostNetworkInterface) (IN_GUID aId,
105 IHostNetworkInterface **aHostNetworkInterface,
106 IProgress **aProgress);
107#endif
108 STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
109 STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
110 STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
111
112 STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
113 STDMETHOD(FindHostNetworkInterfaceById) (IN_GUID id, IHostNetworkInterface **networkInterface);
114
115 // public methods only for internal purposes
116
117 HRESULT loadSettings (const settings::Key &aGlobal);
118 HRESULT saveSettings (settings::Key &aGlobal);
119
120#ifdef VBOX_WITH_USB
121 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
122
123 /** Must be called from under this object's lock. */
124 USBProxyService *usbProxyService() { return mUSBProxyService; }
125
126 HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
127 void getUSBFilters(USBDeviceFilterList *aGlobalFiltes, VirtualBox::SessionMachineVector *aMachines);
128 HRESULT checkUSBProxyService();
129#endif /* !VBOX_WITH_USB */
130
131#ifdef RT_OS_WINDOWS
132 static int networkInterfaceHelperServer (SVCHlpClient *aClient,
133 SVCHlpMsg::Code aMsgCode);
134#endif
135
136 // for VirtualBoxSupportErrorInfoImpl
137 static const wchar_t *getComponentName() { return L"Host"; }
138
139private:
140
141#if defined(RT_OS_SOLARIS)
142# if defined(VBOX_USE_LIBHAL)
143 bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list);
144 bool getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list);
145# endif
146 void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
147 bool validateDevice(const char *deviceNode, bool isCDROM);
148#endif
149
150#ifdef VBOX_WITH_USB
151 /** specialization for IHostUSBDeviceFilter */
152 ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
153 {
154 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
155 getDependentChild (ComPtr <IUnknown> (aFilter));
156 return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
157 : NULL;
158 }
159#endif /* VBOX_WITH_USB */
160
161#ifdef RT_OS_WINDOWS
162 static int createNetworkInterface (SVCHlpClient *aClient,
163 const Utf8Str &aName,
164 Guid &aGUID, Utf8Str &aErrMsg);
165 static int removeNetworkInterface (SVCHlpClient *aClient,
166 const Guid &aGUID,
167 Utf8Str &aErrMsg);
168 static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
169 Progress *aProgress,
170 void *aUser, int *aVrc);
171#endif
172
173#ifdef VBOX_WITH_RESOURCE_USAGE_API
174 void registerMetrics (PerformanceCollector *aCollector);
175 void unregisterMetrics (PerformanceCollector *aCollector);
176#endif /* VBOX_WITH_RESOURCE_USAGE_API */
177
178 ComObjPtr <VirtualBox, ComWeakRef> mParent;
179
180#ifdef VBOX_WITH_USB
181 USBDeviceFilterList mUSBDeviceFilters;
182
183 /** Pointer to the USBProxyService object. */
184 USBProxyService *mUSBProxyService;
185#endif /* VBOX_WITH_USB */
186
187#ifdef RT_OS_LINUX
188 /** Object with information about host drives */
189 VBoxMainDriveInfo mHostDrives;
190#endif
191 /* Features that can be queried with GetProcessorFeature */
192 BOOL fVTxAMDVSupported, fLongModeSupported, fPAESupported;
193
194 HostPowerService *mHostPowerService;
195};
196
197#endif // ____H_HOSTIMPL
198/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use