VirtualBox

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

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

Attempt at making OSE build again.

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

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