VirtualBox

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

Last change on this file since 4041 was 3668, checked in by vboxsync, 17 years ago

replace underscore symbols in Main/

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef ____H_HOSTIMPL
23#define ____H_HOSTIMPL
24
25#include "VirtualBoxBase.h"
26#include "HostUSBDeviceImpl.h"
27#include "USBDeviceFilterImpl.h"
28
29#ifdef RT_OS_WINDOWS
30#include "win32/svchlp.h"
31#endif
32
33#include <VBox/cfgldr.h>
34
35class VirtualBox;
36class SessionMachine;
37class HostDVDDrive;
38class HostFloppyDrive;
39class Progress;
40
41#include <list>
42
43class ATL_NO_VTABLE Host :
44 public VirtualBoxBaseWithChildren,
45 public VirtualBoxSupportErrorInfoImpl <Host, IHost>,
46 public VirtualBoxSupportTranslation <Host>,
47 public IHost
48{
49public:
50
51 DECLARE_NOT_AGGREGATABLE(Host)
52
53 DECLARE_PROTECT_FINAL_CONSTRUCT()
54
55 BEGIN_COM_MAP(Host)
56 COM_INTERFACE_ENTRY(ISupportErrorInfo)
57 COM_INTERFACE_ENTRY(IHost)
58 END_COM_MAP()
59
60 NS_DECL_ISUPPORTS
61
62 HRESULT FinalConstruct();
63 void FinalRelease();
64
65 // public initializer/uninitializer for internal purposes only
66 HRESULT init (VirtualBox *parent);
67 void uninit();
68
69 // IHost properties
70 STDMETHOD(COMGETTER(DVDDrives))(IHostDVDDriveCollection **drives);
71 STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
72 STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
73 STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters);
74#ifdef RT_OS_WINDOWS
75 STDMETHOD(COMGETTER(NetworkInterfaces))(IHostNetworkInterfaceCollection **networkInterfaces);
76#endif
77 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
78 STDMETHOD(COMGETTER(ProcessorSpeed))(ULONG *speed);
79 STDMETHOD(COMGETTER(ProcessorDescription))(BSTR *description);
80 STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
81 STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
82 STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
83 STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
84 STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
85
86 // IHost methods
87#ifdef RT_OS_WINDOWS
88 STDMETHOD(CreateHostNetworkInterface) (INPTR BSTR aName,
89 IHostNetworkInterface **aHostNetworkInterface,
90 IProgress **aProgress);
91 STDMETHOD(RemoveHostNetworkInterface) (INPTR GUIDPARAM aId,
92 IHostNetworkInterface **aHostNetworkInterface,
93 IProgress **aProgress);
94#endif
95 STDMETHOD(CreateUSBDeviceFilter) (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter);
96 STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
97 STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
98
99 // public methods only for internal purposes
100
101 HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter,
102 BOOL aActiveChanged = FALSE);
103
104 HRESULT loadSettings (CFGNODE aGlobal);
105 HRESULT saveSettings (CFGNODE aGlobal);
106
107 HRESULT captureUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId);
108 HRESULT detachUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId, BOOL aDone);
109 HRESULT autoCaptureUSBDevices (SessionMachine *aMachine);
110 HRESULT detachAllUSBDevices (SessionMachine *aMachine, BOOL aDone);
111
112 void onUSBDeviceAttached (HostUSBDevice *aDevice);
113 void onUSBDeviceDetached (HostUSBDevice *aDevice);
114 void onUSBDeviceStateChanged (HostUSBDevice *aDevice);
115
116 HRESULT checkUSBProxyService();
117
118 /* must be called from under this object's lock */
119 USBProxyService *usbProxyService() { return mUSBProxyService; }
120
121#ifdef RT_OS_WINDOWS
122 static int networkInterfaceHelperServer (SVCHlpClient *aClient,
123 SVCHlpMsg::Code aMsgCode);
124#endif
125
126 // for VirtualBoxSupportErrorInfoImpl
127 static const wchar_t *getComponentName() { return L"Host"; }
128
129private:
130
131#ifdef RT_OS_LINUX
132# ifdef VBOX_USE_LIBHAL
133 bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list);
134 bool getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list);
135# endif
136 void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
137 bool validateDevice(const char *deviceNode, bool isCDROM);
138#endif
139
140 /** specialization for IHostUSBDeviceFilter */
141 ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
142 {
143 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
144 getDependentChild (ComPtr <IUnknown> (aFilter));
145 return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
146 : NULL;
147 }
148
149 HRESULT applyAllUSBFilters (ComObjPtr <HostUSBDevice> &aDevice,
150 SessionMachine *aMachine = NULL);
151
152 bool applyMachineUSBFilters (SessionMachine *aMachine,
153 ComObjPtr <HostUSBDevice> &aDevice);
154
155#ifdef RT_OS_WINDOWS
156 static int createNetworkInterface (SVCHlpClient *aClient,
157 const Utf8Str &aName,
158 Guid &aGUID, Utf8Str &aErrMsg);
159 static int removeNetworkInterface (SVCHlpClient *aClient,
160 const Guid &aGUID,
161 Utf8Str &aErrMsg);
162 static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
163 Progress *aProgress,
164 void *aUser, int *aVrc);
165#endif
166
167 ComObjPtr <VirtualBox, ComWeakRef> mParent;
168
169 typedef std::list <ComObjPtr <HostUSBDevice> > USBDeviceList;
170 USBDeviceList mUSBDevices;
171
172 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
173 USBDeviceFilterList mUSBDeviceFilters;
174
175 /** Pointer to the USBProxyService object. */
176 USBProxyService *mUSBProxyService;
177};
178
179#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