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