author | hgs |
Mon, 23 Aug 2010 14:17:50 +0300 | |
changeset 44 | 0a3ad94fc71c |
parent 28 | 075425b8d9a4 |
child 37 | 451b2e1545b2 |
permissions | -rw-r--r-- |
24 | 1 |
/* |
2 |
* Copyright (c) 2009 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 "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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <coemain.h> |
|
20 |
#include <e32svr.h> |
|
21 |
||
22 |
// User includes |
|
23 |
#include "cradioenginelogger.h" |
|
24 |
#include "cradioenginetls.h" |
|
25 |
||
26 |
const int KUidRadioEngineTls = 0x10281CB8; |
|
27 |
||
28 |
// ======== MEMBER FUNCTIONS ======== |
|
29 |
||
30 |
||
31 |
// --------------------------------------------------------------------------- |
|
32 |
// Returns the CRadioEngineTls instance from TLS |
|
33 |
// --------------------------------------------------------------------------- |
|
34 |
// |
|
35 |
CRadioEngineTls& CRadioEngineTls::Instance() |
|
36 |
{ |
|
37 |
return *static_cast<CRadioEngineTls*>( UserSvr::DllTls( KUidRadioEngineTls ) ); |
|
38 |
} |
|
39 |
||
40 |
||
41 |
// --------------------------------------------------------------------------- |
|
42 |
// |
|
43 |
// --------------------------------------------------------------------------- |
|
44 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
45 |
void CRadioEngineTls::InitializeL( RFs* aFs ) |
24 | 46 |
{ |
47 |
if ( !UserSvr::DllTls( KUidRadioEngineTls ) ) |
|
48 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
49 |
CRadioEngineTls* self = new ( ELeave ) CRadioEngineTls( aFs ); |
24 | 50 |
CleanupStack::PushL( self ); |
51 |
self->ConstructL(); |
|
52 |
User::LeaveIfError( UserSvr::DllSetTls( KUidRadioEngineTls, self ) ); |
|
53 |
CleanupStack::Pop( self ); |
|
54 |
} |
|
55 |
} |
|
56 |
||
57 |
||
58 |
// --------------------------------------------------------------------------- |
|
59 |
// |
|
60 |
// --------------------------------------------------------------------------- |
|
61 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
CRadioEngineTls::CRadioEngineTls( RFs* aFs ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
63 |
: iFs( aFs ) |
24 | 64 |
{ |
65 |
} |
|
66 |
||
67 |
||
68 |
// --------------------------------------------------------------------------- |
|
69 |
// |
|
70 |
// --------------------------------------------------------------------------- |
|
71 |
// |
|
72 |
void CRadioEngineTls::ConstructL() |
|
73 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
74 |
if ( !iFs || !iFs->Handle() ) |
24 | 75 |
{ |
76 |
iFsOwned = ETrue; |
|
77 |
iFs = new ( ELeave ) RFs; |
|
78 |
User::LeaveIfError( iFs->Connect() ); |
|
79 |
} |
|
80 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
81 |
|
24 | 82 |
#ifdef LOGGING_ENABLED |
83 |
iLogger = CRadioEngineLogger::NewL( *iFs ); |
|
84 |
#endif // LOGGING_ENABLED |
|
85 |
||
86 |
} |
|
87 |
||
88 |
||
89 |
// --------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
// --------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
CRadioEngineTls::~CRadioEngineTls() |
|
94 |
{ |
|
95 |
UserSvr::DllFreeTls( KUidRadioEngineTls ); |
|
96 |
||
97 |
#ifdef LOGGING_ENABLED |
|
98 |
delete iLogger; |
|
99 |
#endif |
|
100 |
||
101 |
if ( iFs && iFsOwned ) |
|
102 |
{ |
|
103 |
iFs->Close(); |
|
104 |
delete iFs; |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
||
109 |
// --------------------------------------------------------------------------- |
|
110 |
// Return the logger storage if logging is enabled |
|
111 |
// --------------------------------------------------------------------------- |
|
112 |
// |
|
113 |
MRadioEngineLogger* CRadioEngineTls::Logger() |
|
114 |
{ |
|
115 |
#ifdef LOGGING_ENABLED |
|
116 |
return CRadioEngineTls::Instance().iLogger; |
|
117 |
#else |
|
118 |
return NULL; |
|
119 |
#endif |
|
120 |
} |
|
121 |
||
122 |
||
123 |
// --------------------------------------------------------------------------- |
|
124 |
// Returns the file server session |
|
125 |
// --------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
RFs& CRadioEngineTls::FsSession() |
|
128 |
{ |
|
129 |
return *CRadioEngineTls::Instance().iFs; |
|
130 |
} |
|
131 |
||
132 |
||
133 |
// --------------------------------------------------------------------------- |
|
134 |
// CRadioEngineTls::AddRef |
|
135 |
// --------------------------------------------------------------------------- |
|
136 |
// |
|
137 |
void CRadioEngineTls::AddRef() |
|
138 |
{ |
|
139 |
++iRefs; |
|
140 |
} |
|
141 |
||
142 |
// --------------------------------------------------------------------------- |
|
143 |
// CRadioEngineTls::Release |
|
144 |
// --------------------------------------------------------------------------- |
|
145 |
// |
|
146 |
void CRadioEngineTls::Release() |
|
147 |
{ |
|
148 |
__ASSERT_DEBUG( iRefs > 0 , User::Panic( _L( "CRadioEngineTls" ), KErrCorrupt ) ); |
|
149 |
if ( !--iRefs ) |
|
150 |
{ |
|
151 |
delete this; |
|
152 |
} |
|
153 |
} |