VirtualBox

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

Last change on this file since 2957 was 2957, checked in by vboxsync, 18 years ago

Made IHostFloppyDrive use libhal on Linux and added UDI strings to the host floppy and DVD devices

  • 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 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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 __WIN__
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 __WIN__
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 __WIN__
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 IUSBDevice **aHostDevice);
109 HRESULT releaseUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId);
110 HRESULT autoCaptureUSBDevices (SessionMachine *aMachine,
111 IUSBDeviceCollection **aHostDevices);
112 HRESULT releaseAllUSBDevices (SessionMachine *aMachine);
113
114 void onUSBDeviceAttached (HostUSBDevice *aDevice);
115 void onUSBDeviceDetached (HostUSBDevice *aDevice);
116 void onUSBDeviceStateChanged (HostUSBDevice *aDevice);
117
118 HRESULT checkUSBProxyService();
119
120 /* must be called from under this object's lock */
121 USBProxyService *usbProxyService() { return mUSBProxyService; }
122
123#ifdef __WIN__
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#ifdef __LINUX__
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 /** specialization for IHostUSBDeviceFilter */
143 ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
144 {
145 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
146 getDependentChild (ComPtr <IUnknown> (aFilter));
147 return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
148 : NULL;
149 }
150
151 HRESULT applyAllUSBFilters (ComObjPtr <HostUSBDevice> &aDevice,
152 SessionMachine *aMachine = NULL);
153 void applyMachineUSBFilters (SessionMachine *aMachine,
154 ComObjPtr <HostUSBDevice> &aDevice);
155
156#ifdef __WIN__
157 static int createNetworkInterface (SVCHlpClient *aClient,
158 const Utf8Str &aName,
159 Guid &aGUID, Utf8Str &aErrMsg);
160 static int removeNetworkInterface (SVCHlpClient *aClient,
161 const Guid &aGUID,
162 Utf8Str &aErrMsg);
163 static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
164 Progress *aProgress,
165 void *aUser, int *aVrc);
166#endif
167
168 ComObjPtr <VirtualBox, ComWeakRef> mParent;
169
170 typedef std::list <ComObjPtr <HostUSBDevice> > USBDeviceList;
171 USBDeviceList mUSBDevices;
172
173 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
174 USBDeviceFilterList mUSBDeviceFilters;
175
176 /** Pointer to the USBProxyService object. */
177 USBProxyService *mUSBProxyService;
178};
179
180#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