HostNetworkInterfaceImpl.cpp revision b77cd15f5cf027341f2a126e3659e16092e11dd5
/* $Id $ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "HostNetworkInterfaceImpl.h"
#include "Logging.h"
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
DEFINE_EMPTY_CTOR_DTOR (HostNetworkInterface)
HRESULT HostNetworkInterface::FinalConstruct()
{
return S_OK;
}
void HostNetworkInterface::FinalRelease()
{
uninit ();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the host object.
*
* @returns COM result indicator
* @param aInterfaceName name of the network interface
* @param aGuid GUID of the host network interface
*/
HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid)
{
LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
aInterfaceName.raw(), aGuid.toString().raw()));
ComAssertRet (aInterfaceName, E_INVALIDARG);
ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
unconst (mInterfaceName) = aInterfaceName;
unconst (mGuid) = aGuid;
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
return S_OK;
}
// IHostNetworkInterface properties
/////////////////////////////////////////////////////////////////////////////
/**
* Returns the name of the host network interface.
*
* @returns COM status code
* @param aInterfaceName address of result pointer
*/
STDMETHODIMP HostNetworkInterface::COMGETTER(Name) (BSTR *aInterfaceName)
{
if (!aInterfaceName)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
mInterfaceName.cloneTo (aInterfaceName);
return S_OK;
}
/**
* Returns the GUID of the host network interface.
*
* @returns COM status code
* @param aGuid address of result pointer
*/
STDMETHODIMP HostNetworkInterface::COMGETTER(Id) (GUIDPARAMOUT aGuid)
{
if (!aGuid)
return E_POINTER;
AutoCaller autoCaller (this);
CheckComRCReturnRC (autoCaller.rc());
mGuid.cloneTo (aGuid);
return S_OK;
}