|
1 /* |
|
2 * Copyright (c) 2008-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: Implementation of class CCchUiApiImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cchuilogger.h" |
|
20 #include "cchuiapiimpl.h" |
|
21 #include "cchuiobserver.h" |
|
22 #include "cchuispshandler.h" |
|
23 #include "cchuicchhandler.h" |
|
24 #include "cchuinotehandler.h" |
|
25 #include "cchuiclientobserver.h" |
|
26 #include "cchuiconnectionhandler.h" |
|
27 |
|
28 const TInt KServiceNameMaxLength = 255; |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CCchUiApiImpl* CCchUiApiImpl::NewL( CCch& aCch ) |
|
37 { |
|
38 CCchUiApiImpl* cchUiApiImpl = |
|
39 new ( ELeave ) CCchUiApiImpl(); |
|
40 CleanupStack::PushL( cchUiApiImpl ); |
|
41 cchUiApiImpl->ConstructL( aCch ); |
|
42 CleanupStack::Pop( cchUiApiImpl ); |
|
43 return cchUiApiImpl; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CCchUiApiImpl::CCchUiApiImpl(): |
|
51 iReEnableService( EFalse ), |
|
52 iRemovableConnection( KErrNone ), |
|
53 iObservedService( 0 ) |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Constructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CCchUiApiImpl::ConstructL( CCch& aCch ) |
|
62 { |
|
63 iCCHHandler = CCchUiCchHandler::NewL( aCch ); |
|
64 iSpsHandler = CCchUiSpsHandler::NewL(); |
|
65 iNoteController = CCCHUiNoteHandler::NewL( *this ); |
|
66 iConnectionHandler = CCchUiConnectionHandler::NewL( |
|
67 *iCCHHandler, *iSpsHandler ); |
|
68 // voip sub service is by default the supported one. |
|
69 // Client can overwrite these |
|
70 iAllowedSubServices.AppendL( ECCHVoIPSub ); |
|
71 |
|
72 iLastOperationResult = |
|
73 MCchUiObserver::ECchUiClientOperationResultNotSet; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CCchUiApiImpl::~CCchUiApiImpl() |
|
81 { |
|
82 if ( iObservedService && iCCHHandler ) |
|
83 { |
|
84 TRAP_IGNORE( iCCHHandler->StopObservingL( |
|
85 iObservedService, *this ) ); |
|
86 } |
|
87 |
|
88 iAllowedNotes.Close(); |
|
89 iAllowedSubServices.Close(); |
|
90 iObservervedServices.Close(); |
|
91 iObservers.ResetAndDestroy(); |
|
92 iObservers.Close(); |
|
93 delete iCCHHandler; |
|
94 delete iNoteController; |
|
95 delete iSpsHandler; |
|
96 delete iConnectionHandler; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // AddObserver. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CCchUiApiImpl::AddObserverL( MCchUiObserver& aObserver ) |
|
104 { |
|
105 CCHUIDEBUG( "CCchUiApiImpl::AddObserver - IN"); |
|
106 |
|
107 // Check if already exists |
|
108 TBool alreadyExists = EFalse; |
|
109 for ( TInt i( 0 ) ; i < iObservers.Count() ; i++ ) |
|
110 { |
|
111 if ( &aObserver == &iObservers[ i ]->Observer() ) |
|
112 { |
|
113 CCHUIDEBUG( "AddObserver - already exists"); |
|
114 alreadyExists = ETrue; |
|
115 } |
|
116 } |
|
117 |
|
118 if ( !alreadyExists ) |
|
119 { |
|
120 CCHUIDEBUG( "AddObserver - add observer"); |
|
121 |
|
122 CCchUiClientObserver* capsulatedObs = |
|
123 CCchUiClientObserver::NewLC( aObserver ); |
|
124 |
|
125 iObservers.AppendL( capsulatedObs ); |
|
126 CleanupStack::Pop( capsulatedObs ); |
|
127 } |
|
128 |
|
129 CCHUIDEBUG( "CCchUiApiImpl::AddObserver - OUT"); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // RemoveObserver. |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CCchUiApiImpl::RemoveObserver( MCchUiObserver& aObserver ) |
|
137 { |
|
138 for ( TInt i = 0 ; i < iObservers.Count() ; i++ ) |
|
139 { |
|
140 if ( &aObserver == &iObservers[ i ]->Observer() ) |
|
141 { |
|
142 delete iObservers[ i ]; |
|
143 iObservers.Remove( i ); |
|
144 |
|
145 CCHUIDEBUG( "RemoveObserver - observer removed" ); |
|
146 } |
|
147 } |
|
148 iObservers.Compress(); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Show dialog. |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CCchUiApiImpl::ShowDialogL( |
|
156 TUint32 aServiceId, |
|
157 MCchUiObserver::TCchUiDialogType aDialog ) |
|
158 { |
|
159 CCHUIDEBUG2( "CCchUiApiImpl::ShowDialogL - aServiceId: %d", |
|
160 aServiceId ); |
|
161 CCHUIDEBUG2( "CCchUiApiImpl::ShowDialogL - aDialog: %d", |
|
162 aDialog ); |
|
163 |
|
164 TInt err( KErrNone ); |
|
165 |
|
166 // Get current connection iap id |
|
167 TInt iapId( KErrNone ); |
|
168 iCCHHandler->GetCurrentConnectionIapIdL( |
|
169 aServiceId, ECCHUnknown, iapId, err ); |
|
170 |
|
171 // Get current service username |
|
172 RBuf userName; |
|
173 CleanupClosePushL( userName ); |
|
174 userName.CreateL( KServiceNameLength ); |
|
175 iCCHHandler->GetUsernameL( aServiceId, userName, err ); |
|
176 |
|
177 if ( KErrNone == err || KErrNotFound == err ) |
|
178 { |
|
179 CCHUIDEBUG( "ShowDialogL -Launch note" ); |
|
180 iNoteController->LaunchNoteL( aDialog, aServiceId, iapId, userName ); |
|
181 } |
|
182 else // leave if error code other that KErrNone or KErrNotFound |
|
183 { |
|
184 CCHUIDEBUG2( "ShowDialogL - leave with err=%d", err ); |
|
185 User::Leave( err ); |
|
186 } |
|
187 |
|
188 CleanupStack::PopAndDestroy( &userName ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // Get currently showing dialog. |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CCchUiApiImpl::ConfigureVisualizationL( |
|
196 RArray<MCchUiObserver::TCchUiDialogType>& aAllowedNotes, |
|
197 RArray<TCCHSubserviceType>& aAllowedSubServices ) |
|
198 { |
|
199 CCHUIDEBUG( "CCchUiApiImpl::ConfigureVisualizationL - IN" ); |
|
200 |
|
201 CCHUIDEBUG2( "ConfigureVisualizationL - aAllowedNotes count=%d", |
|
202 aAllowedNotes.Count() ); |
|
203 CCHUIDEBUG2( "ConfigureVisualizationL - aAllowedSubServices count=%d", |
|
204 aAllowedSubServices.Count() ); |
|
205 |
|
206 TBool subServicesHandled = EFalse; |
|
207 TBool dialogsHandled = EFalse; |
|
208 |
|
209 // Reset old data |
|
210 iAllowedNotes.Reset(); |
|
211 iAllowedSubServices.Reset(); |
|
212 |
|
213 if ( KErrNotFound != aAllowedNotes.Find( |
|
214 MCchUiObserver::ECchUiDialogTypeNotSet ) ) |
|
215 { |
|
216 CCHUIDEBUG( "ConfigureVisualizationL - all dialogs are supported" ); |
|
217 dialogsHandled = ETrue; |
|
218 } |
|
219 |
|
220 for ( TInt noteIndex = 0 ; |
|
221 noteIndex < aAllowedNotes.Count() && !dialogsHandled ; |
|
222 noteIndex++ ) |
|
223 { |
|
224 CCHUIDEBUG2( "ConfigureVisualizationL - appending allowed note: %d", |
|
225 aAllowedNotes[ noteIndex ] ); |
|
226 iAllowedNotes.AppendL( aAllowedNotes[ noteIndex ] ); |
|
227 } |
|
228 |
|
229 if ( KErrNotFound != aAllowedSubServices.Find( ECCHUnknown ) ) |
|
230 { |
|
231 CCHUIDEBUG( |
|
232 "ConfigureVisualizationL - all sub services are supported" ); |
|
233 iAllowedSubServices.AppendL( ECCHUnknown ); |
|
234 subServicesHandled = ETrue; |
|
235 } |
|
236 for ( TInt servIndex = 0 ; |
|
237 servIndex < aAllowedSubServices.Count() && subServicesHandled ; |
|
238 servIndex++ ) |
|
239 { |
|
240 CCHUIDEBUG2( |
|
241 "ConfigureVisualizationL - appending allowed sub service: %d", |
|
242 aAllowedSubServices[ servIndex ] ); |
|
243 iAllowedSubServices.AppendL( aAllowedSubServices[ servIndex ] ); |
|
244 } |
|
245 |
|
246 CCHUIDEBUG( "CCchUiApiImpl::ConfigureVisualizationL - OUT" ); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // Cancel notes/dialogs. |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CCchUiApiImpl::CancelNotes() |
|
254 { |
|
255 CCHUIDEBUG( "CCchUiApiImpl::CancelNotes" ); |
|
256 iNoteController->CancelOldNotes(); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // Manual enable has proceeded |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void CCchUiApiImpl::ManualEnableResultL( |
|
264 TUint aServiceId, |
|
265 TInt aEnableResult ) |
|
266 { |
|
267 CCHUIDEBUG( "CCchUiApiImpl::ManualEnableResultL - IN" ); |
|
268 |
|
269 if ( KErrNone == aEnableResult ) |
|
270 { |
|
271 CCHUIDEBUG( "ManualEnableStartedL - start observing service" ); |
|
272 iCCHHandler->StartObservingL( aServiceId, *this ); |
|
273 |
|
274 iObservedService = aServiceId; |
|
275 |
|
276 // Check if id already exists in observed services |
|
277 TInt err = iObservervedServices.Find( aServiceId ); |
|
278 |
|
279 // Append id only if it is not found. |
|
280 if ( KErrNotFound == err ) |
|
281 { |
|
282 CCHUIDEBUG( "ManualEnableStartedL - add to observerd services" ); |
|
283 iObservervedServices.AppendL( aServiceId ); |
|
284 } |
|
285 } |
|
286 else |
|
287 { |
|
288 HandleManualEnableErrorL( aServiceId, aEnableResult ); |
|
289 } |
|
290 |
|
291 CCHUIDEBUG( "CCchUiApiImpl::ManualEnableStartedL - OUT" ); |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // Manual enable error handling. |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 void CCchUiApiImpl::HandleManualEnableErrorL( |
|
299 TUint aServiceId, |
|
300 TInt aEnableResult ) |
|
301 { |
|
302 CCHUIDEBUG( "CCchUiApiImpl::HandleManualEnableErrorL - IN" ); |
|
303 CCHUIDEBUG2( " ---> aEnableResult: %d", aEnableResult ); |
|
304 |
|
305 MCchUiObserver::TCchUiDialogType dialogType = |
|
306 MCchUiObserver::ECchUiDialogTypeNotSet; |
|
307 |
|
308 switch ( aEnableResult ) |
|
309 { |
|
310 case KCCHErrorAccessPointNotDefined: |
|
311 { |
|
312 dialogType = MCchUiObserver::ECchUiDialogTypeNoConnectionDefined; |
|
313 } |
|
314 break; |
|
315 case KCCHErrorAuthenticationFailed: |
|
316 { |
|
317 dialogType = MCchUiObserver::ECchUiDialogTypeAuthenticationFailed; |
|
318 } |
|
319 break; |
|
320 case KCCHErrorInvalidSettings: |
|
321 { |
|
322 dialogType = MCchUiObserver::ECchUiDialogTypeDefectiveSettings; |
|
323 } |
|
324 break; |
|
325 |
|
326 case KCCHErrorBandwidthInsufficient: |
|
327 { |
|
328 dialogType = MCchUiObserver::ECchUiDialogTypeErrorInConnection; |
|
329 } |
|
330 break; |
|
331 case KCCHErrorInvalidIap: |
|
332 case KCCHErrorNetworkLost: |
|
333 case KCCHErrorServiceNotResponding: |
|
334 { |
|
335 dialogType = MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable; |
|
336 } |
|
337 break; |
|
338 default: |
|
339 break; |
|
340 } |
|
341 |
|
342 // show dialog if dialog type set and dialog allowed |
|
343 if ( ( MCchUiObserver::ECchUiDialogTypeNotSet != dialogType ) && |
|
344 ( DialogIsAllowed( dialogType ) ) ) |
|
345 { |
|
346 ShowDialogL( aServiceId, dialogType ); |
|
347 } |
|
348 |
|
349 CCHUIDEBUG( "CCchUiApiImpl::HandleManualEnableErrorL - OUT" ); |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // Handle dialog completed situation. |
|
354 // --------------------------------------------------------------------------- |
|
355 // |
|
356 void CCchUiApiImpl::DialogCompletedL( |
|
357 TInt aCompleteCode, |
|
358 TCCHUiNotifierParams aResultParams ) |
|
359 { |
|
360 CCHUIDEBUG( "CCchUiApiImpl::DialogCompletedL - IN"); |
|
361 CCHUIDEBUG2( "DialogCompletedL - complete code=%d", aCompleteCode ); |
|
362 CCHUIDEBUG2( "DialogCompletedL - dialog mode=%d", |
|
363 aResultParams.iDialogMode ); |
|
364 |
|
365 switch ( aResultParams.iDialogMode ) |
|
366 { |
|
367 case MCchUiObserver::ECchUiDialogTypeUsernamePasswordFailed: |
|
368 { |
|
369 // Show username/password query. |
|
370 __ASSERT_ALWAYS( DialogIsAllowed( |
|
371 MCchUiObserver::ECchUiDialogTypeAuthenticationFailed ), |
|
372 User::Leave( KErrNotSupported ) ); |
|
373 |
|
374 CancelNotes(); |
|
375 ShowDialogL( |
|
376 aResultParams.iServiceId, |
|
377 MCchUiObserver::ECchUiDialogTypeAuthenticationFailed ); |
|
378 } |
|
379 break; |
|
380 case MCchUiObserver::ECchUiDialogTypeAuthenticationFailed: |
|
381 { |
|
382 DoHandleAuthenticationFailedCompleteL( |
|
383 aCompleteCode, aResultParams ); |
|
384 } |
|
385 break; |
|
386 case MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable: |
|
387 case MCchUiObserver::ECchUiDialogTypeNoConnectionDefined: |
|
388 { |
|
389 DoHandleNoConnectionsCompleteL( |
|
390 aCompleteCode, aResultParams ); |
|
391 } |
|
392 break; |
|
393 |
|
394 case MCchUiObserver::ECchUiDialogTypeDefectiveSettings: |
|
395 { |
|
396 // Defective settings is permanent type of condition. |
|
397 iCCHHandler->DisableL( aResultParams.iServiceId ); |
|
398 iLastOperationResult = |
|
399 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
400 } |
|
401 break; |
|
402 case MCchUiObserver::ECchUiDialogTypeErrorInConnection: |
|
403 { |
|
404 // Show confirm change connection query |
|
405 __ASSERT_ALWAYS( DialogIsAllowed( |
|
406 MCchUiObserver::ECchUiDialogTypeConfirmChangeConnection ), |
|
407 User::Leave( KErrNotSupported ) ); |
|
408 |
|
409 CancelNotes(); |
|
410 ShowDialogL( |
|
411 aResultParams.iServiceId, |
|
412 MCchUiObserver::ECchUiDialogTypeConfirmChangeConnection ); |
|
413 } |
|
414 break; |
|
415 case MCchUiObserver::ECchUiDialogTypeConfirmChangeConnection: |
|
416 { |
|
417 DoHandleConfirmChangeConnectionCompleteL( |
|
418 aCompleteCode, aResultParams ); |
|
419 } |
|
420 break; |
|
421 case MCchUiObserver::ECchUiDialogTypeChangeConnection: |
|
422 { |
|
423 DoHandleChangeConnectionCompleteL( |
|
424 aCompleteCode, aResultParams ); |
|
425 } |
|
426 break; |
|
427 default: |
|
428 CCHUIDEBUG( "DialogCompletedL - default switch case" ); |
|
429 break; |
|
430 } |
|
431 |
|
432 CCHUIDEBUG( "CCchUiApiImpl::DialogCompletedL - OUT" ); |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------------------------- |
|
436 // Checks if specific note is allowed |
|
437 // --------------------------------------------------------------------------- |
|
438 // |
|
439 TBool CCchUiApiImpl::DialogIsAllowed( |
|
440 MCchUiObserver::TCchUiDialogType aDialog ) |
|
441 { |
|
442 CCHUIDEBUG( "CCchUiApiImpl::DialogIsAllowed"); |
|
443 CCHUIDEBUG2( "CCchUiApiImpl::DialogIsAllowed - allowed notes count=%d", |
|
444 iAllowedNotes.Count() ); |
|
445 CCHUIDEBUG2( "CCchUiApiImpl::DialogIsAllowed - aDialog find result=%d", |
|
446 iAllowedNotes.Find( aDialog ) ); |
|
447 |
|
448 TBool ret = EFalse; |
|
449 if ( !iAllowedNotes.Count() ) return ETrue; // not configured, all allowed |
|
450 else if ( KErrNotFound != iAllowedNotes.Find( |
|
451 MCchUiObserver::ECchUiDialogTypeNotSet ) ) return ETrue; |
|
452 else if ( KErrNotFound != iAllowedNotes.Find( aDialog ) ) return ETrue; |
|
453 |
|
454 CCHUIDEBUG2( "DialogIsAllowed - return: %d", ret ); |
|
455 return ret; |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // Checks if specific sub service is allowed |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 TBool CCchUiApiImpl::SubServiceIsAllowed( TCCHSubserviceType aSubService ) |
|
463 { |
|
464 CCHUIDEBUG( "CCchUiApiImpl::SubServiceIsAllowed"); |
|
465 |
|
466 CCHUIDEBUG2( "SubServiceIsAllowed - allowed subserv=%d", |
|
467 iAllowedSubServices.Count() ); |
|
468 CCHUIDEBUG2( "SubServiceIsAllowed - aSubService find=%d", |
|
469 iAllowedSubServices.Find( aSubService ) ); |
|
470 CCHUIDEBUG2( "SubServiceIsAllowed - all supported=%d", |
|
471 iAllowedSubServices.Find( ECCHUnknown ) ); |
|
472 |
|
473 // If subservice type is ECCHUnknown -> subservice is allowed, other |
|
474 // types are checked from array. |
|
475 TBool allowed = EFalse; |
|
476 TInt result = iAllowedSubServices.Find( aSubService ); |
|
477 |
|
478 if ( ECCHUnknown == aSubService ) |
|
479 { |
|
480 allowed = ETrue; |
|
481 } |
|
482 else if ( KErrNotFound != result ) |
|
483 { |
|
484 allowed = ETrue; |
|
485 } |
|
486 else |
|
487 { |
|
488 allowed = EFalse; |
|
489 } |
|
490 |
|
491 CCHUIDEBUG2( "SubServiceIsAllowed - return: %d", allowed ); |
|
492 return allowed; |
|
493 } |
|
494 |
|
495 // --------------------------------------------------------------------------- |
|
496 // Checks subservice state is allowed for showing dialogs. |
|
497 // --------------------------------------------------------------------------- |
|
498 // |
|
499 TBool CCchUiApiImpl::StateIsAllowed( const TCCHSubserviceState aState ) |
|
500 { |
|
501 CCHUIDEBUG( "CCchUiApiImpl::StateIsAllowed"); |
|
502 |
|
503 TBool allowed( EFalse ); |
|
504 |
|
505 switch ( aState ) |
|
506 { |
|
507 case ECCHUninitialized: |
|
508 case ECCHDisabled: |
|
509 case ECCHDisconnecting: |
|
510 { |
|
511 CCHUIDEBUG( "CCchUiApiImpl::StateIsAllowed: Not allowed"); |
|
512 } |
|
513 break; |
|
514 case ECCHConnecting: |
|
515 case ECCHEnabled: |
|
516 { |
|
517 CCHUIDEBUG( "CCchUiApiImpl::StateIsAllowed: Allowed"); |
|
518 allowed = ETrue; |
|
519 } |
|
520 break; |
|
521 default: |
|
522 CCHUIDEBUG( "CCchUiApiImpl::StateIsAllowed: DEFAULT case"); |
|
523 break; |
|
524 } |
|
525 |
|
526 return allowed; |
|
527 } |
|
528 |
|
529 // --------------------------------------------------------------------------- |
|
530 // Handles re-enabling of service. |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 void CCchUiApiImpl::HandleServiceReEnablingL( TUint aServiceId ) |
|
534 { |
|
535 if ( iRemovableConnection ) |
|
536 { |
|
537 CCHUIDEBUG( |
|
538 "DoHandleServiceEventL - removing old connection" ); |
|
539 |
|
540 RBuf serviceName; |
|
541 CleanupClosePushL( serviceName ); |
|
542 serviceName.CreateL( KServiceNameMaxLength ); |
|
543 |
|
544 iSpsHandler->ServiceNameL( |
|
545 aServiceId, |
|
546 serviceName ); |
|
547 |
|
548 // Remove old connection |
|
549 iConnectionHandler->RemoveConnectionL( |
|
550 serviceName, iRemovableConnection ); |
|
551 |
|
552 CleanupStack::PopAndDestroy( &serviceName ); |
|
553 } |
|
554 |
|
555 CCHUIDEBUG( "HandleServiceReEnablingL - Re-Enabling service" ); |
|
556 |
|
557 iReEnableService = EFalse; |
|
558 iCCHHandler->EnableL( aServiceId ); |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // Handle authentication failed completed situation. |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 void CCchUiApiImpl::DoHandleAuthenticationFailedCompleteL( |
|
566 TInt aCompleteCode, |
|
567 TCCHUiNotifierParams aResultParams ) |
|
568 { |
|
569 CCHUIDEBUG( "CCchUiApiImpl::DoHandleAuthenticationFailedCompleteL - IN"); |
|
570 |
|
571 switch ( aCompleteCode ) |
|
572 { |
|
573 case KErrNone: |
|
574 { |
|
575 TInt err( KErrNone ); |
|
576 |
|
577 // Set username |
|
578 iCCHHandler->SetUsernameL( aResultParams, err ); |
|
579 |
|
580 // If no error set also password |
|
581 if ( !err ) |
|
582 { |
|
583 iCCHHandler->SetPasswordL( aResultParams, err ); |
|
584 } |
|
585 else |
|
586 { |
|
587 iLastOperationResult = |
|
588 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
589 } |
|
590 |
|
591 // Both username and password set succesfully. |
|
592 if ( !err ) |
|
593 { |
|
594 iLastOperationResult = |
|
595 MCchUiObserver::ECchUiClientOperationResultCredentialsChanged; |
|
596 } |
|
597 else |
|
598 { |
|
599 iLastOperationResult = |
|
600 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
601 } |
|
602 |
|
603 aCompleteCode = err; |
|
604 break; |
|
605 } |
|
606 case KErrAlreadyExists: |
|
607 { |
|
608 // dialog active, do nothing |
|
609 break; |
|
610 } |
|
611 case KErrCancel: |
|
612 { |
|
613 iLastOperationResult = |
|
614 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
615 break; |
|
616 } |
|
617 default: |
|
618 { |
|
619 CCHUIDEBUG( |
|
620 "DoHandleAuthenticationFailedCompleteL - switch default case"); |
|
621 iLastOperationResult = |
|
622 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
623 break; |
|
624 } |
|
625 } |
|
626 |
|
627 switch ( iLastOperationResult ) |
|
628 { |
|
629 case MCchUiObserver::ECchUiClientOperationResultCredentialsChanged: |
|
630 { |
|
631 iCCHHandler->EnableL( aResultParams.iServiceId ); |
|
632 break; |
|
633 } |
|
634 default: |
|
635 { |
|
636 iCCHHandler->DisableL( aResultParams.iServiceId ); |
|
637 break; |
|
638 } |
|
639 } |
|
640 |
|
641 CCHUIDEBUG( "CCchUiApiImpl::DoHandleAuthenticationFailedCompleteL - OUT"); |
|
642 } |
|
643 |
|
644 |
|
645 // --------------------------------------------------------------------------- |
|
646 // Handle no connections complete situation. |
|
647 // --------------------------------------------------------------------------- |
|
648 // |
|
649 void CCchUiApiImpl::DoHandleNoConnectionsCompleteL( |
|
650 TInt aCompleteCode, |
|
651 TCCHUiNotifierParams aResultParams ) |
|
652 { |
|
653 CCHUIDEBUG( "CCchUiApiImpl::DoHandleNoConnectionsCompleteL - IN"); |
|
654 |
|
655 if ( KErrNone == aCompleteCode ) |
|
656 { |
|
657 switch( aResultParams.iOperationCommand ) |
|
658 { |
|
659 case ECchUiCommandSearchWlan: |
|
660 { |
|
661 HandleSearchWlanCompleteL( |
|
662 aCompleteCode, aResultParams ); |
|
663 break; |
|
664 } |
|
665 case ECchUiCommandCopyGprs: |
|
666 { |
|
667 HandleCopyGprsCompleteL( |
|
668 aCompleteCode, aResultParams ); |
|
669 break; |
|
670 } |
|
671 case ECchUiCommandGprsNotFound: |
|
672 { |
|
673 CCHUIDEBUG( " -> GPRS was not found"); |
|
674 iLastOperationResult = |
|
675 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
676 break; |
|
677 } |
|
678 case ECchUiCommandEnableCancelled: |
|
679 { |
|
680 iLastOperationResult = |
|
681 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
682 break; |
|
683 } |
|
684 case ECchUiCommandConnectWhenAvailable: |
|
685 { |
|
686 iLastOperationResult = |
|
687 MCchUiObserver::ECchUiClientOperationResultNotSet; |
|
688 break; |
|
689 } |
|
690 default: |
|
691 { |
|
692 CCHUIDEBUG( " -> !DEFAULT!"); |
|
693 iLastOperationResult = |
|
694 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
695 } |
|
696 break; |
|
697 } |
|
698 } |
|
699 else if ( KErrAlreadyExists == aCompleteCode ) |
|
700 { |
|
701 // dialog active, do nothing |
|
702 } |
|
703 else if ( KErrCancel == aCompleteCode ) |
|
704 { |
|
705 iLastOperationResult = |
|
706 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
707 } |
|
708 else |
|
709 { |
|
710 iLastOperationResult = |
|
711 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
712 } |
|
713 |
|
714 switch ( iLastOperationResult ) |
|
715 { |
|
716 case MCchUiObserver::ECchUiClientOperationResultAccessPointAdded: |
|
717 { |
|
718 // New access point was added --> enable service |
|
719 iCCHHandler->EnableL( aResultParams.iServiceId ); |
|
720 break; |
|
721 } |
|
722 case MCchUiObserver::ECchUiClientOperationResultNotSet: |
|
723 { |
|
724 // If no operation result set, do nothing |
|
725 break; |
|
726 } |
|
727 // By default disable service |
|
728 default: |
|
729 { |
|
730 CCHUIDEBUG( " -> !DEFAULT!"); |
|
731 CCHUIDEBUG( " -> Disabling service"); |
|
732 iCCHHandler->DisableL( aResultParams.iServiceId ); |
|
733 break; |
|
734 } |
|
735 } |
|
736 |
|
737 CCHUIDEBUG( "CCchUiApiImpl::DoHandleNoConnectionsCompleteL - OUT"); |
|
738 } |
|
739 |
|
740 // --------------------------------------------------------------------------- |
|
741 // Handle change connection confirmation note complete situation. |
|
742 // --------------------------------------------------------------------------- |
|
743 // |
|
744 void CCchUiApiImpl::DoHandleConfirmChangeConnectionCompleteL( |
|
745 TInt aCompleteCode, |
|
746 TCCHUiNotifierParams aResultParams ) |
|
747 { |
|
748 CCHUIDEBUG( |
|
749 "CCchUiApiImpl::DoHandleConfirmChangeConnectionCompleteL - IN"); |
|
750 |
|
751 switch( aCompleteCode ) |
|
752 { |
|
753 case KErrNone: |
|
754 { |
|
755 // show change connection query |
|
756 __ASSERT_ALWAYS( DialogIsAllowed( |
|
757 MCchUiObserver::ECchUiDialogTypeChangeConnection ), |
|
758 User::Leave( KErrNotSupported ) ); |
|
759 |
|
760 // Set removable connection which is removed when connection |
|
761 // is changed successfully |
|
762 if ( aResultParams.iRemoveOldConnection ) |
|
763 { |
|
764 iRemovableConnection = aResultParams.iCurrentConnectionIapId; |
|
765 } |
|
766 |
|
767 CancelNotes(); |
|
768 ShowDialogL( |
|
769 aResultParams.iServiceId, |
|
770 MCchUiObserver::ECchUiDialogTypeChangeConnection ); |
|
771 break; |
|
772 } |
|
773 case KErrCancel: |
|
774 { |
|
775 iLastOperationResult = |
|
776 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
777 break; |
|
778 } |
|
779 default: |
|
780 { |
|
781 CCHUIDEBUG( |
|
782 "DoHandleConfirmChangeConnectionCompleteL - default switch case"); |
|
783 |
|
784 iLastOperationResult = |
|
785 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
786 break; |
|
787 } |
|
788 } |
|
789 |
|
790 CCHUIDEBUG( |
|
791 "CCchUiApiImpl::DoHandleConfirmChangeConnectionCompleteL - OUT"); |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // Handle change connection query complete situation. |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 void CCchUiApiImpl::DoHandleChangeConnectionCompleteL( |
|
799 TInt aCompleteCode, |
|
800 TCCHUiNotifierParams aResultParams ) |
|
801 { |
|
802 CCHUIDEBUG( "CCchUiApiImpl::DoHandleChangeConnectionCompleteL - IN"); |
|
803 |
|
804 switch( aCompleteCode ) |
|
805 { |
|
806 case KErrNone: |
|
807 { |
|
808 HandleChangeConnectionL( |
|
809 aCompleteCode, aResultParams ); |
|
810 break; |
|
811 } |
|
812 case KErrCancel: |
|
813 { |
|
814 iLastOperationResult = |
|
815 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
816 break; |
|
817 } |
|
818 default: |
|
819 { |
|
820 CCHUIDEBUG( |
|
821 "DoHandleChangeConnectionCompleteL - default switch case"); |
|
822 |
|
823 iLastOperationResult = |
|
824 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
825 |
|
826 break; |
|
827 } |
|
828 } |
|
829 |
|
830 CCHUIDEBUG( "CCchUiApiImpl::DoHandleChangeConnectionCompleteL - OUT"); |
|
831 } |
|
832 |
|
833 // --------------------------------------------------------------------------- |
|
834 // Handles search wlan dialog result. |
|
835 // --------------------------------------------------------------------------- |
|
836 // |
|
837 void CCchUiApiImpl::HandleSearchWlanCompleteL( |
|
838 TInt& aCompleteCode, |
|
839 TCCHUiNotifierParams& aResultParams ) |
|
840 { |
|
841 CCHUIDEBUG( "CCchUiApiImpl::HandleSearchWlanCompleteL - IN"); |
|
842 |
|
843 CCHUIDEBUG( "HandleSearchWlanCompleteL - begin wlan search"); |
|
844 |
|
845 TInt err( KErrNone ); |
|
846 TInt snapId( KErrNone ); |
|
847 |
|
848 iCCHHandler->GetConnectionSnapIdL( |
|
849 aResultParams.iServiceId, snapId, err ); |
|
850 |
|
851 if ( !err ) |
|
852 { |
|
853 CCHUIDEBUG2( |
|
854 "HandleSearchWlanCompleteL - service snap is: %d", snapId ); |
|
855 |
|
856 HBufC* serviceName = HBufC::NewLC( KServiceNameMaxLength ); |
|
857 TPtr serviceNamePtr( serviceName->Des() ); |
|
858 |
|
859 CCHUIDEBUG( "HandleSearchWlanCompleteL - get service name"); |
|
860 |
|
861 iSpsHandler->ServiceNameL( |
|
862 aResultParams.iServiceId, serviceNamePtr ); |
|
863 |
|
864 CCHUIDEBUG( "HandleSearchWlanCompleteL - proceed to wlan search"); |
|
865 |
|
866 TRAP( err, iConnectionHandler->SearchAccessPointsL( |
|
867 aResultParams.iServiceId, |
|
868 snapId, |
|
869 serviceNamePtr ) ); |
|
870 |
|
871 CCHUIDEBUG2( "HandleSearchWlanCompleteL - wlan search err: %d", err ); |
|
872 |
|
873 CleanupStack::PopAndDestroy( serviceName ); |
|
874 |
|
875 HandleSearchAccessPointsErrorL( |
|
876 err, aCompleteCode, aResultParams ); |
|
877 } |
|
878 |
|
879 CCHUIDEBUG( "CCchUiApiImpl::HandleSearchWlanCompleteL - OUT"); |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
|
883 // Handles search access points error code. |
|
884 // --------------------------------------------------------------------------- |
|
885 // |
|
886 void CCchUiApiImpl::HandleSearchAccessPointsErrorL( |
|
887 TInt aErr, |
|
888 TInt& aCompleteCode, |
|
889 TCCHUiNotifierParams& /*aResultParams*/ ) |
|
890 { |
|
891 CCHUIDEBUG( "CCchUiApiImpl::HandleSearchAccessPointsErrorL - IN" ); |
|
892 |
|
893 switch ( aErr ) |
|
894 { |
|
895 case KErrNone: |
|
896 { |
|
897 CCHUIDEBUG( |
|
898 "HandleSearchAccessPointsErrorL - access point added" ); |
|
899 iLastOperationResult = |
|
900 MCchUiObserver::ECchUiClientOperationResultAccessPointAdded; |
|
901 break; |
|
902 } |
|
903 case KErrCancel: // user cancel |
|
904 { |
|
905 CCHUIDEBUG( "HandleSearchAccessPointsErrorL - error, cancelled"); |
|
906 iLastOperationResult = |
|
907 MCchUiObserver::ECchUiClientOperationResultUserCancelled; |
|
908 break; |
|
909 } |
|
910 default: // other errors |
|
911 { |
|
912 CCHUIDEBUG( |
|
913 "HandleSearchAccessPointsErrorL - error, set general failure"); |
|
914 |
|
915 aCompleteCode = aErr; |
|
916 iLastOperationResult = |
|
917 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
918 } |
|
919 } |
|
920 |
|
921 CCHUIDEBUG( "CCchUiApiImpl::HandleSearchAccessPointsErrorL - OUT" ); |
|
922 } |
|
923 |
|
924 // --------------------------------------------------------------------------- |
|
925 // Handles search wlan dialog result when use gprs selected. |
|
926 // --------------------------------------------------------------------------- |
|
927 // |
|
928 void CCchUiApiImpl::HandleCopyGprsCompleteL( |
|
929 TInt& /*aCompleteCode*/, |
|
930 TCCHUiNotifierParams& aResultParams ) |
|
931 { |
|
932 CCHUIDEBUG( "CCchUiApiImpl::HandleCopyGprsCompleteL - IN" ); |
|
933 |
|
934 // User selected gprs access point which will now be stored in |
|
935 // service snap |
|
936 TInt snapId( KErrNone ); |
|
937 |
|
938 HBufC* serviceName = HBufC::NewLC( KServiceNameMaxLength ); |
|
939 TPtr serviceNamePtr( serviceName->Des() ); |
|
940 |
|
941 iSpsHandler->ServiceNameL( |
|
942 aResultParams.iServiceId, |
|
943 serviceNamePtr ); |
|
944 |
|
945 TInt err( KErrNone ); |
|
946 iCCHHandler->GetConnectionSnapIdL( |
|
947 aResultParams.iServiceId, |
|
948 snapId, |
|
949 err ); |
|
950 |
|
951 if ( !err ) |
|
952 { |
|
953 CCHUIDEBUG2( |
|
954 "HandleCopyGprsCompleteL - proceed, target snap is: %d", snapId ); |
|
955 CCHUIDEBUG2( |
|
956 "HandleCopyGprsCompleteL - proceed, service id is: %d", |
|
957 aResultParams.iServiceId ); |
|
958 CCHUIDEBUG2( "HandleCopyGprsCompleteL - gprs iap id is: %d", |
|
959 aResultParams.iGprsIapId ); |
|
960 |
|
961 iConnectionHandler->CopyIapToServiceSnapL( |
|
962 aResultParams.iServiceId, serviceNamePtr, |
|
963 aResultParams.iGprsIapId, snapId ); |
|
964 |
|
965 CCHUIDEBUG( "HandleCopyGprsCompleteL - copy gprs iap done ok"); |
|
966 |
|
967 CleanupStack::PopAndDestroy( serviceName ); |
|
968 |
|
969 iLastOperationResult = |
|
970 MCchUiObserver::ECchUiClientOperationResultAccessPointAdded; |
|
971 |
|
972 CCHUIDEBUG( " -> copy gprs iap done ok, enable"); |
|
973 iCCHHandler->EnableL( aResultParams.iServiceId ); |
|
974 } |
|
975 else |
|
976 { |
|
977 iLastOperationResult = |
|
978 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
979 User::Leave( err ); |
|
980 } |
|
981 |
|
982 CCHUIDEBUG( "CCchUiApiImpl::HandleCopyGprsCompleteL - OUT" ); |
|
983 } |
|
984 |
|
985 // --------------------------------------------------------------------------- |
|
986 // Handles changing to new connection. |
|
987 // --------------------------------------------------------------------------- |
|
988 // |
|
989 void CCchUiApiImpl::HandleChangeConnectionL( |
|
990 TInt& aCompleteCode, |
|
991 TCCHUiNotifierParams& aResultParams ) |
|
992 { |
|
993 CCHUIDEBUG( "CCchUiApiImpl::HandleChangeConnectionL - IN" ); |
|
994 |
|
995 switch ( aResultParams.iOperationCommand ) |
|
996 { |
|
997 case ECchUiCommandSearchWlan: |
|
998 { |
|
999 CCHUIDEBUG( "HandleChangeConnectionL - search wlan"); |
|
1000 HandleSearchWlanCompleteL( |
|
1001 aCompleteCode, aResultParams ); |
|
1002 break; |
|
1003 } |
|
1004 case ECchUiCommandCopyGprs: |
|
1005 { |
|
1006 CCHUIDEBUG( "HandleChangeConnectionL - copy gprs"); |
|
1007 HandleCopyGprsCompleteL( |
|
1008 aCompleteCode, aResultParams ); |
|
1009 break; |
|
1010 } |
|
1011 default: |
|
1012 { |
|
1013 CCHUIDEBUG( "HandleChangeConnectionL - default switch case"); |
|
1014 iLastOperationResult = |
|
1015 MCchUiObserver::ECchUiClientOperationResultGeneralFailure; |
|
1016 break; |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 switch ( iLastOperationResult ) |
|
1021 { |
|
1022 case MCchUiObserver::ECchUiClientOperationResultAccessPointAdded: |
|
1023 { |
|
1024 iLastOperationResult = |
|
1025 MCchUiObserver::ECchUiClientOperationResultConnectionChanged; |
|
1026 |
|
1027 CCHUIDEBUG( "HandleChangeConnectionL - re-enable service"); |
|
1028 |
|
1029 // Disable service and set iReEnable flag so that after service |
|
1030 // has disconnected we can connect with new access point. |
|
1031 iCCHHandler->StartObservingL( aResultParams.iServiceId, *this ); |
|
1032 |
|
1033 iReEnableService = ETrue; |
|
1034 |
|
1035 iObservedService = aResultParams.iServiceId; |
|
1036 |
|
1037 InformObserversL( aResultParams.iServiceId ); |
|
1038 iCCHHandler->DisableL( aResultParams.iServiceId ); |
|
1039 |
|
1040 // Check if id already exists in observed services |
|
1041 TInt error = iObservervedServices.Find( |
|
1042 aResultParams.iServiceId ); |
|
1043 |
|
1044 // Append id only if it is not found. |
|
1045 if ( KErrNotFound == error ) |
|
1046 { |
|
1047 CCHUIDEBUG( |
|
1048 "HandleChangeConnectionL add to observerd services" ); |
|
1049 iObservervedServices.AppendL( aResultParams.iServiceId ); |
|
1050 } |
|
1051 break; |
|
1052 } |
|
1053 default: |
|
1054 break; |
|
1055 } |
|
1056 |
|
1057 CCHUIDEBUG( "CCchUiApiImpl::HandleChangeConnectionL - OUT" ); |
|
1058 } |
|
1059 |
|
1060 // --------------------------------------------------------------------------- |
|
1061 // Observer implementation for service events. |
|
1062 // --------------------------------------------------------------------------- |
|
1063 // |
|
1064 void CCchUiApiImpl::ServiceStatusChanged( |
|
1065 TInt aServiceId, |
|
1066 TCCHSubserviceType aType, |
|
1067 const TCchServiceStatus& aServiceStatus ) |
|
1068 { |
|
1069 CCHUIDEBUG( "CCchUiApiImpl::ServiceStatusChanged - IN"); |
|
1070 |
|
1071 CCHUIDEBUG2( "ServiceStatusChanged - aServiceId: %d", |
|
1072 aServiceId ); |
|
1073 CCHUIDEBUG2( "ServiceStatusChanged - aError: %d", |
|
1074 aServiceStatus.Error() ); |
|
1075 CCHUIDEBUG2( "ServiceStatusChanged - aState: %d", |
|
1076 aServiceStatus.State() ); |
|
1077 CCHUIDEBUG2( "ServiceStatusChanged - aType: %d", |
|
1078 aType ); |
|
1079 |
|
1080 TInt observedPos = iObservervedServices.Find( aServiceId ); |
|
1081 |
|
1082 CCHUIDEBUG2( " -> observed position: %d", observedPos ); |
|
1083 |
|
1084 if ( KErrNotFound != observedPos ) |
|
1085 { |
|
1086 switch ( aServiceStatus.Error() ) |
|
1087 { |
|
1088 case KErrNone: |
|
1089 { |
|
1090 TRAP_IGNORE( DoHandleServiceEventL( |
|
1091 aServiceId, aType, aServiceStatus ) ); |
|
1092 break; |
|
1093 } |
|
1094 default: // all error codes but KErrNone |
|
1095 { |
|
1096 TRAP_IGNORE( DoHandleServiceErrorL( |
|
1097 aServiceId, aType, aServiceStatus ) ); |
|
1098 break; |
|
1099 } |
|
1100 } |
|
1101 } |
|
1102 |
|
1103 CCHUIDEBUG( "CCchUiApiImpl::ServiceStatusChanged - OUT"); |
|
1104 } |
|
1105 |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // Observer implementation for service events. |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // |
|
1110 void CCchUiApiImpl::DoHandleServiceErrorL( |
|
1111 TInt aServiceId, |
|
1112 TCCHSubserviceType aType, |
|
1113 const TCchServiceStatus& aServiceStatus ) |
|
1114 { |
|
1115 CCHUIDEBUG( "CCchUiApiImpl::DoHandleServiceErrorL - IN"); |
|
1116 |
|
1117 CCHUIDEBUG2( "DoHandleServiceErrorL - aServiceId: %d", |
|
1118 aServiceId ); |
|
1119 CCHUIDEBUG2( "DoHandleServiceErrorL - aError: %d", |
|
1120 aServiceStatus.Error() ); |
|
1121 CCHUIDEBUG2( "DoHandleServiceErrorL - aState: %d", |
|
1122 aServiceStatus.State() ); |
|
1123 |
|
1124 // Check that sub service is allowed |
|
1125 __ASSERT_ALWAYS( SubServiceIsAllowed( aType ), |
|
1126 User::Leave( KErrNotSupported ) ); |
|
1127 |
|
1128 // Double-check subservice state |
|
1129 TInt err( KErrNone ); |
|
1130 TCCHSubserviceState state = iCCHHandler->GetServiceStateL( |
|
1131 aServiceId, aType, err ); |
|
1132 |
|
1133 if ( err ) |
|
1134 { |
|
1135 User::Leave( err ); |
|
1136 } |
|
1137 |
|
1138 // Check that dialog showing is allowed. |
|
1139 __ASSERT_ALWAYS( StateIsAllowed( state ) || |
|
1140 KCCHErrorInvalidSettings == aServiceStatus.Error(), |
|
1141 User::Leave( KErrNotSupported ) ); |
|
1142 |
|
1143 switch ( aServiceStatus.Error() ) |
|
1144 { |
|
1145 case KCCHErrorAuthenticationFailed: |
|
1146 { |
|
1147 __ASSERT_ALWAYS( DialogIsAllowed( |
|
1148 MCchUiObserver::ECchUiDialogTypeUsernamePasswordFailed ), |
|
1149 User::Leave( KErrNotSupported ) ); |
|
1150 |
|
1151 ShowDialogL( |
|
1152 aServiceId, |
|
1153 MCchUiObserver::ECchUiDialogTypeUsernamePasswordFailed ); |
|
1154 } |
|
1155 break; |
|
1156 |
|
1157 case KCCHErrorInvalidSettings: |
|
1158 { |
|
1159 __ASSERT_ALWAYS( DialogIsAllowed( |
|
1160 MCchUiObserver::ECchUiDialogTypeDefectiveSettings ), |
|
1161 User::Leave( KErrNotSupported ) ); |
|
1162 |
|
1163 ShowDialogL( |
|
1164 aServiceId, |
|
1165 MCchUiObserver::ECchUiDialogTypeDefectiveSettings ); |
|
1166 } |
|
1167 break; |
|
1168 |
|
1169 case KCCHErrorInvalidIap: |
|
1170 case KCCHErrorNetworkLost: |
|
1171 case KCCHErrorServiceNotResponding: |
|
1172 { |
|
1173 __ASSERT_ALWAYS( DialogIsAllowed( |
|
1174 MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable ), |
|
1175 User::Leave( KErrNotSupported ) ); |
|
1176 |
|
1177 ShowDialogL( |
|
1178 aServiceId, |
|
1179 MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable ); |
|
1180 } |
|
1181 break; |
|
1182 |
|
1183 case KCCHErrorAccessPointNotDefined: |
|
1184 { |
|
1185 __ASSERT_ALWAYS( DialogIsAllowed( |
|
1186 MCchUiObserver::ECchUiDialogTypeNoConnectionDefined ), |
|
1187 User::Leave( KErrNotSupported ) ); |
|
1188 |
|
1189 ShowDialogL( |
|
1190 aServiceId, |
|
1191 MCchUiObserver::ECchUiDialogTypeNoConnectionDefined ); |
|
1192 } |
|
1193 break; |
|
1194 case KCCHErrorBandwidthInsufficient: |
|
1195 { |
|
1196 __ASSERT_ALWAYS( DialogIsAllowed( |
|
1197 MCchUiObserver::ECchUiDialogTypeErrorInConnection ), |
|
1198 User::Leave( KErrNotSupported ) ); |
|
1199 |
|
1200 ShowDialogL( |
|
1201 aServiceId, |
|
1202 MCchUiObserver::ECchUiDialogTypeErrorInConnection ); |
|
1203 } |
|
1204 break; |
|
1205 |
|
1206 case KErrCancel: |
|
1207 { |
|
1208 CCHUIDEBUG( "CCchUiApiImpl::DoHandleServiceErrorL - cancelled"); |
|
1209 CancelNotes(); |
|
1210 } |
|
1211 break; |
|
1212 |
|
1213 default: |
|
1214 break; |
|
1215 } |
|
1216 |
|
1217 CCHUIDEBUG( "CCchUiApiImpl::DoHandleServiceErrorL - OUT"); |
|
1218 } |
|
1219 |
|
1220 // --------------------------------------------------------------------------- |
|
1221 // Observer implementation for service events. |
|
1222 // --------------------------------------------------------------------------- |
|
1223 // |
|
1224 void CCchUiApiImpl::DoHandleServiceEventL( |
|
1225 TInt aServiceId, |
|
1226 TCCHSubserviceType aType, |
|
1227 const TCchServiceStatus& aServiceStatus ) |
|
1228 { |
|
1229 CCHUIDEBUG( "CCchUiApiImpl::DoHandleServiceEventL - IN" ); |
|
1230 |
|
1231 CCHUIDEBUG2( "DoHandleServiceEventL - aServiceId: %d", |
|
1232 aServiceId ); |
|
1233 CCHUIDEBUG2( "DoHandleServiceEventL - aError: %d", |
|
1234 aServiceStatus.Error() ); |
|
1235 CCHUIDEBUG2( "DoHandleServiceEventL - aState: %d", |
|
1236 aServiceStatus.State() ); |
|
1237 CCHUIDEBUG2( "DoHandleServiceEventL - aType: %d", |
|
1238 aType ); |
|
1239 |
|
1240 // Check that sub service is allowed |
|
1241 __ASSERT_ALWAYS( SubServiceIsAllowed( aType ), |
|
1242 User::Leave( KErrNotSupported ) ); |
|
1243 |
|
1244 switch ( aServiceStatus.State() ) |
|
1245 { |
|
1246 case ECCHDisabled: |
|
1247 { |
|
1248 CCHUIDEBUG( "DoHandleServiceEventL - disabled event" ); |
|
1249 |
|
1250 // Check if all subservices are disabled |
|
1251 TBool allSubserviceDisabled = |
|
1252 iCCHHandler->AllSubservicesInStateL( aServiceId, ECCHDisabled ); |
|
1253 |
|
1254 CCHUIDEBUG2( "DoHandleServiceEventL - all disabled=%d", |
|
1255 allSubserviceDisabled ); |
|
1256 |
|
1257 // If all subservices are disabled stop observing service events. |
|
1258 if ( allSubserviceDisabled ) |
|
1259 { |
|
1260 TInt observedPos = iObservervedServices.Find( aServiceId ); |
|
1261 |
|
1262 if ( KErrNotFound != observedPos ) |
|
1263 { |
|
1264 CCHUIDEBUG( |
|
1265 "DoHandleServiceEventL - removed observed service" ); |
|
1266 iObservervedServices.Remove( observedPos ); |
|
1267 } |
|
1268 |
|
1269 CCHUIDEBUG( "DoHandleServiceEventL - stop observing" ); |
|
1270 iCCHHandler->StopObservingL( aServiceId, *this ); |
|
1271 iObservedService = 0; |
|
1272 } |
|
1273 |
|
1274 if ( iReEnableService ) |
|
1275 { |
|
1276 if ( allSubserviceDisabled ) |
|
1277 { |
|
1278 CCHUIDEBUG( "DoHandleServiceEventL - Re-Enable service" ); |
|
1279 HandleServiceReEnablingL( aServiceId ); |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 // do nothing and wait next disabled event |
|
1284 // to see if then all subservices are disabled |
|
1285 } |
|
1286 } |
|
1287 else if ( allSubserviceDisabled && !iReEnableService ) |
|
1288 { |
|
1289 CCHUIDEBUG( "DoHandleServiceEventL - all subservices disabled" ); |
|
1290 |
|
1291 // Service is in disabled state. Inform cchui observers. |
|
1292 InformObserversL( aServiceId ); |
|
1293 |
|
1294 iLastOperationResult = |
|
1295 MCchUiObserver::ECchUiClientOperationResultNotSet; |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 CCHUIDEBUG( "DoHandleServiceEventL - all subservices not disabled" ); |
|
1300 // not all subservices are disable, do nothing |
|
1301 } |
|
1302 } |
|
1303 break; |
|
1304 |
|
1305 case ECCHEnabled: |
|
1306 { |
|
1307 if ( iReEnableService && iCCHHandler->AllSubservicesInStateL( aServiceId, ECCHEnabled ) ) |
|
1308 { |
|
1309 CCHUIDEBUG( "DoHandleServiceEventL - reset re-enabling" ); |
|
1310 // Just in case set re-enable flag to EFalse |
|
1311 iReEnableService = EFalse; |
|
1312 } |
|
1313 |
|
1314 CCHUIDEBUG( "DoHandleServiceEventL - service is enabled" ); |
|
1315 |
|
1316 // Cancel notes and stop observing only if no active dialog exists |
|
1317 // which needs user action |
|
1318 if ( !iNoteController->ActiveDialogExists() && !iReEnableService ) |
|
1319 { |
|
1320 CancelNotes(); |
|
1321 |
|
1322 TInt observedPos = iObservervedServices.Find( aServiceId ); |
|
1323 if ( KErrNotFound != observedPos ) |
|
1324 { |
|
1325 CCHUIDEBUG( |
|
1326 "DoHandleServiceEventL - removed observed service" ); |
|
1327 iObservervedServices.Remove( observedPos ); |
|
1328 } |
|
1329 |
|
1330 CCHUIDEBUG( "DoHandleServiceEventL - stop observing" ); |
|
1331 iCCHHandler->StopObservingL( aServiceId, *this ); |
|
1332 iObservedService = 0; |
|
1333 |
|
1334 // Service is in enabled state. Inform cchui observers. |
|
1335 InformObserversL( aServiceId ); |
|
1336 |
|
1337 iLastOperationResult = |
|
1338 MCchUiObserver::ECchUiClientOperationResultNotSet; |
|
1339 } |
|
1340 |
|
1341 if ( iNoteController && |
|
1342 MCchUiObserver::ECchUiDialogTypeNoConnectionAvailable == |
|
1343 iNoteController->CurrentNote() ) |
|
1344 { |
|
1345 CCHUIDEBUG( "DoHandleServiceEventL - cancel notifier" ); |
|
1346 // Connection enabled again so this notify can be canceled. |
|
1347 CancelNotes(); |
|
1348 } |
|
1349 } |
|
1350 break; |
|
1351 default: |
|
1352 CCHUIDEBUG( "DoHandleServiceEventL - default switch case" ); |
|
1353 break; |
|
1354 } |
|
1355 |
|
1356 CCHUIDEBUG( "CCchUiApiImpl::DoHandleServiceEventL - OUT" ); |
|
1357 } |
|
1358 |
|
1359 // --------------------------------------------------------------------------- |
|
1360 // Informs observers about cch ui results. |
|
1361 // --------------------------------------------------------------------------- |
|
1362 // |
|
1363 void CCchUiApiImpl::InformObserversL( TInt aServiceId ) |
|
1364 { |
|
1365 CCHUIDEBUG( "CCchUiApiImpl::InformObserversL - IN"); |
|
1366 |
|
1367 for ( TInt index = 0 ; index < iObservers.Count() ; index++ ) |
|
1368 { |
|
1369 CCHUIDEBUG2( "InformObserversL - aServiceId: %d", aServiceId ); |
|
1370 CCHUIDEBUG2( "InformObserversL - iLastOperationResult: %d", |
|
1371 iLastOperationResult ); |
|
1372 |
|
1373 iObservers[index]->Observer().ConnectivityDialogsCompletedL( |
|
1374 aServiceId, |
|
1375 iLastOperationResult ); |
|
1376 } |
|
1377 |
|
1378 CCHUIDEBUG( "CCchUiApiImpl::InformObserversL - OUT"); |
|
1379 } |
|
1380 |