webengine/device/src/DeviceBridge.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 27 Aug 2009 07:44:59 +0300
changeset 10 a359256acfc6
parent 5 10e98eab6f85
permissions -rw-r--r--
Revision: 200929 Kit: 200935

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of DeviceBridge
*
*/



// INCLUDE FILES
#include <config.h>
#include "Device.h"
#include "DeviceBridge.h"
#include "DeviceBinding.h"

using namespace KJS;
// ============================ LOCAL FUNCTIONS ===============================

// ----------------------------------------------------------------------------
// CreateDeviceBridge
//
//
//
// ----------------------------------------------------------------------------
//
EXPORT_C MDeviceBridge* CreateDeviceBridgeL()
    {
    return new (ELeave) TDeviceBridge();
    }


// ============================ MEMBER FUNCTIONS ===============================

// ----------------------------------------------------------------------------
// TDeviceBridge::TDeviceBridge
//
// ----------------------------------------------------------------------------
//
TDeviceBridge::TDeviceBridge() : m_device( 0 )
    {
    }

// ----------------------------------------------------------------------------
// TDeviceBridge::~TDeviceBridge
//
//
// ----------------------------------------------------------------------------
//
TDeviceBridge::~TDeviceBridge()
    {
    Clear();
    }    
    
// ----------------------------------------------------------------------------
// TDeviceBridge::Clear
//
//
// ----------------------------------------------------------------------------
//
void TDeviceBridge::Clear()
    {
    if ( m_device )
        {
        m_device->Close();
        KJS::Collector::unprotect(m_device);
        }
    m_device = NULL;
    }

// ----------------------------------------------------------------------------
// TDeviceBridge::Device
//
//
// ----------------------------------------------------------------------------
//
void* TDeviceBridge::Device( void* exec )
    {
    if ( !m_device )
        {
        m_device = new KJS::Device( static_cast<ExecState*>( exec ) );
        KJS::Collector::protect(m_device);
        }
    if ( m_device->valid() )
        return static_cast<void*>( m_device );
    else
        return NULL;
    }

// ----------------------------------------------------------------------------
// TDeviceBridge::SetUid
//
//
// ----------------------------------------------------------------------------
//
void TDeviceBridge::SetUid( const TUint& aValue)
    {
    if(m_device)
        m_device->SetUid( aValue);
    }
    
    
void* TDeviceBridge::GetSecuritySession()
    {
    if( m_device && (m_device->GetDeviceBinding()))
        {
        return static_cast<void*>(m_device->GetDeviceBinding()->GetSecuritySession());    
        }
    else
        {
        return NULL;
        }   
    }

//END OF FILE