hotspotfw/hsserver/src/hotspotsession.cpp
branchRCL_3
changeset 15 dff6ebfd236f
parent 8 c2bc3f8c7777
child 21 d9aaeb96a256
equal deleted inserted replaced
8:c2bc3f8c7777 15:dff6ebfd236f
   480             break;
   480             break;
   481             }
   481             }
   482         case EHssSetTimerValues:
   482         case EHssSetTimerValues:
   483             {
   483             {
   484             TUid clientUid( TUid::Uid( aMessage.Int0() ) );
   484             TUid clientUid( TUid::Uid( aMessage.Int0() ) );
       
   485             TBuf<KUidLength> uid;
       
   486             uid.Copy( clientUid.Name() );
       
   487             ModifyClientUid( uid );
   485             TUint loginTimerValue = aMessage.Int1();
   488             TUint loginTimerValue = aMessage.Int1();
   486             TUint logoutTimerValue = aMessage.Int2();
   489             TUint logoutTimerValue = aMessage.Int2();
   487             iServer.SetTimerValues( clientUid, loginTimerValue, logoutTimerValue );
   490             iServer.SetTimerValues( uid, loginTimerValue, logoutTimerValue );
   488             aMessage.Complete( KErrNone );
   491             aMessage.Complete( KErrNone );
   489             break;
   492             break;
   490             }
   493             }
   491         default:
   494         default:
   492             aMessage.Complete( KErrNotSupported );  
   495             aMessage.Complete( KErrNotSupported );  
   667     if ( KErrNotFound != indx )
   670     if ( KErrNotFound != indx )
   668         {
   671         {
   669         iServer.CompleteMessage( indx, KErrCancel );    
   672         iServer.CompleteMessage( indx, KErrCancel );    
   670         }
   673         }
   671         
   674         
   672     TUid clientUid;
       
   673     TBuf8<KExtensionAPILength> extAPI;
   675     TBuf8<KExtensionAPILength> extAPI;
   674     TRAP_IGNORE( iIapSettingsHandler->FindClientL( iIapId, clientUid, extAPI ) );
   676     TBuf<KUidLength> clientUid;
   675     
   677     TInt err = iServer.GetClientUid( iIapId, clientUid );
   676     // 3rd party client was found
   678         
   677     if ( clientUid != TUid::Null() )
   679     if ( err != KErrNotFound )
   678         {
   680         {
   679         DEBUG("CHotSpotSession::LoginTimeout clientUid = CLIENT");
   681         DEBUG("CHotSpotSession::LoginTimeout clientUid = CLIENT");
       
   682         ConvertTBufToTUid( clientUid ); 
   680         TBuf8<KExtensionAPILength> nullBuf;
   683         TBuf8<KExtensionAPILength> nullBuf;
   681         TInt ret = CreateClient( clientUid, nullBuf );
   684         
       
   685         TInt ret = CreateClient( iClientUid, nullBuf );
   682         DEBUG1("CHotSpotSession::LoginTimeout CreateClient ret: %d", ret);
   686         DEBUG1("CHotSpotSession::LoginTimeout CreateClient ret: %d", ret);
   683         if ( KErrNone == ret )
   687         if ( KErrNone == ret )
   684             {
   688             {
   685             iClient->CancelLogin( iIapId );           
   689             iClient->CancelLogin( iIapId );           
   686             }
   690             }
   723     aMessage.ReadL( 0, uidPckg );
   727     aMessage.ReadL( 0, uidPckg );
   724     clientUid = uidPckg().ClientUid();
   728     clientUid = uidPckg().ClientUid();
   725     aMessage.ReadL( 1, iapPckg );
   729     aMessage.ReadL( 1, iapPckg );
   726     iapName = iapPckg().IapName();
   730     iapName = iapPckg().IapName();
   727     
   731     
       
   732     TBuf<KIapNameLength> bufUid;
       
   733     bufUid.Copy( clientUid.Name() );
       
   734     ModifyClientUid( bufUid );
       
   735         
   728     TUint32 iapId( 0 );
   736     TUint32 iapId( 0 );
   729     
   737     
   730     TInt ret( KErrNone );
   738     TInt ret( KErrNone );
   731     TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, clientUid ));
   739     TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, bufUid ));
   732     DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId );
   740     DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId );
   733     DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret );
   741     DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret );
   734     if ( KErrNone == ret )
   742     if ( KErrNone == ret )
   735         {
   743         {
       
   744         iServer.SetClientIap( iapId, bufUid );
   736         aMessage.Complete( iapId );
   745         aMessage.Complete( iapId );
   737         }
   746         }
   738 
   747 
   739     else 
   748     else 
   740         {
   749         {
   754     iAllowNotifications = EFalse;
   763     iAllowNotifications = EFalse;
   755     TInt ret( KErrNone );
   764     TInt ret( KErrNone );
   756 
   765 
   757     // Read message
   766     // Read message
   758     TInt iapId = ( TInt )aMessage.Int0();
   767     TInt iapId = ( TInt )aMessage.Int0();
   759     
   768     iServer.RemoveClientIap( iapId );
   760     // Check that this is not Easy WLAN
   769     // Check that this is not Easy WLAN
   761     TRAP_IGNORE( EasyWlanIdL() );
   770     TInt easyWlan = iServer.GetEasyWlanId();
   762     if ( iEasyWlanId != iapId  )
   771     if ( easyWlan != iapId  )
   763         {
   772         {
   764         TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
   773         TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
   765         // return KErrGeneral if IAP removal is not successful
   774         // return KErrGeneral if IAP removal is not successful
   766         if ( err != KErrNone )
   775         if ( err != KErrNone )
   767             {
   776             {
   782 //   
   791 //   
   783 TInt CHotSpotSession::ProcessStartLoginL( const TUint aIapId, const TUint aNetId )
   792 TInt CHotSpotSession::ProcessStartLoginL( const TUint aIapId, const TUint aNetId )
   784     {
   793     {
   785     DEBUG("CHotSpotSession::ProcessStartLogin");
   794     DEBUG("CHotSpotSession::ProcessStartLogin");
   786     TInt ret( KErrNotFound );
   795     TInt ret( KErrNotFound );
   787     TUid clientUid;
       
   788     TBuf8<KExtensionAPILength> extAPI;
   796     TBuf8<KExtensionAPILength> extAPI;
   789     iIapId = aIapId;
   797     iIapId = aIapId;
   790     
   798     
   791     // Check if Easy WLAN.
   799     // Check if Easy WLAN.
   792     TRAP_IGNORE( EasyWlanIdL() );
   800     TInt easyWlan = iServer.GetEasyWlanId();
   793     if ( iEasyWlanId == aIapId )
   801     if ( easyWlan == aIapId )
   794         {
   802         {
   795          DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   803          DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   796         // Just test internet connectivity and complete message later
   804         // Just test internet connectivity and complete message later
   797         TestInternetConnectivityL();
   805         TestInternetConnectivityL();
   798         ret = KErrNone;
   806         ret = KErrNone;
   799         return ret;
   807         return ret;
   800         }
   808         }
   801     
   809     
   802     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
   810     TBuf<KUidLength> clientUid;
   803     
   811     TInt err = iServer.GetClientUid( aIapId, clientUid );
   804     // 3rd party client was found
   812     
   805     if ( clientUid != TUid::Null() )
   813     if ( err != KErrNotFound )
   806         {
   814         {
   807         DEBUG("CHotSpotSession::ProcessStartLogin clientUid = CLIENT");
   815         DEBUG("CHotSpotSession::ProcessStartLogin clientUid = CLIENT");
       
   816         ConvertTBufToTUid( clientUid ); 
   808         TBuf8<KExtensionAPILength> nullBuf;
   817         TBuf8<KExtensionAPILength> nullBuf;
   809         ret = CreateClient( clientUid, nullBuf );
   818         
       
   819         ret = CreateClient( iClientUid, nullBuf );
   810         
   820         
   811         if ( KErrNone == ret && iServer.GetLoginFlagValue() )
   821         if ( KErrNone == ret && iServer.GetLoginFlagValue() )
   812             {
   822             {
   813             iLoginTimer->After( iServer.GetLoginTimeMicroSecs( clientUid ) );
   823             iLoginTimer->After( iServer.GetLoginTimeMicroSecs( clientUid ) );
   814             DEBUG("CHotSpotSession::ProcessStartLogin iClient->Login( iIapId, iNetId );");
   824             DEBUG("CHotSpotSession::ProcessStartLogin iClient->Login( iIapId, iNetId );");
   832     {
   842     {
   833     DEBUG("CHotSpotSession::ProcessStart");
   843     DEBUG("CHotSpotSession::ProcessStart");
   834     
   844     
   835     TInt ret( KErrNone );
   845     TInt ret( KErrNone );
   836     TBuf8<KExtensionAPILength> extAPI;
   846     TBuf8<KExtensionAPILength> extAPI;
   837     
   847     TBuf<KUidLength> clientUid;
   838     iIapSettingsHandler->FindClientL( aIapId, iClientUid, extAPI );
   848     
   839     if ( iClientUid == TUid::Null() )
   849     TInt err = iServer.GetClientUid( aIapId, clientUid );
       
   850     if ( err != KErrNone )
   840         {
   851         {
   841         DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
   852         DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
   842         
   853         
   843         ret = KErrNotSupported;
   854         ret = KErrNotSupported;
   844         }
   855         }
   845     else
   856     else
   846         {
   857         {
   847         DEBUG("CHotSpotSession::ProcessStartL clientUid = CLIENT");
   858         DEBUG("CHotSpotSession::ProcessStartL clientUid = CLIENT");
       
   859         ConvertTBufToTUid( clientUid ); 
       
   860         TBuf8<KExtensionAPILength> nullBuf;
   848         
   861         
   849         // Try first with API extension defined
   862         // Try first with API extension defined
   850         ret = CreateClient( iClientUid, extAPI );
   863         ret = CreateClient( iClientUid, extAPI );
   851         
   864         
   852         if ( ret != KErrNone )
   865         if ( ret != KErrNone )
   878     TInt ret( KErrNone );
   891     TInt ret( KErrNone );
   879       
   892       
   880     // Client exists if StartAgain is called.
   893     // Client exists if StartAgain is called.
   881     if ( iClient == NULL )
   894     if ( iClient == NULL )
   882         {    
   895         {    
   883            TBuf8<KExtensionAPILength> nullBuf;
   896         TBuf8<KExtensionAPILength> nullBuf;
   884         ret = CreateClient( iClientUid, nullBuf );
   897         ret = CreateClient( iClientUid, nullBuf );
   885         }
   898         }
   886     
   899     
   887     if (  ret == KErrNone )
   900     if (  ret == KErrNone )
   888         {
   901         {
   945 //   
   958 //   
   946 TInt CHotSpotSession::ProcessCloseL( const TUint aIapId )
   959 TInt CHotSpotSession::ProcessCloseL( const TUint aIapId )
   947     {
   960     {
   948     DEBUG("CHotSpotSession::ProcessCloseL");
   961     DEBUG("CHotSpotSession::ProcessCloseL");
   949     TInt ret( KErrNone );
   962     TInt ret( KErrNone );
   950     TUid clientUid;
       
   951     TBuf8<KExtensionAPILength> extAPI;
   963     TBuf8<KExtensionAPILength> extAPI;
   952   
   964     TBuf<KUidLength> clientUid;
   953     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
   965     
   954     if ( clientUid == TUid::Null() )
   966     TInt err = iServer.GetClientUid( aIapId, clientUid );
       
   967     if ( err != KErrNone )
   955         {
   968         {
   956         DEBUG("CHotSpotSession::ProcessCloseL clientUid = EMPTY");
   969         DEBUG("CHotSpotSession::ProcessCloseL clientUid = EMPTY");
   957         // do nothing
   970         // do nothing
   958         ret = KErrNotSupported;
   971         ret = KErrNotSupported;
   959         }
   972         }
   960     else
   973     else
   961         {
   974         {
   962         DEBUG("CHotSpotSession::ProcessCloseL clientUid = CLIENT");
   975         DEBUG("CHotSpotSession::ProcessCloseL clientUid = CLIENT");
   963         if ( iClient == NULL )
   976         if ( iClient == NULL )
   964             {
   977             {
       
   978             //Convert TBuf to TUid
       
   979             TLex lex( clientUid );
       
   980             TUint value( 0 );
       
   981             lex.Val( value, EHex );
       
   982             iClientUid = TUid::Null();
       
   983             iClientUid.iUid = value;
   965             TBuf8<KExtensionAPILength> nullBuf;
   984             TBuf8<KExtensionAPILength> nullBuf;
   966             ret = CreateClient( clientUid, nullBuf );
   985 
       
   986             ret = CreateClient( iClientUid, nullBuf );
   967             }
   987             }
   968         else
   988         else
   969             {
   989             {
   970             ret = KErrNone;   
   990             ret = KErrNone;   
   971             }
   991             }
  1109 
  1129 
  1110     DEBUG("CHotSpotSession::AuthenticateLC() done");
  1130     DEBUG("CHotSpotSession::AuthenticateLC() done");
  1111     }
  1131     }
  1112 
  1132 
  1113 // -----------------------------------------------------------------------------
  1133 // -----------------------------------------------------------------------------
  1114 // EasyWlanIdL
  1134 // ModifyClientUid
  1115 // -----------------------------------------------------------------------------
  1135 // -----------------------------------------------------------------------------
  1116 //
  1136 //
  1117 void CHotSpotSession::EasyWlanIdL()
  1137 void CHotSpotSession::ModifyClientUid( TDes& aUid )
  1118     {
  1138     {
  1119     DEBUG("CHotSpotSession::EasyWlanIdL()");
  1139     DEBUG("CHotSpotSession::ModifyClientUid");
  1120     // Set to default value just in case
  1140     TInt indx = aUid.Find( KMark1 );
  1121     iEasyWlanId = KEasyWlanServiceId; 
  1141     if ( KErrNotFound != indx )
  1122     
  1142         {
  1123     RCmManagerExt cmManager;
  1143         aUid.Delete( indx, 1 );
  1124     cmManager.OpenL();
  1144         indx = aUid.Find( KMark2 );
  1125     CleanupClosePushL( cmManager );
  1145         if ( KErrNotFound != indx )
  1126     
  1146             {
  1127     iEasyWlanId = cmManager.EasyWlanIdL();
  1147             aUid.Delete( indx, 1 );
  1128     DEBUG1("CHotSpotSession::EasyWlanIdL() ret: % d", iEasyWlanId);
  1148             }
  1129     CleanupStack::PopAndDestroy( &cmManager );
  1149         }
       
  1150     }
       
  1151 
       
  1152 // -----------------------------------------------------------------------------
       
  1153 // ConvertTBufToTUid
       
  1154 // -----------------------------------------------------------------------------
       
  1155 //
       
  1156 void CHotSpotSession::ConvertTBufToTUid( TDes& aUid )
       
  1157     {
       
  1158     DEBUG("CHotSpotSession::ConvertTBufToTUid");
       
  1159     TLex lex( aUid );
       
  1160     TUint value( 0 );
       
  1161     lex.Val( value, EHex );
       
  1162     iClientUid = TUid::Null();
       
  1163     iClientUid.iUid = value;
  1130     }
  1164     }
  1131 
  1165 
  1132 // -----------------------------------------------------------------------------
  1166 // -----------------------------------------------------------------------------
  1133 // ConnectionStateChanged
  1167 // ConnectionStateChanged
  1134 // -----------------------------------------------------------------------------
  1168 // -----------------------------------------------------------------------------
  1135 //
  1169 //
  1136 void CHotSpotSession::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
  1170 void CHotSpotSession::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
  1137     {
  1171     {
  1138     DEBUG1( "CHotSpotSession::ConnectionStateChanged() aNewState=%d", aNewState );
  1172     DEBUG1( "CHotSpotSession::ConnectionStateChanged() aNewState=%d", aNewState );
  1139     switch ( aNewState )
  1173     switch ( aNewState )
  1140             {
  1174         {
  1141             case EWlanConnectionModeSearching:
  1175         case EWlanConnectionModeSearching:
  1142                 {
  1176             {
  1143                 break;
  1177             break;
  1144                 }
  1178             }
  1145             case EWlanConnectionModeInfrastructure:
  1179         case EWlanConnectionModeInfrastructure:
  1146             case EWlanConnectionModeSecureInfra:
  1180         case EWlanConnectionModeSecureInfra:
  1147                 {
  1181             {
  1148                 iMgtClient->CancelNotifications();
  1182             iMgtClient->CancelNotifications();
  1149                 ProcessAssociationStatus( iIapId, ETrue );
  1183             ProcessAssociationStatus( iIapId, ETrue );
  1150                 break;
  1184             break;
  1151                 }
  1185             }
  1152             case EWlanConnectionModeAdhoc:
  1186         case EWlanConnectionModeAdhoc:
  1153             case EWlanConnectionModeNotConnected:
  1187         case EWlanConnectionModeNotConnected:
  1154                 {
  1188             {
  1155                 iMgtClient->CancelNotifications();
  1189             iMgtClient->CancelNotifications();
  1156                 iServer.SetAssociationFlag( EFalse );
  1190             iServer.SetAssociationFlag( EFalse );
  1157                 break;
  1191             break;
  1158                 }
  1192             }
  1159             default:
  1193         default:
  1160                 {
  1194             {
  1161                 iMgtClient->CancelNotifications();
  1195             iMgtClient->CancelNotifications();
  1162                 iServer.SetAssociationFlag( EFalse );
  1196             iServer.SetAssociationFlag( EFalse );
  1163                 }
  1197             }
  1164             }
  1198         }
  1165     
  1199 
  1166     }
  1200     }
  1167 
  1201 
  1168 // end of file
  1202 // end of file
  1169 
  1203