|
1 /* |
|
2 * Copyright (c) 2004 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: Access handler of the network session |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngTransAdapFactory.h" |
|
20 #include "CPEngSessionManager.h" |
|
21 #include "CPEngSessionSlotId.h" |
|
22 |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CPEngTransAdapFactory::CPEngTransAdapFactory |
|
28 // C++ default constructor can NOT contain any code, that might leave. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPEngTransAdapFactory::CPEngTransAdapFactory() |
|
32 : iSessManagers( 1 ) // usually only one session |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPEngTransAdapFactory::InstanceLC() |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CPEngTransAdapFactory* CPEngTransAdapFactory::InstanceLC() |
|
42 { |
|
43 CPEngTransAdapFactory* self = static_cast<CPEngTransAdapFactory*>( Dll::Tls() ); |
|
44 if ( !self ) |
|
45 { |
|
46 // create instance and store it in the Tls |
|
47 self = new ( ELeave ) CPEngTransAdapFactory(); |
|
48 CleanupClosePushL( *self ); |
|
49 User::LeaveIfError( Dll::SetTls( self ) ); |
|
50 } |
|
51 else |
|
52 { |
|
53 self->Open(); // CSI: 65 # |
|
54 CleanupClosePushL( *self ); |
|
55 } |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // Destructor |
|
61 CPEngTransAdapFactory::~CPEngTransAdapFactory() |
|
62 { |
|
63 iSessManagers.ResetAndDestroy(); |
|
64 Dll::SetTls( NULL ); |
|
65 |
|
66 |
|
67 #if _BullseyeCoverage |
|
68 cov_write(); |
|
69 #endif |
|
70 } |
|
71 |
|
72 |
|
73 // ============================================================================= |
|
74 // =============== New Functions of the MPEngTransAdapFactory ================== |
|
75 // ============================================================================= |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CPEngTransAdapFactory::OpenSessionCount() |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CPEngTransAdapFactory::OpenSessionCount() |
|
82 { |
|
83 Open(); |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CPEngTransAdapFactory::CloseSession() |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CPEngTransAdapFactory::CloseSession( |
|
92 CPEngSessionManager* aSessManager ) |
|
93 { |
|
94 TInt x ( iSessManagers.Find( aSessManager ) ); |
|
95 if ( x != KErrNotFound ) |
|
96 { |
|
97 iSessManagers.Remove( x ); |
|
98 } |
|
99 Close(); |
|
100 } |
|
101 |
|
102 |
|
103 // ============================================================================= |
|
104 // =============== New Functions of the base class ============================= |
|
105 // ============================================================================= |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CPEngTransAdapFactory::AccessHandlerL() |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 MPEngAccessHandler* CPEngTransAdapFactory::AccessHandlerL( |
|
112 const CPEngSessionSlotId& aSessionId ) |
|
113 { |
|
114 MPEngAccessHandler* handler = |
|
115 SessionManagerLC( aSessionId ).AccessHandlerL(); |
|
116 CleanupStack::PopAndDestroy(); // sessManager |
|
117 return handler; |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPEngTransAdapFactory::PureDataHandlerL() |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 MPEngPureDataHandler* CPEngTransAdapFactory::PureDataHandlerL( |
|
126 const CPEngSessionSlotId& aSessionId ) |
|
127 { |
|
128 MPEngPureDataHandler* handler = |
|
129 SessionManagerLC( aSessionId ).PureDataHandlerL(); |
|
130 CleanupStack::PopAndDestroy(); // sessManager |
|
131 return handler; |
|
132 } |
|
133 |
|
134 |
|
135 // ============================================================================= |
|
136 // =============== New Private Functions of the base class ===================== |
|
137 // ============================================================================= |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CPEngTransAdapFactory::SessionManagerLC |
|
141 // Find Session manager |
|
142 // if it does not exist it is created |
|
143 // (other items were commented in a header). |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CPEngSessionManager& CPEngTransAdapFactory::SessionManagerLC( |
|
147 const CPEngSessionSlotId& aSessionId ) |
|
148 { |
|
149 TInt count ( iSessManagers.Count() ); |
|
150 CPEngSessionManager* sessManager = NULL; |
|
151 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
152 { |
|
153 if ( KErrNone == iSessManagers[ x ]->SessionId().Match( |
|
154 aSessionId ) ) |
|
155 { |
|
156 sessManager = iSessManagers[ x ]; |
|
157 sessManager->Open(); // CSI: 65 # |
|
158 CleanupClosePushL( *sessManager ); |
|
159 break; |
|
160 } |
|
161 } |
|
162 if ( !sessManager ) |
|
163 { |
|
164 // does not exist, create new one |
|
165 sessManager = CPEngSessionManager::NewLC( *this, aSessionId ); |
|
166 iSessManagers.AppendL( sessManager ); |
|
167 } |
|
168 return *sessManager; |
|
169 } |
|
170 |
|
171 // End of File |
|
172 |
|
173 |