HostImpl.h revision c281f4fa076f6ea627903f32a3c0070c235ac944
1N/A/* $Id$ */
1N/A/** @file
1N/A * Implemenation of IHost.
1N/A */
1N/A
1N/A/*
1N/A * Copyright (C) 2006-2007 Sun Microsystems, Inc.
1N/A *
1N/A * This file is part of VirtualBox Open Source Edition (OSE), as
1N/A * available from http://www.virtualbox.org. This file is free software;
1N/A * you can redistribute it and/or modify it under the terms of the GNU
1N/A * General Public License (GPL) as published by the Free Software
1N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
1N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1N/A *
1N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
1N/A * additional information or have any questions.
1N/A */
1N/A
1N/A#ifndef ____H_HOSTIMPL
1N/A#define ____H_HOSTIMPL
1N/A
1N/A#include "VirtualBoxBase.h"
1N/A#ifdef VBOX_WITH_USB
1N/A# include "HostUSBDeviceImpl.h"
1N/A# include "USBDeviceFilterImpl.h"
1N/A# include "USBProxyService.h"
1N/A# include "VirtualBoxImpl.h"
1N/A#else
1N/Aclass USBProxyService;
1N/A#endif
1N/A#include "HostPower.h"
1N/A
1N/A#ifdef RT_OS_WINDOWS
1N/A# include "win/svchlp.h"
1N/A#endif
1N/A
1N/A#ifdef VBOX_WITH_RESOURCE_USAGE_API
1N/A# include "PerformanceImpl.h"
1N/A#endif /* VBOX_WITH_RESOURCE_USAGE_API */
1N/A
1N/Aclass VirtualBox;
1N/Aclass SessionMachine;
1N/Aclass HostDVDDrive;
1N/Aclass HostFloppyDrive;
1N/Aclass Progress;
1N/A
1N/A#include <list>
1N/A
1N/Aclass ATL_NO_VTABLE Host :
1N/A public VirtualBoxBaseWithChildren,
1N/A public VirtualBoxSupportErrorInfoImpl <Host, IHost>,
1N/A public VirtualBoxSupportTranslation <Host>,
1N/A public IHost
1N/A{
1N/Apublic:
1N/A
1N/A DECLARE_NOT_AGGREGATABLE(Host)
1N/A
1N/A DECLARE_PROTECT_FINAL_CONSTRUCT()
1N/A
1N/A BEGIN_COM_MAP(Host)
1N/A COM_INTERFACE_ENTRY(ISupportErrorInfo)
1N/A COM_INTERFACE_ENTRY(IHost)
1N/A END_COM_MAP()
1N/A
1N/A NS_DECL_ISUPPORTS
1N/A
1N/A HRESULT FinalConstruct();
1N/A void FinalRelease();
1N/A
1N/A // public initializer/uninitializer for internal purposes only
1N/A HRESULT init (VirtualBox *aParent);
1N/A void uninit();
1N/A
1N/A // IHost properties
1N/A STDMETHOD(COMGETTER(DVDDrives))(IHostDVDDriveCollection **drives);
1N/A STDMETHOD(COMGETTER(FloppyDrives))(IHostFloppyDriveCollection **drives);
1N/A STDMETHOD(COMGETTER(USBDevices))(IHostUSBDeviceCollection **aUSBDevices);
1N/A STDMETHOD(COMGETTER(USBDeviceFilters))(IHostUSBDeviceFilterCollection ** aUSBDeviceFilters);
1N/A STDMETHOD(COMGETTER(NetworkInterfaces))(IHostNetworkInterfaceCollection **networkInterfaces);
1N/A STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
1N/A STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
1N/A STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
1N/A STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
1N/A STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
1N/A STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
1N/A STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);
1N/A STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);
1N/A STDMETHOD(COMGETTER(OSVersion))(BSTR *version);
1N/A STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);
1N/A
1N/A // IHost methods
1N/A#ifdef RT_OS_WINDOWS
1N/A STDMETHOD(CreateHostNetworkInterface) (INPTR BSTR aName,
1N/A IHostNetworkInterface **aHostNetworkInterface,
1N/A IProgress **aProgress);
1N/A STDMETHOD(RemoveHostNetworkInterface) (INPTR GUIDPARAM aId,
1N/A IHostNetworkInterface **aHostNetworkInterface,
1N/A IProgress **aProgress);
1N/A#endif
1N/A STDMETHOD(CreateUSBDeviceFilter) (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter);
1N/A STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
1N/A STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter **aFilter);
1N/A
1N/A // public methods only for internal purposes
1N/A
1N/A HRESULT loadSettings (const settings::Key &aGlobal);
1N/A HRESULT saveSettings (settings::Key &aGlobal);
1N/A
1N/A#ifdef VBOX_WITH_USB
1N/A typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
1N/A
1N/A /** Must be called from under this object's lock. */
1N/A USBProxyService *usbProxyService() { return mUSBProxyService; }
1N/A
1N/A HRESULT onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
1N/A void getUSBFilters(USBDeviceFilterList *aGlobalFiltes, VirtualBox::SessionMachineVector *aMachines);
1N/A HRESULT checkUSBProxyService();
1N/A#endif /* !VBOX_WITH_USB */
1N/A
1N/A#ifdef RT_OS_WINDOWS
1N/A static int networkInterfaceHelperServer (SVCHlpClient *aClient,
1N/A SVCHlpMsg::Code aMsgCode);
1N/A#endif
1N/A
1N/A // for VirtualBoxSupportErrorInfoImpl
1N/A static const wchar_t *getComponentName() { return L"Host"; }
1N/A
1N/Aprivate:
1N/A
1N/A#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
1N/A# ifdef VBOX_USE_LIBHAL
1N/A bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list);
1N/A bool getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list);
1N/A# endif
1N/A void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list);
1N/A bool validateDevice(const char *deviceNode, bool isCDROM);
1N/A#endif
1N/A
1N/A#ifdef VBOX_WITH_USB
1N/A /** specialization for IHostUSBDeviceFilter */
1N/A ComObjPtr <HostUSBDeviceFilter> getDependentChild (IHostUSBDeviceFilter *aFilter)
1N/A {
1N/A VirtualBoxBase *child = VirtualBoxBaseWithChildren::
1N/A getDependentChild (ComPtr <IUnknown> (aFilter));
1N/A return child ? dynamic_cast <HostUSBDeviceFilter *> (child)
1N/A : NULL;
1N/A }
1N/A#endif /* VBOX_WITH_USB */
1N/A
1N/A#ifdef RT_OS_WINDOWS
1N/A static int createNetworkInterface (SVCHlpClient *aClient,
1N/A const Utf8Str &aName,
1N/A Guid &aGUID, Utf8Str &aErrMsg);
1N/A static int removeNetworkInterface (SVCHlpClient *aClient,
1N/A const Guid &aGUID,
1N/A Utf8Str &aErrMsg);
1N/A static HRESULT networkInterfaceHelperClient (SVCHlpClient *aClient,
1N/A Progress *aProgress,
1N/A void *aUser, int *aVrc);
1N/A#endif
1N/A
1N/A#ifdef VBOX_WITH_RESOURCE_USAGE_API
1N/A void registerMetrics (PerformanceCollector *aCollector);
1N/A void unregisterMetrics (PerformanceCollector *aCollector);
1N/A#endif /* VBOX_WITH_RESOURCE_USAGE_API */
1N/A
1N/A ComObjPtr <VirtualBox, ComWeakRef> mParent;
1N/A
1N/A#ifdef VBOX_WITH_USB
1N/A USBDeviceFilterList mUSBDeviceFilters;
1N/A
1N/A /** Pointer to the USBProxyService object. */
1N/A USBProxyService *mUSBProxyService;
1N/A#endif /* VBOX_WITH_USB */
1N/A
1N/A HostPowerService *mHostPowerService;
1N/A};
1N/A
1N/A#endif // ____H_HOSTIMPL
1N/A