|
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 "CPEngAccessHandler.h" |
|
20 #include <CIMPSSAPSettings.h> |
|
21 #include <ImpsServices.h> |
|
22 |
|
23 #include "PEngLoginDataCodec.h" |
|
24 #include "MPEngSessionStatusObserver.h" |
|
25 #include "MPEngSessionManager.h" |
|
26 #include "PEngTransAdapterPanics.h" |
|
27 |
|
28 #include "PEngWVPresenceErrors2.h" |
|
29 #include "PresenceDebugPrint.h" |
|
30 |
|
31 |
|
32 //DATA TYPES |
|
33 /** |
|
34 * Function map structure. |
|
35 */ |
|
36 struct SCspFunctionMap |
|
37 { |
|
38 TInt iPeFunc; |
|
39 TImpsFunctions iImpsEngFunc; |
|
40 |
|
41 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
42 const TText* iPeFuncName; |
|
43 #endif |
|
44 }; |
|
45 |
|
46 |
|
47 /** |
|
48 * Sub-Function map structure. |
|
49 */ |
|
50 struct SCspSubFunctionMap |
|
51 { |
|
52 TInt iPeSubFunc; |
|
53 TInt iImpsEngSubFunc; |
|
54 |
|
55 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
56 const TText* iPeSubFuncName; |
|
57 #endif |
|
58 }; |
|
59 |
|
60 //CONTANTS |
|
61 const TInt KPEngNullFunction = 0; |
|
62 |
|
63 |
|
64 //MACROS |
|
65 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
66 #define MAPPING( a1, a2 ) { a1, a2, _S( #a1 ) } |
|
67 #define MAPPING_TERMINATION { KPEngNullFunction } |
|
68 #else |
|
69 #define MAPPING( a1, a2 ) { a1, a2 } |
|
70 #define MAPPING_TERMINATION { KPEngNullFunction } |
|
71 #endif |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 /** |
|
78 * Fundamental functions & sub-functions. |
|
79 */ |
|
80 const SCspFunctionMap KFuncMapFundamental[] = |
|
81 { |
|
82 MAPPING( KPEngFFServiceFunction, EServiceFunc ), |
|
83 MAPPING( KPEngFFSearchFunction, ESearchFunc ), |
|
84 MAPPING( KPEngFFInviteFunction, EInviteFunc ), |
|
85 MAPPING_TERMINATION |
|
86 }; |
|
87 |
|
88 const SCspSubFunctionMap KSubFuncMapFundamental[] = |
|
89 { |
|
90 MAPPING( KPEngFFSubFuncGETSPI, KImpsServiceGETSPI ), |
|
91 MAPPING( KPEngFFSubFuncSRCH, KImpsServiceSRCH ), |
|
92 MAPPING( KPEngFFSubFuncSTSRC, KImpsServiceSTSRC ), |
|
93 MAPPING( KPEngFFSubFuncINVIT, KImpsServiceINVIT ), |
|
94 MAPPING( KPEngFFSubFuncCAINV, KImpsServiceCAINV ), |
|
95 MAPPING_TERMINATION |
|
96 }; |
|
97 |
|
98 /** |
|
99 * Presence functions & sub-functions. |
|
100 */ |
|
101 const SCspFunctionMap KFuncMapPresence[] = |
|
102 { |
|
103 MAPPING( KPEngWVContListFunction, EContListFunc ), |
|
104 MAPPING( KPEngWVPresAuthFunction, EPresenceAuthFunc ), |
|
105 MAPPING( KPEngWVPresDelivFunction, EPresenceDeliverFunc ), |
|
106 MAPPING( KPEngWVAttrListFunction, EAttrListFunc ), |
|
107 MAPPING_TERMINATION |
|
108 }; |
|
109 |
|
110 |
|
111 const SCspSubFunctionMap KSubFuncMapPresence[] = |
|
112 { |
|
113 MAPPING( KPEngWVSubFuncGCLI, KImpsServiceGCLI ), |
|
114 MAPPING( KPEngWVSubFuncCCLI, KImpsServiceCCLI ), |
|
115 MAPPING( KPEngWVSubFuncDCLI, KImpsServiceDCLI ), |
|
116 MAPPING( KPEngWVSubFuncMCLS, KImpsServiceMCLS ), |
|
117 MAPPING( KPEngWVSubFuncGETWL, KImpsServiceGETWL ), |
|
118 MAPPING( KPEngWVSubFuncREACT, KImpsServiceREACT ), |
|
119 MAPPING( KPEngWVSubFuncCAAUT, KImpsServiceCAAUT ), |
|
120 //{ KPEngWVSubFuncGETAUT, Not yet in WV Engine }, |
|
121 MAPPING( KPEngWVSubFuncGETPR, KImpsServiceGETPR ), |
|
122 MAPPING( KPEngWVSubFuncUPDPR, KImpsServiceUPDPR ), |
|
123 MAPPING( KPEngWVSubFuncCALI, KImpsServiceCALI ), |
|
124 MAPPING( KPEngWVSubFuncDALI, KImpsServiceDALI ), |
|
125 MAPPING( KPEngWVSubFuncGALS, KImpsServiceGALS ), |
|
126 MAPPING_TERMINATION |
|
127 }; |
|
128 |
|
129 /** |
|
130 * IM Functions & sub-functions. |
|
131 */ |
|
132 const SCspFunctionMap KFuncMapIm[] = |
|
133 { |
|
134 MAPPING( KPEngIMSendFunctions, EIMSendFunc ), |
|
135 MAPPING( KPEngIMReceiveFunctions, EIMReceiveFunc ), |
|
136 MAPPING( KPEngIMAuthorFunctions, EIMAuthFunc ), |
|
137 MAPPING_TERMINATION |
|
138 }; |
|
139 |
|
140 const SCspSubFunctionMap KSubFuncMapIm[] = |
|
141 { |
|
142 // Send Functions |
|
143 MAPPING( KPEngIMSubFuncMDELIV, KImpsServiceMDELIV ), |
|
144 MAPPING( KPEngIMSubFuncFWMSG, KImpsServiceFWMSG ), |
|
145 // Receive functions |
|
146 MAPPING( KPEngIMSubFuncSETD, KImpsServiceSETD ), |
|
147 MAPPING( KPEngIMSubFuncGETLM, KImpsServiceGETLM ), |
|
148 MAPPING( KPEngIMSubFuncGETM, KImpsServiceGETM ), |
|
149 MAPPING( KPEngIMSubFuncREJCM, KImpsServiceREJCM ), |
|
150 MAPPING( KPEngIMSubFuncNOTIF, KImpsServiceNOTIF ), |
|
151 MAPPING( KPEngIMSubFuncNEWM, KImpsServiceNEWM ), |
|
152 // Authorize functions |
|
153 MAPPING( KPEngIMSubFuncGLBLU, KImpsServiceGLBLU ), |
|
154 MAPPING( KPEngIMSubFuncBLENT, KImpsServiceBLENT ), |
|
155 MAPPING_TERMINATION |
|
156 }; |
|
157 |
|
158 /** |
|
159 * Group Functions & sub-functions. |
|
160 */ |
|
161 /** |
|
162 * IM Functions & sub-functions. |
|
163 */ |
|
164 const SCspFunctionMap KFuncMapGroup[] = |
|
165 { |
|
166 MAPPING( KPEngGRManageFunctions, EGroupMgmtFunc ), |
|
167 MAPPING( KPEngGRUseFunctions, EGroupUseFunc ), |
|
168 MAPPING( KPEngGRAuthorFunctions, EGroupAuthFunc ), |
|
169 MAPPING_TERMINATION |
|
170 }; |
|
171 |
|
172 const SCspSubFunctionMap KSubFuncMapGroup[] = |
|
173 { |
|
174 // Manager functions |
|
175 MAPPING( KPEngGRSubFuncCREAG, KImpsServiceCREAG ), |
|
176 MAPPING( KPEngGRSubFuncDELGR, KImpsServiceDELGR ), |
|
177 MAPPING( KPEngGRSubFuncGETGP, KImpsServiceGETGP ), |
|
178 MAPPING( KPEngGRSubFuncSETGP, KImpsServiceSETGP ), |
|
179 // Use functions |
|
180 MAPPING( KPEngGRSubFuncSUBGCN, KImpsServiceSUBGCN ), |
|
181 MAPPING( KPEngGRSubFuncGRCHN, KImpsServiceGRCHN ), |
|
182 // Authorization functions |
|
183 MAPPING( KPEngGRSubFuncGETGM, KImpsServiceGETGM ), |
|
184 MAPPING( KPEngGRSubFuncADDGM, KImpsServiceADDGM ), |
|
185 MAPPING( KPEngGRSubFuncRMVGM, KImpsServiceRMVGM ), |
|
186 MAPPING( KPEngGRSubFuncMBRAC, KImpsServiceMBRAC ), |
|
187 MAPPING( KPEngGRSubFuncREJEC, KImpsServiceREJEC ), |
|
188 MAPPING_TERMINATION |
|
189 }; |
|
190 |
|
191 |
|
192 // ============================ LOCAL FUNCTIONS =============================== |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // DebugDumpFeatureSubtree() |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
199 void DebugDumpFeatureSubtree( const TDesC& aFeatureName, |
|
200 TPEngWVCspFeature2& aPEFeature, |
|
201 const SCspFunctionMap aFunctionMap[], |
|
202 const SCspSubFunctionMap aSubFunctionMap[] ) |
|
203 |
|
204 { |
|
205 //Whole feature |
|
206 PENG_DP( D_PENG_LIT( "%S, support status: %d" ), |
|
207 &aFeatureName, aPEFeature.FeatureSupported() ); |
|
208 |
|
209 //Functions |
|
210 PENG_DP( D_PENG_LIT( "%S, supported functions:" ), &aFeatureName ); |
|
211 for ( TInt i( 0 ); aFunctionMap[ i ].iPeFunc != KPEngNullFunction; ++i ) |
|
212 { |
|
213 const SCspFunctionMap functionMap = aFunctionMap[ i ]; |
|
214 |
|
215 if ( aPEFeature.FunctionSupported( functionMap.iPeFunc ) ) |
|
216 { |
|
217 TPtrC peFuncName( functionMap.iPeFuncName ); |
|
218 PENG_DP( D_PENG_LIT( " %S" ), &peFuncName ); |
|
219 } |
|
220 } |
|
221 |
|
222 |
|
223 //Sub-functions |
|
224 PENG_DP( D_PENG_LIT( "%S, supported sub-functions:" ), &aFeatureName ); |
|
225 for ( TInt ii( 0 ); aSubFunctionMap[ ii ].iPeSubFunc != KPEngNullFunction; ++ii ) |
|
226 { |
|
227 const SCspSubFunctionMap subFuncMap = aSubFunctionMap[ ii ]; |
|
228 if ( aPEFeature.SubFunctionSupported( subFuncMap.iPeSubFunc ) ) |
|
229 { |
|
230 TPtrC peSubFuncName( subFuncMap.iPeSubFuncName ); |
|
231 PENG_DP( D_PENG_LIT( " %S" ), &peSubFuncName ); |
|
232 } |
|
233 } |
|
234 } |
|
235 #endif |
|
236 |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CopyFeatureSubtree() |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 void CopyFeatureSubtree( TPEngWVCspFeature2& aPEFeature, |
|
243 TImpsFeature& aWVFeature, |
|
244 const SCspFunctionMap aFunctionMap[], |
|
245 const SCspSubFunctionMap aSubFunctionMap[] ) |
|
246 |
|
247 { |
|
248 // Is feature supported at all |
|
249 aPEFeature.iSupported = aWVFeature.IsSupported(); |
|
250 |
|
251 TInt holder; |
|
252 |
|
253 //Functions |
|
254 holder = KPEngNullFunction; |
|
255 for ( TInt i( 0 ); aFunctionMap[ i ].iPeFunc != KPEngNullFunction; ++i ) |
|
256 { |
|
257 const SCspFunctionMap functionMap = aFunctionMap[ i ]; |
|
258 if ( aWVFeature.Function( functionMap.iImpsEngFunc ) ) |
|
259 { |
|
260 holder |= functionMap.iPeFunc; |
|
261 } |
|
262 } |
|
263 aPEFeature.iFunctions = holder; |
|
264 |
|
265 //Sub-functions |
|
266 holder = KPEngNullFunction; |
|
267 for ( TInt ii( 0 ); aSubFunctionMap[ ii ].iPeSubFunc != KPEngNullFunction; ++ii ) |
|
268 { |
|
269 const SCspSubFunctionMap subFunctionMap = aSubFunctionMap[ ii ]; |
|
270 if ( aWVFeature.Capability( subFunctionMap.iImpsEngSubFunc ) ) |
|
271 { |
|
272 holder = holder + subFunctionMap.iPeSubFunc; |
|
273 } |
|
274 } |
|
275 aPEFeature.iSubFunctions = holder; |
|
276 } |
|
277 |
|
278 |
|
279 // ============================ MEMBER FUNCTIONS =============================== |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CPEngAccessHandler::CPEngAccessHandler |
|
283 // C++ default constructor can NOT contain any code, that might leave. |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 CPEngAccessHandler::CPEngAccessHandler( |
|
287 MPEngSessionManager& aSessManager, |
|
288 const CPEngSessionSlotId& aSessionId ) |
|
289 : iCount( 1 ), // init count to 1 |
|
290 iSessionManager( aSessManager ), |
|
291 iSessionId( aSessionId ), |
|
292 iSessStatus( EPEngNWPresenceSessionClosed ), |
|
293 iOperation( EIdle ) |
|
294 { |
|
295 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::CPEngAccessHandler" ) ); |
|
296 iSessionManager.OpenRef(); |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CPEngAccessHandler::ConstructL |
|
301 // Symbian 2nd phase constructor can leave. |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CPEngAccessHandler::ConstructL( |
|
305 RImpsEng& aSessClient ) |
|
306 { |
|
307 iAccessClient.RegisterL( aSessClient, this ); |
|
308 iAccessClient.RegisterErrorObserverL( *this ); |
|
309 iAccessClient.RegisterStatusObserverL( this ); |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CPEngAccessHandler::NewLC() |
|
314 // Two-phased constructor. |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 CPEngAccessHandler* CPEngAccessHandler::NewL( |
|
318 RImpsEng& aSessClient, |
|
319 MPEngSessionManager& aSessManager, |
|
320 const CPEngSessionSlotId& aSessionId ) |
|
321 { |
|
322 CPEngAccessHandler* self = new ( ELeave ) CPEngAccessHandler( |
|
323 aSessManager, |
|
324 aSessionId ); |
|
325 CleanupClosePushL( *self ); |
|
326 self->ConstructL( aSessClient ); |
|
327 CleanupStack::Pop(); |
|
328 return self; |
|
329 } |
|
330 |
|
331 |
|
332 // Destructor |
|
333 CPEngAccessHandler::~CPEngAccessHandler() |
|
334 { |
|
335 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::~CPEngAccessHandler" ) ); |
|
336 __ASSERT_DEBUG( ( iObservers.Count() == 0 ), User::Panic( |
|
337 KPEngTransferAdapterPanic, EOpIdConsistencyLost ) ); |
|
338 |
|
339 delete iLogInData; |
|
340 iAccessClient.Unregister(); |
|
341 iSessionManager.CloseAccessHandler(); |
|
342 iObservers.Reset(); |
|
343 } |
|
344 |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // ----------------------------------------------------------------------------- |
|
348 |
|
349 // ============================================================================= |
|
350 // =============== New Functions of the MPEngAccessHandler ===================== |
|
351 // ============================================================================= |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // CPEngAccessHandler::Close() |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void CPEngAccessHandler::Close() |
|
358 { |
|
359 iCount--; |
|
360 if ( iCount == 0 ) |
|
361 { |
|
362 delete this; |
|
363 } |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CPEngAccessHandler::Open() |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CPEngAccessHandler::Open() |
|
371 { |
|
372 iCount++; |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CPEngAccessHandler::LogInL( |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void CPEngAccessHandler::LogInL( |
|
380 TRequestStatus& aStatus, |
|
381 HBufC8* aLoginBuffer ) |
|
382 { |
|
383 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::LogInL" ) ); |
|
384 |
|
385 if ( iOperation != EIdle ) |
|
386 { |
|
387 // client is busy, leave |
|
388 delete aLoginBuffer; |
|
389 User::Leave( KErrNotReady ); |
|
390 } |
|
391 // Are we logged? |
|
392 if ( iSessStatus == EPEngNWPresenceSessionOpen ) |
|
393 { |
|
394 // we are already logged, this should not happened |
|
395 delete aLoginBuffer; |
|
396 User::Leave( KErrAlreadyExists ); |
|
397 } |
|
398 |
|
399 delete iLogInData; |
|
400 iLogInData = aLoginBuffer; |
|
401 |
|
402 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::LogInL() - doing reactive login" ) ); |
|
403 CIMPSSAPSettings* sapSetting = CIMPSSAPSettings::NewLC(); |
|
404 PEngLoginDataCodec::UnPackLoginDataL( *iLogInData, *sapSetting ); |
|
405 TImpsCspIdentifier sessIndentifier; |
|
406 sessIndentifier.SetUserIdL( sapSetting->SAPUserId() ); |
|
407 sessIndentifier.SetSapL( sapSetting->SAPAddress() ); |
|
408 |
|
409 // panic if we get other session log in data, user's gone wacko |
|
410 CheckConsistency( iSessionId, sessIndentifier ); |
|
411 iOpId = iAccessClient.ReactiveLoginL( |
|
412 sessIndentifier, // Identifier |
|
413 sapSetting->SAPUserPassword(), // User Password |
|
414 sapSetting->ClientId(), // Client Id |
|
415 sapSetting->AccessPoint(), // Access Point |
|
416 &( sapSetting->ServerAuthenticationName() ), // Operator key 1 |
|
417 &( sapSetting->ServerAuthenticationPassword() ) ); // Operator key 2 |
|
418 |
|
419 CleanupStack::PopAndDestroy( sapSetting ); |
|
420 |
|
421 // log in issued, set operation to the Log In |
|
422 aStatus = KRequestPending; |
|
423 iStatus = &aStatus; |
|
424 iOperation = EDoingLogIn; |
|
425 } |
|
426 |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CPEngAccessHandler::LogOutL() |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void CPEngAccessHandler::LogOutL( TRequestStatus& aStatus ) |
|
433 { |
|
434 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::LogOutL" ) ); |
|
435 |
|
436 if ( iOperation != EIdle ) |
|
437 { |
|
438 // client is busy, leave |
|
439 User::Leave( KErrNotReady ); |
|
440 } |
|
441 |
|
442 // Are we even logged |
|
443 if ( iSessStatus != EPEngNWPresenceSessionOpen ) |
|
444 { |
|
445 // we are already logged out |
|
446 return; |
|
447 } |
|
448 |
|
449 iOpId = iAccessClient.LogoutL(); |
|
450 aStatus = KRequestPending; |
|
451 iStatus = &aStatus; |
|
452 iOperation = EDoingLogOut; |
|
453 } |
|
454 |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CPEngAccessHandler::LogInData( ) |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 const TDesC8& CPEngAccessHandler::LogInData( ) const |
|
461 { |
|
462 return *iLogInData; |
|
463 } |
|
464 |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // CPEngAccessHandler::CancelL() |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 void CPEngAccessHandler::Cancel() |
|
471 { |
|
472 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::Cancel, Status:%d operation:%d" ), |
|
473 iSessStatus, |
|
474 iOperation ); |
|
475 |
|
476 if ( iStatus ) |
|
477 { |
|
478 switch ( iOperation ) |
|
479 { |
|
480 case EDoingLogIn: |
|
481 { |
|
482 // cancel login |
|
483 TRAP_IGNORE( iAccessClient.CancelLoginL( iOpId ) ); |
|
484 User::RequestComplete( iStatus, KErrCancel ); |
|
485 iStatus = NULL; |
|
486 iOperation = ECanceling; |
|
487 break; |
|
488 } |
|
489 case EDoingLogOut: |
|
490 { |
|
491 // cancel logout |
|
492 // no cancel, complete and let it delete |
|
493 User::RequestComplete( iStatus, KErrCancel ); |
|
494 iStatus = NULL; |
|
495 iOperation = ECanceling; |
|
496 break; |
|
497 } |
|
498 default: |
|
499 { |
|
500 // this should not happen, active, status, and idle operation |
|
501 // completed status |
|
502 User::RequestComplete( iStatus, KErrCancel ); |
|
503 iStatus = NULL; |
|
504 } |
|
505 } |
|
506 } |
|
507 } |
|
508 |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CPEngAccessHandler::RegisterSessionObserver( |
|
512 // ----------------------------------------------------------------------------- |
|
513 // |
|
514 void CPEngAccessHandler::RegisterSessionObserverL( MPEngSessionStatusObserver& aObserver ) |
|
515 { |
|
516 if ( KErrNotFound != iObservers.Find( &aObserver ) ) |
|
517 { |
|
518 User::Leave( KErrAlreadyExists ); |
|
519 } |
|
520 iObservers.AppendL( &aObserver ); |
|
521 } |
|
522 |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // CPEngAccessHandler::UnregisterSessionObserver( |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 void CPEngAccessHandler::UnregisterSessionObserver( MPEngSessionStatusObserver& aObserver ) |
|
529 { |
|
530 TInt index ( iObservers.Find( &aObserver ) ); |
|
531 if ( index != KErrNotFound ) |
|
532 { |
|
533 iObservers.Remove( index ); |
|
534 } |
|
535 } |
|
536 |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // CPEngAccessHandler::ServiceCapabilities() |
|
540 // ----------------------------------------------------------------------------- |
|
541 // |
|
542 TPEngWVCspServicesTree2& CPEngAccessHandler::ServiceCapabilities() |
|
543 { |
|
544 return iServices; |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CPEngAccessHandler::AssertLoginDataL() |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void CPEngAccessHandler::AssertLoginDataL( |
|
552 TDesC8& aLogInData ) |
|
553 { |
|
554 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::AssertLoginDataL()" ) ); |
|
555 __ASSERT_DEBUG( iLogInData, User::Panic( |
|
556 KPEngTransferAdapterPanic, ELogInDataNotValid ) ); |
|
557 |
|
558 CIMPSSAPSettings* originalData = CIMPSSAPSettings::NewLC(); |
|
559 PEngLoginDataCodec::UnPackLoginDataL( *iLogInData, *originalData ); |
|
560 CIMPSSAPSettings* assertData = CIMPSSAPSettings::NewLC(); |
|
561 PEngLoginDataCodec::UnPackLoginDataL( aLogInData, *assertData ); |
|
562 if ( |
|
563 ( KErrNone != originalData->SAPUserPassword().Compare( assertData->SAPUserPassword() ) ) |
|
564 || |
|
565 ( KErrNone != originalData->SAPAddress().Compare( assertData->SAPAddress() ) ) |
|
566 || |
|
567 ( KErrNone != originalData->SAPUserId().Compare( assertData->SAPUserId() ) ) |
|
568 ) |
|
569 { |
|
570 User::Leave( KPEngNwErrInvalidPassword ); |
|
571 } |
|
572 CleanupStack::PopAndDestroy( 2 ); // assertData, originalData |
|
573 } |
|
574 |
|
575 // ============================================================================= |
|
576 // =============== New Functions of the MImpsAccessHandler ===================== |
|
577 // ============================================================================= |
|
578 |
|
579 // ----------------------------------------------------------------------------- |
|
580 // CPEngAccessHandler::HandleLoginL() |
|
581 // ----------------------------------------------------------------------------- |
|
582 // |
|
583 void CPEngAccessHandler::HandleLoginL( |
|
584 TInt aId, |
|
585 TImpsCspIdentifier& aCspId ) |
|
586 { |
|
587 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::HandleLoginL - id: %d" ), aId ); |
|
588 |
|
589 // panic if we get other session notification |
|
590 CheckConsistency( iSessionId, aCspId ); |
|
591 // if operation came from some other session it should be 0 |
|
592 __ASSERT_DEBUG( ( aId == iOpId ), User::Panic( |
|
593 KPEngTransferAdapterPanic, EOpIdConsistencyLost ) ); |
|
594 } |
|
595 |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CPEngAccessHandler::HandleLogoutL() |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CPEngAccessHandler::HandleLogoutL( |
|
602 TInt aId, |
|
603 TImpsCspIdentifier& aCspId ) |
|
604 { |
|
605 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::HandleLogoutL - id: %d" ), aId ); |
|
606 |
|
607 // panic if we get other session notification |
|
608 CheckConsistency( iSessionId, aCspId ); |
|
609 TPEngNWSessionSlotEvent event; |
|
610 // Operation id -1 means that server kicked us out |
|
611 if ( aId == -1 ) |
|
612 { |
|
613 event = EPEngEventNWSessionClosedByServer; |
|
614 } |
|
615 else |
|
616 { |
|
617 event = EPEngEventAppNWPresenceSessionClosed; |
|
618 } |
|
619 |
|
620 if ( iStatus ) |
|
621 { |
|
622 if ( iOperation == EDoingLogOut ) |
|
623 { |
|
624 User::RequestComplete( iStatus, KErrNone ); |
|
625 } |
|
626 else |
|
627 { |
|
628 User::RequestComplete( iStatus, KErrCancel ); |
|
629 } |
|
630 iStatus = NULL; |
|
631 iOperation = EIdle; |
|
632 iOpId = KErrNone; |
|
633 } |
|
634 |
|
635 // notify observers |
|
636 NotifyIfNewStateL( EPEngNWPresenceSessionClosed, event ); |
|
637 } |
|
638 |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // CPEngAccessHandler::HandleLoginCancelL() |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 void CPEngAccessHandler::HandleLoginCancelL( |
|
645 TInt aCancelledOpId, |
|
646 TImpsCspIdentifier& aCspId ) |
|
647 { |
|
648 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::HandleLoginCancelL - id: %d" ), |
|
649 aCancelledOpId ); |
|
650 |
|
651 // panic if we get other session notification |
|
652 CheckConsistency( iSessionId, aCspId ); |
|
653 __ASSERT_DEBUG( ( aCancelledOpId == iOpId ), |
|
654 User::Panic( KPEngTransferAdapterPanic, EOpIdConsistencyLost ) ); |
|
655 |
|
656 iSessStatus = EPEngNWPresenceSessionClosed; |
|
657 iOperation = EIdle; |
|
658 } |
|
659 |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CPEngAccessHandler::HandleNbrSessionsL() |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 void CPEngAccessHandler::HandleNbrSessionsL( |
|
666 TInt /* aId */, |
|
667 TInt /* aNbr */, |
|
668 TImpsCspIdentifier& /* aCspId */ ) |
|
669 { |
|
670 |
|
671 } |
|
672 |
|
673 |
|
674 // ============================================================================= |
|
675 // =============== New Functions of the MImpsErrorHandler ===================== |
|
676 // ============================================================================= |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CPEngAccessHandler::HandleErrorL() |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CPEngAccessHandler::HandleErrorL( |
|
683 TInt aStatus, |
|
684 TInt /*aOpId*/, |
|
685 const TDesC* /* aDescription */, |
|
686 const CImpsDetailed* /* aDetailedRes */, |
|
687 TImpsCspIdentifier& aCspId ) |
|
688 { |
|
689 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::HandleErrorL - id: %d" ), aStatus ); |
|
690 // panic if we get other session notification |
|
691 CheckConsistency( iSessionId, aCspId ); |
|
692 |
|
693 // we get here if service negotiation failed |
|
694 if ( iStatus ) |
|
695 { |
|
696 iOperation = EIdle; |
|
697 User::RequestComplete( iStatus, aStatus ); |
|
698 iStatus = NULL; |
|
699 } |
|
700 } |
|
701 |
|
702 |
|
703 // ============================================================================= |
|
704 // =============== New Functions of the MImpsStatusHandler ===================== |
|
705 // ============================================================================= |
|
706 |
|
707 // ----------------------------------------------------------------------------- |
|
708 // CPEngAccessHandler::HandleStatusChangeL() |
|
709 // ----------------------------------------------------------------------------- |
|
710 // |
|
711 void CPEngAccessHandler::HandleStatusChangeL( |
|
712 TImpsServiceStatus aStatus, |
|
713 TImpsCspIdentifier& aCspId ) |
|
714 { |
|
715 PENG_DP( D_PENG_LIT( "CPEngAccessHandler::HandleStatusChangeL: %d" ), aStatus ); |
|
716 // panic if we get other session notification |
|
717 CheckConsistency( iSessionId, aCspId ); |
|
718 switch ( aStatus ) |
|
719 { |
|
720 case EImps_ON_LINE: |
|
721 { |
|
722 HandleLogInCompletionL(); |
|
723 break; |
|
724 } |
|
725 case EImps_NOT_LOGGED: |
|
726 { |
|
727 NotifyIfNewStateL( EPEngNWPresenceSessionClosed, |
|
728 EPEngEventAppNWPresenceSessionClosed ); |
|
729 iServiceFetched = EFalse; |
|
730 break; |
|
731 } |
|
732 case EImps_SHUTTING_DOWN: |
|
733 { |
|
734 NotifyIfNewStateL( EPEngNWPresenceSessionClosed, |
|
735 EPEngEventNWSessionClosedByServer ); |
|
736 iServiceFetched = EFalse; |
|
737 break; |
|
738 } |
|
739 default: |
|
740 { |
|
741 // do nothing |
|
742 User::Panic( KPEngTransferAdapterPanic, EUnknownUnumeration ); |
|
743 } |
|
744 } |
|
745 } |
|
746 |
|
747 |
|
748 // ============================================================================= |
|
749 // =============== New Private Functions of main class ========================= |
|
750 // ============================================================================= |
|
751 |
|
752 // ----------------------------------------------------------------------------- |
|
753 // CPEngAccessHandler::CopyTree() |
|
754 // Copy service tree |
|
755 // (other items were commented in a header). |
|
756 // ----------------------------------------------------------------------------- |
|
757 // |
|
758 void CPEngAccessHandler::CopyServiceTree( |
|
759 TImpsServices& aFrom ) |
|
760 { |
|
761 PENG_DP( D_PENG_LIT( "Network session capability details:" ) ); |
|
762 |
|
763 TImpsFeature* wvFeature = NULL; |
|
764 // fundamental features |
|
765 wvFeature = aFrom.Feature( EFundamentalFeat ); |
|
766 if ( wvFeature ) |
|
767 { |
|
768 CopyFeatureSubtree( iServices.iFundamentalFeat, |
|
769 *wvFeature, |
|
770 KFuncMapFundamental, |
|
771 KSubFuncMapFundamental ); |
|
772 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
773 DebugDumpFeatureSubtree( _L( "FundamentalFeatures" ), // CSI: 78 # |
|
774 iServices.iFundamentalFeat, |
|
775 KFuncMapFundamental, |
|
776 KSubFuncMapFundamental ); |
|
777 #endif |
|
778 } |
|
779 |
|
780 wvFeature = NULL; |
|
781 // Presence features |
|
782 wvFeature = aFrom.Feature( EPresenceFeat ); |
|
783 if ( wvFeature ) |
|
784 { |
|
785 CopyFeatureSubtree( iServices.iPresenceFeat, |
|
786 *wvFeature, |
|
787 KFuncMapPresence, |
|
788 KSubFuncMapPresence ); |
|
789 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
790 DebugDumpFeatureSubtree( _L( "PresenceFeatures" ), // CSI: 78 # |
|
791 iServices.iPresenceFeat, |
|
792 KFuncMapPresence, |
|
793 KSubFuncMapPresence ); |
|
794 #endif |
|
795 } |
|
796 |
|
797 wvFeature = NULL; |
|
798 // Im features |
|
799 wvFeature = aFrom.Feature( EIMFeat ); |
|
800 if ( wvFeature ) |
|
801 { |
|
802 CopyFeatureSubtree( iServices.iIMFeat, |
|
803 *wvFeature, |
|
804 KFuncMapIm, |
|
805 KSubFuncMapIm ); |
|
806 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
807 DebugDumpFeatureSubtree( _L( "IMFeatures" ), // CSI: 78 # |
|
808 iServices.iIMFeat, |
|
809 KFuncMapIm, |
|
810 KSubFuncMapIm ); |
|
811 #endif |
|
812 } |
|
813 |
|
814 wvFeature = NULL; |
|
815 // Group features |
|
816 wvFeature = aFrom.Feature( EGroupFeat ); |
|
817 if ( wvFeature ) |
|
818 { |
|
819 CopyFeatureSubtree( iServices.iGroupFeat, |
|
820 *wvFeature, |
|
821 KFuncMapGroup, |
|
822 KSubFuncMapGroup ); |
|
823 #ifdef PENG_ENABLE_DEBUG_PRINT |
|
824 DebugDumpFeatureSubtree( _L( "GroupFeatures" ), // CSI: 78 # |
|
825 iServices.iGroupFeat, |
|
826 KFuncMapGroup, |
|
827 KSubFuncMapGroup ); |
|
828 #endif |
|
829 } |
|
830 } |
|
831 |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CPEngAccessHandler::NotifyIfNewStateL() |
|
835 // Notify if new state |
|
836 // (other items were commented in a header). |
|
837 // ----------------------------------------------------------------------------- |
|
838 // |
|
839 void CPEngAccessHandler::NotifyIfNewStateL( |
|
840 TPEngNWSessionSlotState aNewState, |
|
841 TPEngNWSessionSlotEvent aEvent ) |
|
842 { |
|
843 if ( iSessStatus != aNewState ) |
|
844 { |
|
845 iSessStatus = aNewState; |
|
846 for ( TInt x( iObservers.Count() - 1 ) ; x >= 0 ; --x ) |
|
847 { |
|
848 iObservers[ x ]->StatusChangedL( iSessStatus, aEvent ); |
|
849 } |
|
850 } |
|
851 } |
|
852 |
|
853 |
|
854 // ----------------------------------------------------------------------------- |
|
855 // CPEngAccessHandler::HandleLogInCompletionL() |
|
856 // Handle completion of the log in request |
|
857 // (other items were commented in a header). |
|
858 // ----------------------------------------------------------------------------- |
|
859 // |
|
860 void CPEngAccessHandler::HandleLogInCompletionL( ) |
|
861 { |
|
862 if ( !iServiceFetched ) |
|
863 { |
|
864 // copy tree of capabilities |
|
865 TImpsServices services; |
|
866 iAccessClient.GetServicesL( services ); |
|
867 CopyServiceTree( services ); |
|
868 iServiceFetched = ETrue; |
|
869 } |
|
870 |
|
871 NotifyIfNewStateL( EPEngNWPresenceSessionOpen, |
|
872 EPEngEventAppNWPresenceSessionOpened ); |
|
873 |
|
874 if ( iStatus ) |
|
875 { |
|
876 // handle Operation |
|
877 iOperation = EIdle; |
|
878 User::RequestComplete( iStatus, KErrNone ); |
|
879 iStatus = NULL; |
|
880 iOpId = KErrNone; |
|
881 } |
|
882 } |
|
883 |
|
884 // End of File |
|
885 |
|
886 |