HostImpl.h revision ebd5aa3aa60caa6252a7e9bf77be3ed92c1f5abb
af062818b47340eef15700d2f0211576ba3506eevboxsync/* $Id$ */
af062818b47340eef15700d2f0211576ba3506eevboxsync/** @file
af062818b47340eef15700d2f0211576ba3506eevboxsync * Implemenation of IHost.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
af062818b47340eef15700d2f0211576ba3506eevboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
af062818b47340eef15700d2f0211576ba3506eevboxsync * additional information or have any questions.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifndef ____H_HOSTIMPL
af062818b47340eef15700d2f0211576ba3506eevboxsync#define ____H_HOSTIMPL
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include "VirtualBoxBase.h"
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass HostUSBDeviceFilter;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass USBProxyService;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass VirtualBox;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass SessionMachine;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass Progress;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass PerformanceCollector;
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass Medium;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncnamespace settings
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsync struct Host;
af062818b47340eef15700d2f0211576ba3506eevboxsync}
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <list>
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsyncclass ATL_NO_VTABLE Host :
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxBase,
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxSupportErrorInfoImpl<Host, IHost>,
af062818b47340eef15700d2f0211576ba3506eevboxsync public VirtualBoxSupportTranslation<Host>,
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOX_SCRIPTABLE_IMPL(IHost)
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsyncpublic:
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync DECLARE_NOT_AGGREGATABLE(Host)
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync BEGIN_COM_MAP(Host)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY(ISupportErrorInfo)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY(IHost)
af062818b47340eef15700d2f0211576ba3506eevboxsync COM_INTERFACE_ENTRY(IDispatch)
af062818b47340eef15700d2f0211576ba3506eevboxsync END_COM_MAP()
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT FinalConstruct();
af062818b47340eef15700d2f0211576ba3506eevboxsync void FinalRelease();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // public initializer/uninitializer for internal purposes only
af062818b47340eef15700d2f0211576ba3506eevboxsync HRESULT init(VirtualBox *aParent);
af062818b47340eef15700d2f0211576ba3506eevboxsync void uninit();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // IHost properties
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IMedium *, drives));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IMedium *, drives));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(COMGETTER(Acceleration3DAvailable))(BOOL *aSupported);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // IHost methods
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
af062818b47340eef15700d2f0211576ba3506eevboxsync IProgress **aProgress);
af062818b47340eef15700d2f0211576ba3506eevboxsync STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_BSTR aId, IProgress **aProgress);
STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition);
STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IMedium **aDrive);
STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IMedium **aDrive);
STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
STDMETHOD(FindHostNetworkInterfaceById) (IN_BSTR id, IHostNetworkInterface **networkInterface);
STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
STDMETHOD(FindUSBDeviceById) (IN_BSTR aId, IHostUSBDevice **aDevice);
// public methods only for internal purposes
HRESULT loadSettings(const settings::Host &data);
HRESULT saveSettings(settings::Host &data);
#ifdef VBOX_WITH_USB
typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
/** Must be called from under this object's lock. */
USBProxyService* usbProxyService();
HRESULT addChild(HostUSBDeviceFilter *pChild);
HRESULT removeChild(HostUSBDeviceFilter *pChild);
VirtualBox* parent();
HRESULT onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
void getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
HRESULT checkUSBProxyService();
#endif /* !VBOX_WITH_USB */
// for VirtualBoxSupportErrorInfoImpl
static const wchar_t *getComponentName() { return L"Host"; }
private:
#if (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)) && defined(VBOX_USE_LIBHAL)
bool getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
bool getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
#endif
#if defined(RT_OS_SOLARIS)
void parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
bool validateDevice(const char *deviceNode, bool isCDROM);
#endif
#ifdef VBOX_WITH_USB
/** specialization for IHostUSBDeviceFilter */
// ComObjPtr<HostUSBDeviceFilter> getDependentChild(IHostUSBDeviceFilter *aFilter);
#endif /* VBOX_WITH_USB */
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void registerMetrics (PerformanceCollector *aCollector);
void unregisterMetrics (PerformanceCollector *aCollector);
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
struct Data; // opaque data structure, defined in HostImpl.cpp
Data *m;
};
#endif // ____H_HOSTIMPL