VirtualBox

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

Last change on this file since 19115 was 19115, checked in by vboxsync, 16 years ago

Enabling create/destroy host-only interfaces in Main API for all platforms.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: HostImpl.h 19115 2009-04-22 17:22:45Z vboxsync $ */
2/** @file
3 * Implemenation of IHost.
4 */
5
6/*
7 * Copyright (C) 2006-2009 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_LINUX
37# include <HostHardwareLinux.h>
38#endif
39
40#ifdef VBOX_WITH_RESOURCE_USAGE_API
41# include "PerformanceImpl.h"
42#endif /* VBOX_WITH_RESOURCE_USAGE_API */
43
44class VirtualBox;
45class SessionMachine;
46class HostDVDDrive;
47class HostFloppyDrive;
48class Progress;
49
50#include <list>
51
52class ATL_NO_VTABLE Host :
53 public VirtualBoxBaseWithChildren,
54 public VirtualBoxSupportErrorInfoImpl <Host, IHost>,
55 public VirtualBoxSupportTranslation <Host>,
56 public IHost
57{
58public:
59
60 DECLARE_NOT_AGGREGATABLE(Host)
61
62 DECLARE_PROTECT_FINAL_CONSTRUCT()
63
64 BEGIN_COM_MAP(Host)
65 COM_INTERFACE_ENTRY(ISupportErrorInfo)
66 COM_INTERFACE_ENTRY(IHost)
67 END_COM_MAP()
68
69 NS_DECL_ISUPPORTS
70
71 HRESULT FinalConstruct();
72 void FinalRelease();
73
74 // public initializer/uninitializer for internal purposes only
75 HRESULT init (VirtualBox *aParent);
76 void uninit();
77
78 // IHost properties
79 STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IHostDVDDrive*, drives));
80 STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IHostFloppyDrive*, drives));
81 STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
82 STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
83 STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
84 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
85 STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
86 STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
87 STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
88 STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
89 STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
90 STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
91 STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
92 STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
93 STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
94
95 // IHost methods
96#if defined(RT_OS_WINDOWS) || defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
97
98 STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
99 IProgress **aProgress);
100 STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_GUID aId,
101 IHostNetworkInterface **aHostNetworkInterface,
102 IProgress **aProgress);
103#endif
104 STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
105 STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
106 STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
107
108 STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IHostDVDDrive **aDrive);
109 STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IHostFloppyDrive **aDrive);
110 STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
111 STDMETHOD(FindHostNetworkInterfaceById) (IN_GUID id, IHostNetworkInterface **networkInterface);
112 STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
113 STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
114 STDMETHOD(FindUSBDeviceById) (IN_GUID aId, IHostUSBDevice **aDevice);
115
116 // public methods only for internal purposes
117
118 HRESULT loadSettings (const settings::Key &aGlobal);
119 HRESULT saveSettings (settings::Key &aGlobal);
120
121#ifdef VBOX_WITH_USB
122 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
123
124 /** Must be called from under this object's lock. */
125 USBProxyService *usbProxyService() { return mUSBProxyService; }
126
127 HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
128 void getUSBFilters(USBDeviceFilterList *aGlobalFiltes, VirtualBox::SessionMachineVector *aMachines);
129 HRESULT checkUSBProxyService();
130#endif /* !VBOX_WITH_USB */
131
132 // for VirtualBoxSupportErrorInfoImpl
133 static const wchar_t *getComponentName() { return L"Host"; }
134
135private:
136
137#if defined(RT_OS_SOLARIS)
138# if defined(VBOX_USE_LIBHAL)
139 bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list);
140 bool getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list);
141# endif
142 void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
143 bool validateDevice(const char *deviceNode, bool isCDROM);
144#endif
145
146#ifdef VBOX_WITH_USB
147 /** specialization for IHostUSBDeviceFilter */
148 ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
149 {
150 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
151 getDependentChild (ComPtr <IUnknown> (aFilter));
152 return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
153 : NULL;
154 }
155#endif /* VBOX_WITH_USB */
156
157#ifdef VBOX_WITH_RESOURCE_USAGE_API
158 void registerMetrics (PerformanceCollector *aCollector);
159 void unregisterMetrics (PerformanceCollector *aCollector);
160#endif /* VBOX_WITH_RESOURCE_USAGE_API */
161
162 ComObjPtr <VirtualBox, ComWeakRef> mParent;
163
164#ifdef VBOX_WITH_USB
165 USBDeviceFilterList mUSBDeviceFilters;
166
167 /** Pointer to the USBProxyService object. */
168 USBProxyService *mUSBProxyService;
169#endif /* VBOX_WITH_USB */
170
171#ifdef RT_OS_LINUX
172 /** Object with information about host drives */
173 VBoxMainDriveInfo mHostDrives;
174#endif
175 /* Features that can be queried with GetProcessorFeature */
176 BOOL fVTxAMDVSupported, fLongModeSupported, fPAESupported;
177
178 HostPowerService *mHostPowerService;
179};
180
181#endif // ____H_HOSTIMPL
182/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette