19 #include "mpmlogger.h" |
19 #include "mpmlogger.h" |
20 #include "mpmserversession.h" |
20 #include "mpmserversession.h" |
21 #include "mpmcommsdataccess.h" |
21 #include "mpmcommsdataccess.h" |
22 #include "mpmconnmonevents.h" |
22 #include "mpmconnmonevents.h" |
23 #include "mpmconfirmdlgstarting.h" |
23 #include "mpmconfirmdlgstarting.h" |
24 #include "mpmdefaultconnection.h" |
|
25 #include "mpmwlanquerydialog.h" |
|
26 #include "extendedconnpref.h" |
24 #include "extendedconnpref.h" |
27 |
25 |
28 // --------------------------------------------------------------------------- |
26 // --------------------------------------------------------------------------- |
29 // CMPMIapSelection::CMPMIapSelection |
27 // CMPMIapSelection::CMPMIapSelection |
30 // --------------------------------------------------------------------------- |
28 // --------------------------------------------------------------------------- |
36 iCommsDatAccess( aCommsDatAccess ), |
34 iCommsDatAccess( aCommsDatAccess ), |
37 iConnUiUtils( aConnUiUtils ), |
35 iConnUiUtils( aConnUiUtils ), |
38 iStoredIapInfo(), |
36 iStoredIapInfo(), |
39 iSession( aSession ), |
37 iSession( aSession ), |
40 iConfirmDlgStarting( NULL ), |
38 iConfirmDlgStarting( NULL ), |
41 iWlanDialog( NULL ), |
|
42 iNextBestExists( EFalse ), |
39 iNextBestExists( EFalse ), |
43 iUserSelectionIapId( 0 ), |
40 iUserSelectionIapId( 0 ), |
44 iUserSelectionSnapId( 0 ), |
41 iUserSelectionSnapId( 0 ), |
45 iImplicitState( EImplicitStart ), |
42 iImplicitState( EImplicitStart ), |
46 iIsRoaming( EFalse ), |
43 iIsRoaming( EFalse ), |
84 // stop confirm dialog in case one exists |
81 // stop confirm dialog in case one exists |
85 // |
82 // |
86 StopDisplayingStartingDlg(); |
83 StopDisplayingStartingDlg(); |
87 |
84 |
88 delete iConfirmDlgStarting; |
85 delete iConfirmDlgStarting; |
89 delete iWlanDialog; |
|
90 } |
86 } |
91 |
87 |
92 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
93 // CMPMIapSelection::ChooseIapL |
89 // CMPMIapSelection::ChooseIapL |
94 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
183 if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault ) |
179 if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault ) |
184 { |
180 { |
185 // Default connection is requested. |
181 // Default connection is requested. |
186 |
182 |
187 MPMLOGSTRING( "CMPMIapSelection::ChooseIapL:\ |
183 MPMLOGSTRING( "CMPMIapSelection::ChooseIapL:\ |
188 Default Connection" ) |
184 Default Connection" ) |
189 |
185 |
190 if ( iSession->UseUserConnPref() ) |
186 if ( iSession->UseUserConnPref() ) |
191 { |
187 { |
192 // User connection active -> use it |
188 // User connection active -> use it |
193 // Add info into the BM connections |
189 // Add info into the BM connections |
199 |
195 |
200 ChooseIapComplete( KErrNone, iSession->MyServer().UserConnPref()); |
196 ChooseIapComplete( KErrNone, iSession->MyServer().UserConnPref()); |
201 return; |
197 return; |
202 } |
198 } |
203 |
199 |
|
200 // Read the default connection values |
204 TCmDefConnType type( TCmDefConnType( 0 ) ); |
201 TCmDefConnType type( TCmDefConnType( 0 ) ); |
205 TUint32 id( 0 ); |
202 TUint32 id( 0 ); |
206 iSession->MyServer().DefaultConnection()->GetDefaultConnectionL( type, id ); |
203 iCommsDatAccess->GetDefaultConnectionL( type, id ); |
207 |
204 |
208 MPMLOGSTRING3( "CMPMIapSelection::ChooseIapL:\ |
205 MPMLOGSTRING3( "CMPMIapSelection::ChooseIapL:\ |
209 default connection type %d id %d", type, id ) |
206 default connection type %d id %d", type, id ) |
210 |
207 |
211 if( type == ECmDefConnConnectionMethod ) |
208 // set the received snap id and open the connection |
212 { |
209 iChooseIapPref.SetSnapId( id ); |
213 iChooseIapPref.SetIapId( id ); |
210 ExplicitConnectionL(); |
214 iChooseIapPref.SetSnapId( 0 ); |
|
215 ExplicitConnectionL(); |
|
216 } |
|
217 else if( type == ECmDefConnDestination ) |
|
218 { |
|
219 iChooseIapPref.SetSnapId( id ); |
|
220 ExplicitConnectionL(); |
|
221 } |
|
222 else |
|
223 { |
|
224 if( iCommsDatAccess->IsSnapEmptyL( id ) ) |
|
225 { |
|
226 // start implicit connection |
|
227 ImplicitConnectionL(); |
|
228 return; |
|
229 } |
|
230 |
|
231 iChooseIapPref.SetSnapId( id ); |
|
232 |
|
233 // start connection as if explicitly defined |
|
234 // by application |
|
235 ExplicitConnectionL(); |
|
236 } |
|
237 } |
211 } |
238 else if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit ) |
212 else if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit ) |
239 { |
213 { |
240 // Client has defined SNAP or IAP connection to be used. |
214 // Client has defined SNAP or IAP connection to be used. |
241 |
215 |
348 // in connection preferences |
322 // in connection preferences |
349 // |
323 // |
350 iChooseIapPref.SetIapId( validateIapId ); |
324 iChooseIapPref.SetIapId( validateIapId ); |
351 iChooseIapPref.SetNetId( retNetId ); |
325 iChooseIapPref.SetNetId( retNetId ); |
352 |
326 |
353 // In case offline mode is enabled, only LAN or WLAN is allowed. |
327 if ( !iapTypeLanOrWlan && |
354 // If some other bearer has been requested, then error code |
328 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) |
355 // KErrGprsOfflineMode should be returned instead of KErrNone. |
|
356 // |
|
357 |
|
358 if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() || |
|
359 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) ) |
|
360 { |
329 { |
361 ChooseIapComplete( KErrGprsOfflineMode, &iChooseIapPref ); |
330 ChooseIapComplete( KErrGprsOfflineMode, &iChooseIapPref ); |
362 } |
331 } |
363 else |
332 else |
364 { |
333 { |
365 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( validateIapId ); |
334 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( validateIapId ); |
366 if( wlanType != ENotWlanIap ) |
335 if( wlanType != ENotWlanIap ) |
367 { |
336 { |
368 iChooseIapState = EExplicitConnection; |
337 // Add info into the BM connections |
369 iWlanDialog = CMPMWlanQueryDialog::NewL( *this, validateIapId ); |
338 iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), |
370 iWlanDialog->StartWlanQueryL(); |
339 iChooseIapPref.SnapId(), |
|
340 validateIapId, |
|
341 EStarting, |
|
342 *iSession ); |
|
343 ChooseIapComplete( KErrNone, &iChooseIapPref ); |
371 return; |
344 return; |
372 } |
345 } |
373 |
346 |
374 // Check whether confirmation from user is needed for allowing cellular usage. |
347 // Check whether confirmation from user is needed for allowing cellular usage. |
375 // When application is starting an IAP confirmation is asked only when roaming. |
348 // When application is starting an IAP confirmation is asked only when roaming. |
512 |
485 |
513 if ( !CheckGprsServicesAllowedL( iapTypeLanOrWlan ) ) |
486 if ( !CheckGprsServicesAllowedL( iapTypeLanOrWlan ) ) |
514 { |
487 { |
515 ChooseIapComplete( KErrGprsServicesNotAllowed, NULL ); |
488 ChooseIapComplete( KErrGprsServicesNotAllowed, NULL ); |
516 } |
489 } |
517 else if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() || |
490 else if ( !iapTypeLanOrWlan && |
518 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) ) |
491 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) |
519 { |
492 { |
520 // In case offline mode is enabled, only LAN or WLAN is allowed. |
493 // In case offline mode is enabled, only LAN or WLAN is allowed. |
521 // If some other bearer has been requested, then error code |
494 // If some other bearer has been requested, then error code |
522 // KErrGprsOfflineMode should be returned instead of KErrNone. |
495 // KErrGprsOfflineMode should be returned instead of KErrNone. |
523 // |
496 // |
570 ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref ); |
543 ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref ); |
571 } |
544 } |
572 } |
545 } |
573 else |
546 else |
574 { |
547 { |
575 if ( !StartWlanQueryIfNeededL( validateIapId ) ) |
548 // Add info into the BM connections |
576 { |
549 // |
577 // Add info into the BM connections |
550 iSession->MyServer().AppendBMConnection( connId, |
578 // |
|
579 iSession->MyServer().AppendBMConnection( connId, |
|
580 snap, |
551 snap, |
581 validateIapId, |
552 validateIapId, |
582 EStarting, |
553 EStarting, |
583 *iSession ); |
554 *iSession ); |
584 ChooseIapComplete( KErrNone, &iChooseIapPref ); |
555 ChooseIapComplete( KErrNone, &iChooseIapPref ); |
585 |
|
586 } |
|
587 |
|
588 } |
556 } |
589 } |
557 } |
590 |
558 |
591 CleanupStack::PopAndDestroy( &availableIAPList ); |
559 CleanupStack::PopAndDestroy( &availableIAPList ); |
592 } |
560 } |
621 } |
589 } |
622 return ETrue; |
590 return ETrue; |
623 } |
591 } |
624 |
592 |
625 // ----------------------------------------------------------------------------- |
593 // ----------------------------------------------------------------------------- |
626 // CMPMIapSelection::StartWlanQueryIfNeededL |
594 // CMPMIapSelection::IsIapWlanL |
627 // ----------------------------------------------------------------------------- |
595 // ----------------------------------------------------------------------------- |
628 // |
596 // |
629 TBool CMPMIapSelection::StartWlanQueryIfNeededL( TUint32 aIapId, TBool aIsRoaming ) |
597 TBool CMPMIapSelection::IsIapWlanL( TUint32 aIapId ) |
630 { |
598 { |
631 MPMLOGSTRING3( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, isRoaming %d ", |
599 MPMLOGSTRING2( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, ", aIapId) |
632 aIapId, |
|
633 aIsRoaming ) |
|
634 TBool wlanQueryNeeded( EFalse ); |
|
635 // If wlan iap check if offline note needed |
|
636 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( aIapId ); |
600 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( aIapId ); |
637 if( wlanType != ENotWlanIap ) |
601 if( wlanType != EWlanIap ) |
638 { |
602 { |
639 iIsRoaming = aIsRoaming; |
603 return EFalse; |
640 iChooseIapState = EExplicitConnection; |
604 } |
641 iWlanDialog = CMPMWlanQueryDialog::NewL( *this, aIapId ); |
605 return ETrue; |
642 iWlanDialog->StartWlanQueryL(); |
|
643 wlanQueryNeeded = ETrue; |
|
644 } |
|
645 return wlanQueryNeeded; |
|
646 } |
606 } |
647 |
607 |
648 // ----------------------------------------------------------------------------- |
608 // ----------------------------------------------------------------------------- |
649 // CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL |
609 // CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL |
650 // ----------------------------------------------------------------------------- |
610 // ----------------------------------------------------------------------------- |
717 void CMPMIapSelection::ChooseIapComplete( |
677 void CMPMIapSelection::ChooseIapComplete( |
718 TInt aError, |
678 TInt aError, |
719 const TMpmConnPref* aPolicyPref ) |
679 const TMpmConnPref* aPolicyPref ) |
720 { |
680 { |
721 MPMLOGSTRING2( "CMPMIapSelection::ChooseIapComplete aError = %d", aError ) |
681 MPMLOGSTRING2( "CMPMIapSelection::ChooseIapComplete aError = %d", aError ) |
722 |
|
723 if( iWlanDialog ) |
|
724 { |
|
725 delete iWlanDialog; |
|
726 iWlanDialog = NULL; |
|
727 } |
|
728 |
682 |
729 iSession->ChooseIapComplete( aError, aPolicyPref ); |
683 iSession->ChooseIapComplete( aError, aPolicyPref ); |
730 // Set choose iap state to none |
684 // Set choose iap state to none |
731 iChooseIapState = ENoConnection; |
685 iChooseIapState = ENoConnection; |
732 iNextBestExists = EFalse; |
686 iNextBestExists = EFalse; |
733 iUserSelectionSnapId = 0; |
687 iUserSelectionSnapId = 0; |
734 iUserSelectionIapId = 0; |
688 iUserSelectionIapId = 0; |
735 iImplicitState = EImplicitStart; |
689 iImplicitState = EImplicitStart; |
736 } |
690 } |
737 |
691 |
738 |
|
739 // ----------------------------------------------------------------------------- |
|
740 // CMPMIapSelection::UserWlanSelectionDoneL |
|
741 // ----------------------------------------------------------------------------- |
|
742 // |
|
743 void CMPMIapSelection::UserWlanSelectionDoneL( TInt aError, TUint32 aIapId ) |
|
744 { |
|
745 MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL" ) |
|
746 |
|
747 if( iIsRoaming ) |
|
748 { |
|
749 iIsRoaming = EFalse; |
|
750 iSession->MigrateCallbackL( aError ); |
|
751 delete iWlanDialog; |
|
752 iWlanDialog = NULL; |
|
753 } |
|
754 else |
|
755 { |
|
756 if( aError != KErrNone ) |
|
757 { |
|
758 MPMLOGSTRING2( "CMPMIapSelection::UserWlanSelectionDoneL - Error = %d, completing", aError ) |
|
759 ChooseIapComplete( aError, NULL ); |
|
760 } |
|
761 else |
|
762 { |
|
763 if( iChooseIapState == EImplicitConnection ) |
|
764 { |
|
765 iUserSelectionIapId = aIapId; |
|
766 ImplicitConnectionL(); |
|
767 } |
|
768 else if( iChooseIapState == EExplicitConnection ) |
|
769 { |
|
770 MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL completing explicit iap connection" ) |
|
771 iChooseIapPref.SetIapId( aIapId ); |
|
772 // Add info into the BM connections |
|
773 // |
|
774 iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), |
|
775 iChooseIapPref.SnapId(), |
|
776 aIapId, |
|
777 EStarting, |
|
778 *iSession ); |
|
779 delete iWlanDialog; |
|
780 iWlanDialog = NULL; |
|
781 |
|
782 ChooseIapComplete( KErrNone, &iChooseIapPref ); |
|
783 } |
|
784 else |
|
785 { |
|
786 MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL - error, no connection state" ) |
|
787 } |
|
788 |
|
789 } |
|
790 |
|
791 } |
|
792 } |
|
793 |
|
794 // ----------------------------------------------------------------------------- |
692 // ----------------------------------------------------------------------------- |
795 // CMPMIapSelection::HandleUserSelectionError |
693 // CMPMIapSelection::HandleUserSelectionError |
796 // ----------------------------------------------------------------------------- |
694 // ----------------------------------------------------------------------------- |
797 // |
695 // |
798 void CMPMIapSelection::HandleUserSelectionError( TInt aError ) |
696 void CMPMIapSelection::HandleUserSelectionError( TInt aError ) |
865 void CMPMIapSelection::ImplicitConnectionWlanNoteL() |
763 void CMPMIapSelection::ImplicitConnectionWlanNoteL() |
866 { |
764 { |
867 MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionWlanNoteL" ) |
765 MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionWlanNoteL" ) |
868 |
766 |
869 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( iUserSelectionIapId ); |
767 TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( iUserSelectionIapId ); |
870 // In case offline mode is enabled, only LAN or WLAN is allowed. |
768 |
871 // If some other bearer has been requested, then error code |
|
872 // KErrGprsOfflineMode should be returned instead of KErrNone. |
|
873 // |
|
874 if( wlanType != ENotWlanIap ) |
769 if( wlanType != ENotWlanIap ) |
875 { |
770 { |
876 iChooseIapState = EImplicitConnection; |
771 ImplicitConnectionL(); |
877 iWlanDialog = CMPMWlanQueryDialog::NewL( *this, iUserSelectionIapId ); |
|
878 iWlanDialog->StartWlanQueryL(); |
|
879 return; |
772 return; |
880 } |
773 } |
881 else |
774 else |
882 { |
775 { |
883 // Check whether confirmation from user is needed for allowing cellular usage. |
776 // Check whether confirmation from user is needed for allowing cellular usage. |
934 iUserSelectionIapId, |
827 iUserSelectionIapId, |
935 retNetId, |
828 retNetId, |
936 iapTypeLanOrWlan, |
829 iapTypeLanOrWlan, |
937 *iSession ); |
830 *iSession ); |
938 |
831 |
939 if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() || |
832 if ( !iapTypeLanOrWlan && |
940 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) ) |
833 iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) |
941 { |
834 { |
942 MPMLOGSTRING2( "CMPMIapSelection::CompleteImplicitConnectionL: Completing with code = %i", |
835 MPMLOGSTRING2( "CMPMIapSelection::CompleteImplicitConnectionL: Completing with code = %i", |
943 KErrGprsOfflineMode ) |
836 KErrGprsOfflineMode ) |
944 ChooseIapComplete( KErrGprsOfflineMode, NULL ); |
837 ChooseIapComplete( KErrGprsOfflineMode, NULL ); |
945 } |
838 } |