|
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: NWSessionSlot handle implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngNWSessionSlot2Imp.h" |
|
20 #include "CPEngNWSessionSlotID2Imp.h" |
|
21 #include "CPEngNWSessionOperation.h" |
|
22 #include "CPEngNWSessionOpenOp.h" |
|
23 #include "CPEngNWSessionCloseOp.h" |
|
24 #include "PEngLoginDataCodec.h" |
|
25 |
|
26 |
|
27 #include "CPEngSessionSlotState.h" |
|
28 #include "CPEngNWSessionSlotStorageProxy.h" |
|
29 #include "PEngStorageManager.h" |
|
30 #include "CPEngNWSessionProxy.h" |
|
31 |
|
32 |
|
33 #include <PEngPresenceEngineConsts2.h> |
|
34 #include <CPEngNWSessionSlot2.h> |
|
35 #include <CPEngNWSessionSlotID2.h> |
|
36 #include <PEngWVServices2.h> |
|
37 |
|
38 |
|
39 |
|
40 //LOCAL constants |
|
41 #ifdef _DEBUG |
|
42 namespace |
|
43 { |
|
44 //Panic |
|
45 _LIT( KPEngNWSessionSlotPanic, "PEngAtLstTrans" ); |
|
46 |
|
47 //Panic reasons |
|
48 enum TPEngNWSessionSlotPanicReasons |
|
49 { |
|
50 ENWSessionSlotUnkownOp |
|
51 }; |
|
52 |
|
53 void PEngNWSessionSlotPanic( TPEngNWSessionSlotPanicReasons aPanicReason ) |
|
54 { |
|
55 User::Panic( KPEngNWSessionSlotPanic, aPanicReason ); |
|
56 } |
|
57 } |
|
58 #endif |
|
59 |
|
60 // ============================ MEMBER FUNCTIONS =============================== |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPEngNWSessionSlot2Imp::NewL() |
|
64 // Two-phased constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CPEngNWSessionSlot2Imp* CPEngNWSessionSlot2Imp::NewL( CPEngNWSessionSlot2& aInterface, |
|
68 TInt aPriority, |
|
69 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
70 { |
|
71 CPEngNWSessionSlot2Imp* self = |
|
72 new ( ELeave ) CPEngNWSessionSlot2Imp( aInterface, aPriority ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL( aNWSessionSlotID ); |
|
75 CleanupStack::Pop( self ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 |
|
80 |
|
81 // Destructor |
|
82 CPEngNWSessionSlot2Imp::~CPEngNWSessionSlot2Imp() |
|
83 { |
|
84 //Cancel also deletes the operation objects |
|
85 CancelOpenNWPresenceSession(); |
|
86 CancelCloseNWPresenceSession(); |
|
87 |
|
88 delete iUsedSlot; |
|
89 delete iNWSessionProxy; |
|
90 |
|
91 #if _BullseyeCoverage |
|
92 cov_write(); |
|
93 #endif |
|
94 } |
|
95 |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CPEngNWSessionSlot2Imp::CPEngNWSessionSlot2Imp |
|
100 // C++ default constructor can NOT contain any code, that |
|
101 // might leave. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CPEngNWSessionSlot2Imp::CPEngNWSessionSlot2Imp( CPEngNWSessionSlot2& aInterface, |
|
105 TInt aPriority ) |
|
106 : iInterface( aInterface ), |
|
107 iActivePriority( aPriority ) |
|
108 { |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CPEngNWSessionSlot2Imp::ConstructL() |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CPEngNWSessionSlot2Imp::ConstructL( const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
117 { |
|
118 iUsedSlot = CPEngNWSessionSlotStorageProxy::NewL( aNWSessionSlotID ); |
|
119 iNWSessionProxy = CPEngNWSessionProxy::NewL( aNWSessionSlotID ); |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CPEngNWSessionSlot2Imp::GetNWSessionSlotID() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CPEngNWSessionSlot2Imp::GetNWSessionSlotID( CPEngNWSessionSlotID2& aNWSessionSlotID ) const |
|
128 { |
|
129 TRAPD( err, aNWSessionSlotID.Implementation()->SetAllL( iUsedSlot->BaseId(), |
|
130 iUsedSlot->AppId() ) ); |
|
131 return err; |
|
132 } |
|
133 |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CPEngNWSessionSlot2Imp::GetOption() |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 TInt CPEngNWSessionSlot2Imp::GetOption( TUint aOptionName, |
|
140 TUint aOptionLevel, |
|
141 TDes8& aOption ) |
|
142 { |
|
143 if ( ( aOptionName == KPEngWVCspServicesTree2 ) && |
|
144 ( aOptionLevel == KPEngNWSessionSlotTransportQuery ) ) |
|
145 { |
|
146 if ( aOption.Length() != sizeof( TPEngWVCspServicesTree2 ) ) |
|
147 { |
|
148 return KErrArgument; |
|
149 } |
|
150 |
|
151 TPEngWVCspServicesTree2 cspTree; |
|
152 TInt err = iNWSessionProxy->GetServiceTree( cspTree ); |
|
153 TPckg<TPEngWVCspServicesTree2> cspTreeBuf( cspTree ); |
|
154 aOption = cspTreeBuf; |
|
155 |
|
156 return err; |
|
157 } |
|
158 |
|
159 return KErrNotSupported; |
|
160 } |
|
161 |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CPEngNWSessionSlot2Imp::IsOpenNWPresenceSessionActive() |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CPEngNWSessionSlot2Imp::IsOpenNWPresenceSessionActive() const |
|
168 { |
|
169 return( iSessionOpenOp != NULL ); // CSI: 64 # |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CPEngNWSessionSlot2Imp::OpenNWPresenceSession() |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CPEngNWSessionSlot2Imp::OpenNWPresenceSession( |
|
178 const CIMPSSAPSettings& aSAP, |
|
179 MPEngNWSessionOperationObserver2& aObserver ) |
|
180 { |
|
181 if ( iSessionOpenOp || iSessionCloseOp ) |
|
182 { |
|
183 return KErrInUse; |
|
184 } |
|
185 |
|
186 CPEngNWSessionOpenOp* op = NULL; |
|
187 TRAPD( err, |
|
188 op = CPEngNWSessionOpenOp::NewL( iActivePriority, |
|
189 *iNWSessionProxy, |
|
190 iInterface, |
|
191 aSAP, |
|
192 aObserver ) ); |
|
193 |
|
194 if ( err == KErrNone ) |
|
195 { |
|
196 op->SetOwner( *this ); |
|
197 op->IssueNWSessionOpen(); |
|
198 iSessionOpenOp = op; |
|
199 } |
|
200 |
|
201 return err; |
|
202 } |
|
203 |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CPEngNWSessionSlot2Imp::CancelOpenNWPresenceSession() |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CPEngNWSessionSlot2Imp::CancelOpenNWPresenceSession() |
|
210 { |
|
211 //Deletes also the operation |
|
212 if ( iSessionOpenOp ) |
|
213 { |
|
214 iSessionOpenOp->CancelOpD(); |
|
215 iSessionOpenOp = NULL; |
|
216 } |
|
217 } |
|
218 |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CPEngNWSessionSlot2Imp::IsCloseNWPresenceSessionActive() |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 TBool CPEngNWSessionSlot2Imp::IsCloseNWPresenceSessionActive() const |
|
225 { |
|
226 return( iSessionCloseOp != NULL ); // CSI: 64 # |
|
227 } |
|
228 |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CPEngNWSessionSlot2Imp::CloseNWPresenceSession() |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CPEngNWSessionSlot2Imp::CloseNWPresenceSession( |
|
235 MPEngNWSessionOperationObserver2& aObserver, |
|
236 TBool aForceClose ) |
|
237 { |
|
238 if ( iSessionOpenOp || iSessionCloseOp ) |
|
239 { |
|
240 return KErrInUse; |
|
241 } |
|
242 |
|
243 CPEngNWSessionCloseOp* op = NULL; |
|
244 TRAPD( err, |
|
245 op = CPEngNWSessionCloseOp::NewL( iActivePriority, |
|
246 *iNWSessionProxy, |
|
247 iInterface, |
|
248 aObserver, |
|
249 aForceClose ) ); |
|
250 |
|
251 if ( err == KErrNone ) |
|
252 { |
|
253 op->SetOwner( *this ); |
|
254 op->IssueNWSessionClose(); |
|
255 iSessionCloseOp = op; |
|
256 } |
|
257 |
|
258 return err; |
|
259 } |
|
260 |
|
261 |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CPEngNWSessionSlot2Imp::CancelCloseNWPresenceSession() |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 void CPEngNWSessionSlot2Imp::CancelCloseNWPresenceSession() |
|
268 { |
|
269 //Deletes also the operation |
|
270 if ( iSessionCloseOp ) |
|
271 { |
|
272 iSessionCloseOp->CancelOpD(); |
|
273 iSessionCloseOp = NULL; |
|
274 } |
|
275 } |
|
276 |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CPEngNWSessionSlot2Imp::OpenNWPresenceSessionOwnership() |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TInt CPEngNWSessionSlot2Imp::OpenNWPresenceSessionOwnership() |
|
283 { |
|
284 return iNWSessionProxy->OpenOwnership(); |
|
285 } |
|
286 |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CPEngNWSessionSlot2Imp::CloseNWPresenceSessionOwnership() |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void CPEngNWSessionSlot2Imp::CloseNWPresenceSessionOwnership() |
|
293 { |
|
294 iNWSessionProxy->Close(); |
|
295 } |
|
296 |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CPEngNWSessionSlot2Imp::StoreNWPresenceSessionOwnership() |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 TInt CPEngNWSessionSlot2Imp::StoreNWPresenceSessionOwnership( |
|
303 const TDesC16& aOwnerID ) |
|
304 { |
|
305 return iNWSessionProxy->StoreOwnership( aOwnerID ); |
|
306 } |
|
307 |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CPEngNWSessionSlot2Imp::RestoreNWPresenceSessionOwnership() |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 TInt CPEngNWSessionSlot2Imp::RestoreNWPresenceSessionOwnership( |
|
314 const TDesC16& aOwnerID ) |
|
315 { |
|
316 return iNWSessionProxy->RestoreOwnership( aOwnerID ); |
|
317 } |
|
318 |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CPEngNWSessionSlot2Imp::GetNWPresenceSessionSap() |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CPEngNWSessionSlot2Imp::GetNWPresenceSessionSap( CIMPSSAPSettings& aSAP ) const |
|
325 { |
|
326 TRAPD( err, DoGetNWPresenceSessionSapL( aSAP ) ); |
|
327 return err; |
|
328 } |
|
329 |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CPEngNWSessionSlot2Imp::GetNWSessionSlotState() |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 TInt CPEngNWSessionSlot2Imp::GetNWSessionSlotState( |
|
336 TPEngNWSessionSlotState& aState ) const |
|
337 { |
|
338 TRAPD( err, |
|
339 { |
|
340 CPEngSessionSlotState* state = CPEngSessionSlotState::NewLC(); |
|
341 PEngStorageManager::SessionSlotStateL( iUsedSlot->BaseId(), |
|
342 *state ); |
|
343 |
|
344 aState = state->AppState( iUsedSlot->AppId() ); |
|
345 CleanupStack::PopAndDestroy( state ); |
|
346 } ); |
|
347 |
|
348 |
|
349 return err; |
|
350 } |
|
351 |
|
352 |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CPEngNWSessionSlot2Imp::HandleNWSessionOperationDestruction() |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void CPEngNWSessionSlot2Imp::HandleNWSessionOperationDestruction( |
|
359 CPEngNWSessionOperation* aOperation ) |
|
360 { |
|
361 if ( aOperation == iSessionOpenOp ) |
|
362 { |
|
363 iSessionOpenOp = NULL; |
|
364 return; |
|
365 } |
|
366 |
|
367 if ( aOperation == iSessionCloseOp ) |
|
368 { |
|
369 iSessionCloseOp = NULL; |
|
370 return; |
|
371 } |
|
372 |
|
373 __ASSERT_DEBUG( EFalse, PEngNWSessionSlotPanic( ENWSessionSlotUnkownOp ) ); |
|
374 } |
|
375 |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CPEngNWSessionSlot2Imp::DoGetNWPresenceSessionSapL() |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 void CPEngNWSessionSlot2Imp::DoGetNWPresenceSessionSapL( CIMPSSAPSettings& aSAP ) const |
|
382 { |
|
383 HBufC8* loginData = NULL; |
|
384 User::LeaveIfError( iNWSessionProxy->GetLoginData( loginData ) ); |
|
385 __ASSERT_ALWAYS( loginData, User::Leave( KErrGeneral ) ); |
|
386 |
|
387 |
|
388 CleanupStack::PushL( loginData ); |
|
389 PEngLoginDataCodec::UnPackLoginDataL( *loginData, aSAP ); |
|
390 CleanupStack::PopAndDestroy( loginData ); |
|
391 } |
|
392 |
|
393 |
|
394 |
|
395 // End of File |
|
396 |
|
397 |