webengine/device/src/DeviceBridge.cpp
changeset 0 dd21522fd290
child 5 10e98eab6f85
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webengine/device/src/DeviceBridge.cpp	Mon Mar 30 12:54:55 2009 +0300
@@ -0,0 +1,100 @@
+/*
+* 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"
+
+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()
+    {
+    if ( m_device )
+        {
+        m_device->Close();
+        KJS::Collector::unprotect(m_device);
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// 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);
+    }
+//END OF FILE
+
+
+