23 #include "hssnotif.h" |
23 #include "hssnotif.h" |
24 #include "hsslogintimer.h" |
24 #include "hsslogintimer.h" |
25 #include "hsslogouttimer.h" |
25 #include "hsslogouttimer.h" |
26 #include "hssclientinterface.h" |
26 #include "hssclientinterface.h" |
27 #include "am_debug.h" |
27 #include "am_debug.h" |
28 #include <internetconnectivitycrkeys.h> |
|
29 #include <WlanCdbCols.h> |
28 #include <WlanCdbCols.h> |
30 #include <starterclient.h> |
29 #include <starterclient.h> |
31 #include <cmmanagerext.h> |
|
32 #include <e32std.h> |
30 #include <e32std.h> |
33 #include <ecom.h> |
31 #include <ecom.h> |
34 #include <f32file.h> |
32 #include <f32file.h> |
35 #include <apgcli.h> |
|
36 |
33 |
37 // Forward declarations |
34 // Forward declarations |
38 class CWlanMgmtClient; |
35 class CWlanMgmtClient; |
39 class MWlanMgmtNotifications; |
36 class MWlanMgmtNotifications; |
40 |
37 |
41 // Constants |
|
42 const TInt KSeparatorsLength = 4; |
|
43 const TInt KBrowserUid = 0x2000AFCC; // WLAN Login UID |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
38 // ============================ MEMBER FUNCTIONS =============================== |
46 |
39 |
47 // ----------------------------------------------------------------------------- |
40 // ----------------------------------------------------------------------------- |
48 // CHotSpotPluginSession |
41 // CHotSpotPluginSession |
49 // ----------------------------------------------------------------------------- |
42 // ----------------------------------------------------------------------------- |
50 // |
43 // |
51 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) : |
44 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) : |
52 iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), |
45 iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), |
53 iNotificationHandle( NULL ), iAllowNotifications( ETrue ), |
46 iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue ) |
54 iHotspotExtension( ETrue ) |
|
55 { |
47 { |
56 |
48 |
57 } |
49 } |
58 |
50 |
59 // ----------------------------------------------------------------------------- |
51 // ----------------------------------------------------------------------------- |
159 TPckgBuf<TInt> iapPackage( iIapId ); |
147 TPckgBuf<TInt> iapPackage( iIapId ); |
160 |
148 |
161 switch ( aMessage.Function() ) |
149 switch ( aMessage.Function() ) |
162 { |
150 { |
163 case EHssActivateNotifications : |
151 case EHssActivateNotifications : |
|
152 DEBUG( "CHotSpotSession::ActivateNotificationsL" ); |
164 iAllowNotifications = EFalse; |
153 iAllowNotifications = EFalse; |
165 |
154 |
166 if ( iNotifications == NULL ) |
155 if ( iNotifications == NULL ) |
167 { |
156 { |
168 iNotifications = new ( ELeave ) HssNotifications( *this ); |
157 iNotifications = new ( ELeave ) HssNotifications( *this ); |
169 iMgtClient->ActivateNotificationsL( *iNotifications ); |
158 iMgtClient->ActivateNotificationsL( *iNotifications ); |
170 } |
159 } |
171 HandleOrderNotifications( aMessage ); |
160 HandleOrderNotifications( aMessage ); |
172 break; |
161 break; |
173 case EHssCancelNotifications : |
162 case EHssCancelNotifications : |
|
163 DEBUG( "CHotSpotSession::CancelNotifications" ); |
174 iAllowNotifications = EFalse; |
164 iAllowNotifications = EFalse; |
175 iMgtClient->CancelNotifications( ); |
165 iMgtClient->CancelNotifications( ); |
176 |
166 |
177 if ( iNotifications != NULL ) |
167 if ( iNotifications != NULL ) |
178 { |
168 { |
461 case EHssGetIAP: |
453 case EHssGetIAP: |
462 aMessage.WriteL( 0, iapPackage ); |
454 aMessage.WriteL( 0, iapPackage ); |
463 aMessage.Complete( KErrNone ); |
455 aMessage.Complete( KErrNone ); |
464 break; |
456 break; |
465 case EHssUiState: |
457 case EHssUiState: |
466 TRAP_IGNORE( ProcessUiStateL( aMessage ) ); |
458 aMessage.Complete( KErrNotSupported ); |
467 // Just complete the message |
|
468 aMessage.Complete( KErrNone ); |
|
469 break; |
459 break; |
470 case EHssStartBrowser: |
460 case EHssStartBrowser: |
471 { |
461 { |
472 TInt len = aMessage.GetDesLength( 0 ); |
462 aMessage.Complete( KErrNotSupported ); |
473 iIapId = ( TInt )aMessage.Int1(); |
|
474 iNetId = ( TInt )aMessage.Int2(); |
|
475 err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser ); |
|
476 HBufC* buf = HBufC::NewLC( len ); |
|
477 TPtr ptr( buf->Des() ); |
|
478 User::LeaveIfError( aMessage.Read( 0, ptr ) ); |
|
479 |
|
480 AuthenticateL( ptr ); |
|
481 |
|
482 CleanupStack::PopAndDestroy(buf); |
|
483 break; |
463 break; |
484 } |
464 } |
485 case EHssSetTimerValues: |
465 case EHssSetTimerValues: |
486 { |
466 { |
487 TUid clientUid( TUid::Uid( aMessage.Int0() ) ); |
467 TUid clientUid( TUid::Uid( aMessage.Int0() ) ); |
598 } |
578 } |
599 } |
579 } |
600 } |
580 } |
601 |
581 |
602 // ----------------------------------------------------------------------------- |
582 // ----------------------------------------------------------------------------- |
603 // TestInternetConnectivityL |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 void CHotSpotSession::TestInternetConnectivityL() |
|
607 { |
|
608 DEBUG("CHotSpotSession::TestInternetConnectivityL"); |
|
609 if ( iIcts != NULL ) |
|
610 { |
|
611 delete iIcts; |
|
612 iIcts = NULL; |
|
613 } |
|
614 |
|
615 iIcts = CIctsClientInterface::NewL( iIapId, iNetId, *this ); |
|
616 iIcts->StartL(); |
|
617 } |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // ConnectivityObserver |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 void CHotSpotSession::ConnectivityObserver( TIctsTestResult aResult, |
|
624 const TDesC& aString ) |
|
625 { |
|
626 DEBUG1("CHotSpotSession::ConnectivityObserver result: %d", aResult); |
|
627 TInt indx( KErrNone ); |
|
628 switch ( aResult ) |
|
629 { |
|
630 case EConnectionOk : |
|
631 // Create IAP first, then complete the message to connection. |
|
632 TRAP_IGNORE( iIapSettingsHandler->CreateIapL( EFalse ) ); |
|
633 indx = iServer.FindMessage( iIapId, EHssStartLogin ); |
|
634 if ( KErrNotFound != indx ) |
|
635 { |
|
636 iServer.CompleteMessage( indx, KErrNone ); |
|
637 } |
|
638 break; |
|
639 case EHttpAuthenticationNeeded : |
|
640 // Start browser for authentication |
|
641 TRAPD( browserStarted, AuthenticateL( aString ) ); |
|
642 if ( browserStarted != KErrNone ) |
|
643 { |
|
644 // Starting of browser leaved. Complete the message. |
|
645 indx = iServer.FindMessage( iIapId, EHssStartLogin ); |
|
646 if ( KErrNotFound != indx ) |
|
647 { |
|
648 iServer.CompleteMessage( indx, KErrNone ); |
|
649 } |
|
650 } |
|
651 break; |
|
652 case EConnectionNotOk : |
|
653 case ETimeout : |
|
654 indx = iServer.FindMessage( iIapId, EHssStartLogin ); |
|
655 if ( KErrNotFound != indx ) |
|
656 { |
|
657 iServer.CompleteMessage( indx, KErrNone ); |
|
658 } |
|
659 break; |
|
660 default: |
|
661 break; |
|
662 } |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // LoginTimeout |
583 // LoginTimeout |
667 // ----------------------------------------------------------------------------- |
584 // ----------------------------------------------------------------------------- |
668 // |
585 // |
669 void CHotSpotSession::LoginTimeout() |
586 void CHotSpotSession::LoginTimeout() |
670 { |
587 { |
758 aMessage.Complete( KErrNone ); |
675 aMessage.Complete( KErrNone ); |
759 } |
676 } |
760 } |
677 } |
761 |
678 |
762 // --------------------------------------------------------- |
679 // --------------------------------------------------------- |
763 // ProcessUnRegisterL |
680 // ProcessUnRegister |
764 // --------------------------------------------------------- |
681 // --------------------------------------------------------- |
765 // |
682 // |
766 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage ) |
683 void CHotSpotSession::ProcessUnRegister( const RMessage2& aMessage ) |
767 { |
684 { |
768 DEBUG("CHotSpotSession::ProcessUnRegisterL"); |
685 DEBUG("CHotSpotSession::ProcessUnRegister"); |
769 iAllowNotifications = EFalse; |
686 iAllowNotifications = EFalse; |
770 TInt ret( KErrNone ); |
687 TInt ret( KErrNone ); |
771 |
688 |
772 // Read message |
689 // Read message |
773 TInt iapId = ( TInt )aMessage.Int0(); |
690 TInt iapId = ( TInt )aMessage.Int0(); |
774 iServer.RemoveClientIap( iapId ); |
691 iServer.RemoveClientIap( iapId ); |
775 // Check that this is not Easy WLAN |
692 |
776 TInt easyWlan = iServer.GetEasyWlanId(); |
693 TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) ); |
777 if ( easyWlan != iapId ) |
694 // return KErrGeneral if IAP removal is not successful |
778 { |
695 if ( err != KErrNone ) |
779 TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) ); |
696 { |
780 // return KErrGeneral if IAP removal is not successful |
697 ret = KErrGeneral; |
781 if ( err != KErrNone ) |
698 } |
782 { |
|
783 ret = KErrGeneral; |
|
784 } |
|
785 } |
|
786 else |
|
787 { |
|
788 ret = KErrPermissionDenied; |
|
789 } |
|
790 aMessage.Complete( ret ); |
699 aMessage.Complete( ret ); |
791 DEBUG("CHotSpotSession::ProcessUnRegisterL DONE"); |
700 DEBUG("CHotSpotSession::ProcessUnRegisterL DONE"); |
792 } |
701 } |
793 |
702 |
794 // ----------------------------------------------------------------------------- |
703 // ----------------------------------------------------------------------------- |
795 // ProcessStartLogin |
704 // ProcessStartLogin |
796 // ----------------------------------------------------------------------------- |
705 // ----------------------------------------------------------------------------- |
797 // |
706 // |
798 TInt CHotSpotSession::ProcessStartLoginL( const TUint aIapId, const TUint aNetId ) |
707 TInt CHotSpotSession::ProcessStartLogin( const TUint aIapId, const TUint aNetId ) |
799 { |
708 { |
800 DEBUG("CHotSpotSession::ProcessStartLogin"); |
709 DEBUG("CHotSpotSession::ProcessStartLogin"); |
801 TInt ret( KErrNotFound ); |
710 TInt ret( KErrNotFound ); |
802 TBuf8<KExtensionAPILength> extAPI; |
711 TBuf8<KExtensionAPILength> extAPI; |
803 iIapId = aIapId; |
712 iIapId = aIapId; |
804 |
713 |
805 // Check if Easy WLAN. |
|
806 TInt easyWlan = iServer.GetEasyWlanId(); |
|
807 if ( easyWlan == aIapId ) |
|
808 { |
|
809 DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected"); |
|
810 // Just test internet connectivity and complete message later |
|
811 TestInternetConnectivityL(); |
|
812 ret = KErrNone; |
|
813 return ret; |
|
814 } |
|
815 |
|
816 TBuf<KUidLength> clientUid; |
714 TBuf<KUidLength> clientUid; |
817 TInt err = iServer.GetClientUid( aIapId, clientUid ); |
715 TInt err = iServer.GetClientUid( aIapId, clientUid ); |
818 |
716 |
819 if ( err != KErrNotFound ) |
717 if ( err != KErrNotFound ) |
820 { |
718 { |
1035 aMessage.Complete( KErrNone ); |
933 aMessage.Complete( KErrNone ); |
1036 } |
934 } |
1037 } |
935 } |
1038 |
936 |
1039 // ----------------------------------------------------------------------------- |
937 // ----------------------------------------------------------------------------- |
1040 // ProcessUiStateL |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CHotSpotSession::ProcessUiStateL( const RMessage2& aMessage ) |
|
1044 { |
|
1045 DEBUG( "CHotSpotSession::ProcessUiStateL()" ); |
|
1046 TBool completeMsg = EFalse; |
|
1047 TInt indx( KErrNone ); |
|
1048 TInt indxBrowser( KErrNone ); |
|
1049 TInt ret( KErrNone ); |
|
1050 iIapId = ( TInt )aMessage.Int0(); |
|
1051 |
|
1052 indx = iServer.FindMessage( iIapId, EHssStartLogin ); |
|
1053 indxBrowser = iServer.FindMessage( iIapId, EHssStartBrowser ); |
|
1054 THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state |
|
1055 switch ( uiState ) |
|
1056 { |
|
1057 case EHsBrowserUiRunning: |
|
1058 { |
|
1059 DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiRunning" ); |
|
1060 break; |
|
1061 } |
|
1062 case EHsBrowserUiAuthenticatedOk: |
|
1063 { |
|
1064 DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk" ); |
|
1065 // Check if Easy WLAN. |
|
1066 TInt easyWlan = iServer.GetEasyWlanId(); |
|
1067 if ( easyWlan != iIapId ) |
|
1068 { |
|
1069 iIapSettingsHandler->MoveIapL( iIapId ); |
|
1070 // Activate notifications and mark as client IAP so that |
|
1071 // IAP can be deleted after the use. |
|
1072 TBuf<KIapNameLength> clientUid; |
|
1073 iServer.SetClientIap( iIapId, clientUid ); |
|
1074 iServer.ActivateWlanNotificationsL(); |
|
1075 } |
|
1076 else |
|
1077 { |
|
1078 TInt iapId( 0 ); |
|
1079 iapId = iIapSettingsHandler->CreateIapL( ETrue ); |
|
1080 if ( iapId > 0 ) |
|
1081 { |
|
1082 // Activate notifications and mark as client IAP so that |
|
1083 // IAP can be deleted after the use. |
|
1084 TBuf<KIapNameLength> clientUid; |
|
1085 iServer.SetClientIap( iapId, clientUid ); |
|
1086 iServer.ActivateWlanNotificationsL(); |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 completeMsg = ETrue; |
|
1091 DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk Done" ); |
|
1092 break; |
|
1093 } |
|
1094 case EHsBrowserUiAuthenticatedNok: |
|
1095 { |
|
1096 DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedNok" ); |
|
1097 |
|
1098 completeMsg = ETrue; |
|
1099 break; |
|
1100 } |
|
1101 case EHsBrowserUiClosed: |
|
1102 { |
|
1103 DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiClosed" ); |
|
1104 completeMsg = ETrue; |
|
1105 break; |
|
1106 } |
|
1107 default: |
|
1108 { |
|
1109 DEBUG( "CHotSpotSession::ProcessUiStateL() default" ); |
|
1110 completeMsg = ETrue; |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 if ( completeMsg ) |
|
1115 { |
|
1116 // complete messages EHssStartLogin/EHssStartBrowser |
|
1117 if ( indx >= 0 ) |
|
1118 { |
|
1119 DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartLogin" ); |
|
1120 iServer.CompleteMessage( indx , KErrNone ); |
|
1121 } |
|
1122 |
|
1123 if ( indxBrowser >= 0 ) |
|
1124 { |
|
1125 DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartBrowser" ); |
|
1126 iServer.CompleteMessage( indxBrowser, ret ); |
|
1127 } |
|
1128 } |
|
1129 } |
|
1130 |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // Authenticate() |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // |
|
1135 void CHotSpotSession::AuthenticateL( const TDesC& aString ) |
|
1136 { |
|
1137 DEBUG("CHotSpotSession::AuthenticateL()"); |
|
1138 |
|
1139 // Count IAP Id length |
|
1140 TInt iapIdLength ( 1 ); |
|
1141 TInt iapId = iIapId; |
|
1142 while ( iapId >= 10 ) |
|
1143 { |
|
1144 iapId = iapId / 10; |
|
1145 iapIdLength++; |
|
1146 } |
|
1147 |
|
1148 // Count Network Id length |
|
1149 TInt netIdLength ( 1 ); |
|
1150 TInt netId = iNetId; |
|
1151 while ( netId >= 10 ) |
|
1152 { |
|
1153 netId = netId / 10; |
|
1154 netIdLength++; |
|
1155 } |
|
1156 |
|
1157 TInt length = aString.Length() + |
|
1158 iapIdLength + |
|
1159 netIdLength + |
|
1160 KSeparatorsLength; |
|
1161 HBufC* param = HBufC::NewLC( length ); |
|
1162 _LIT(tmpString, "%d, %d, %S"); |
|
1163 param->Des().Format( tmpString, iIapId, iNetId, &aString ); |
|
1164 TUid uid( TUid::Uid( KBrowserUid ) ); |
|
1165 RApaLsSession appArcSession; |
|
1166 User::LeaveIfError( appArcSession.Connect() ); // connect to AppArc server |
|
1167 CleanupClosePushL( appArcSession ); |
|
1168 TThreadId id; |
|
1169 TInt err = appArcSession.StartDocument( *param, TUid::Uid( KBrowserUid ), id ); |
|
1170 if ( err != KErrNone ) |
|
1171 { |
|
1172 DEBUG1( "CHotSpotSession::AuthenticateL() StartDocument: %d", err ); |
|
1173 } |
|
1174 CleanupStack::PopAndDestroy( &appArcSession ); |
|
1175 CleanupStack::PopAndDestroy( param ); |
|
1176 |
|
1177 DEBUG("CHotSpotSession::AuthenticateLC() done"); |
|
1178 } |
|
1179 |
|
1180 // ----------------------------------------------------------------------------- |
|
1181 // ModifyClientUid |
938 // ModifyClientUid |
1182 // ----------------------------------------------------------------------------- |
939 // ----------------------------------------------------------------------------- |
1183 // |
940 // |
1184 void CHotSpotSession::ModifyClientUid( TDes& aUid ) |
941 void CHotSpotSession::ModifyClientUid( TDes& aUid ) |
1185 { |
942 { |