|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of DeviceBridge |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <config.h> |
|
22 #include "Device.h" |
|
23 #include "DeviceBridge.h" |
|
24 |
|
25 using namespace KJS; |
|
26 // ============================ LOCAL FUNCTIONS =============================== |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // CreateDeviceBridge |
|
30 // |
|
31 // |
|
32 // |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C MDeviceBridge* CreateDeviceBridgeL() |
|
36 { |
|
37 return new (ELeave) TDeviceBridge(); |
|
38 } |
|
39 |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // TDeviceBridge::TDeviceBridge |
|
45 // |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 TDeviceBridge::TDeviceBridge() : m_device( 0 ) |
|
49 { |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // TDeviceBridge::~TDeviceBridge |
|
54 // |
|
55 // |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 TDeviceBridge::~TDeviceBridge() |
|
59 { |
|
60 if ( m_device ) |
|
61 { |
|
62 m_device->Close(); |
|
63 KJS::Collector::unprotect(m_device); |
|
64 } |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // TDeviceBridge::Device |
|
69 // |
|
70 // |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 void* TDeviceBridge::Device( void* exec ) |
|
74 { |
|
75 if ( !m_device ) |
|
76 { |
|
77 m_device = new KJS::Device( static_cast<ExecState*>( exec ) ); |
|
78 KJS::Collector::protect(m_device); |
|
79 } |
|
80 if ( m_device->valid() ) |
|
81 return static_cast<void*>( m_device ); |
|
82 else |
|
83 return NULL; |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // TDeviceBridge::SetUid |
|
88 // |
|
89 // |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 void TDeviceBridge::SetUid( const TUint& aValue) |
|
93 { |
|
94 if(m_device) |
|
95 m_device->SetUid( aValue); |
|
96 } |
|
97 //END OF FILE |
|
98 |
|
99 |
|
100 |