VirtualBox

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

Last change on this file since 10146 was 9937, checked in by vboxsync, 17 years ago

Main: Corrected getProcessorUsage() impl (docs, spacing etc).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/* $Id: HostImpl.h 9937 2008-06-25 18:18:13Z 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
35#ifdef RT_OS_WINDOWS
36# include "win/svchlp.h"
37#endif
38
39#ifdef VBOX_WITH_RESOURCE_USAGE_API
40#include "iprt/timer.h"
41#include "iprt/system.h"
42
43/* Each second we obtain new CPU load stats. */
44#define VBOX_USAGE_SAMPLER_INTERVAL 1000
45#endif /* VBOX_WITH_RESOURCE_USAGE_API */
46
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 *parent);
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#ifdef RT_OS_WINDOWS
88 STDMETHOD(COMGETTER(NetworkInterfaces))(IHostNetworkInterfaceCollection **networkInterfaces);
89#endif
90 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
91 STDMETHOD(COMGETTER(ProcessorSpeed))(ULONG *speed);
92 STDMETHOD(COMGETTER(ProcessorDescription))(BSTR *description);
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) (INPTR BSTR aName,
102 IHostNetworkInterface **aHostNetworkInterface,
103 IProgress **aProgress);
104 STDMETHOD(RemoveHostNetworkInterface) (INPTR GUIDPARAM aId,
105 IHostNetworkInterface **aHostNetworkInterface,
106 IProgress **aProgress);
107#endif
108 STDMETHOD(CreateUSBDeviceFilter) (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter);
109 STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
110 STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
111
112 STDMETHOD(GetProcessorUsage) (ULONG *aUser, ULONG *aSystem, ULONG *aIdle);
113
114 // public methods only for internal purposes
115
116 HRESULT loadSettings (const settings::Key &aGlobal);
117 HRESULT saveSettings (settings::Key &aGlobal);
118
119#ifdef VBOX_WITH_USB
120 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
121
122 /** Must be called from under this object's lock. */
123 USBProxyService *usbProxyService() { return mUSBProxyService; }
124
125 HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
126 void getUSBFilters(USBDeviceFilterList *aGlobalFiltes, VirtualBox::SessionMachineVector *aMachines);
127 HRESULT checkUSBProxyService();
128#endif /* !VBOX_WITH_USB */
129
130#ifdef RT_OS_WINDOWS
131 static int networkInterfaceHelperServer (SVCHlpClient *aClient,
132 SVCHlpMsg::Code aMsgCode);
133#endif
134
135 // for VirtualBoxSupportErrorInfoImpl
136 static const wchar_t *getComponentName() { return L"Host"; }
137
138private:
139
140#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
141# ifdef VBOX_USE_LIBHAL
142 bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list);
143 bool getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list);
144# endif
145 void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
146 bool validateDevice(const char *deviceNode, bool isCDROM);
147#endif
148
149#ifdef VBOX_WITH_USB
150 /** specialization for IHostUSBDeviceFilter */
151 ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
152 {
153 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
154 getDependentChild (ComPtr <IUnknown> (aFilter));
155 return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
156 : NULL;
157 }
158#endif /* VBOX_WITH_USB */
159
160#ifdef RT_OS_WINDOWS
161 static int createNetworkInterface (SVCHlpClient *aClient,
162 const Utf8Str &aName,
163 Guid &aGUID, Utf8Str &aErrMsg);
164 static int removeNetworkInterface (SVCHlpClient *aClient,
165 const Guid &aGUID,
166 Utf8Str &aErrMsg);
167 static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
168 Progress *aProgress,
169 void *aUser, int *aVrc);
170#endif
171
172#ifdef VBOX_WITH_RESOURCE_USAGE_API
173 /** Static timer callback. */
174 static void UsageSamplerCallback (PRTTIMER pTimer, void *pvUser, uint64_t iTick);
175 /** Member timer callback. */
176 void usageSamplerCallback();
177#endif /* VBOX_WITH_RESOURCE_USAGE_API */
178
179 ComObjPtr <VirtualBox, ComWeakRef> mParent;
180
181#ifdef VBOX_WITH_USB
182 USBDeviceFilterList mUSBDeviceFilters;
183
184 /** Pointer to the USBProxyService object. */
185 USBProxyService *mUSBProxyService;
186#endif /* VBOX_WITH_USB */
187
188#ifdef VBOX_WITH_RESOURCE_USAGE_API
189 /** Pointer to the usage sampling timer. */
190 PRTTIMER mUsageSampler;
191 /** Structure to hold processor usage stats. */
192 RTCPUUSAGESTATS mCpuStats;
193#endif /* VBOX_WITH_RESOURCE_USAGE_API */
194};
195
196#endif // ____H_HOSTIMPL
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