hotspotfw/hsserver/src/hotspotsession.cpp
branchRCL_3
changeset 52 b852595f5cbe
parent 44 a9524956f6b5
child 54 63be7eb3fc78
equal deleted inserted replaced
51:3b2fb68d23df 52:b852595f5cbe
    48 // CHotSpotPluginSession
    48 // CHotSpotPluginSession
    49 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    50 //
    50 //
    51 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
    51 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
    52     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
    52     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
    53     iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue )
    53     iNotificationHandle( NULL ), iAllowNotifications( ETrue ), 
       
    54     iHotspotExtension( ETrue )
    54     {
    55     {
    55     
    56     
    56     }
    57     }
    57 
    58 
    58 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
   158     TPckgBuf<TInt> iapPackage( iIapId );
   159     TPckgBuf<TInt> iapPackage( iIapId );
   159     
   160     
   160     switch ( aMessage.Function() )
   161     switch ( aMessage.Function() )
   161         {
   162         {
   162         case EHssActivateNotifications :
   163         case EHssActivateNotifications :
   163             DEBUG( "CHotSpotSession::ActivateNotificationsL" );
       
   164             iAllowNotifications = EFalse;
   164             iAllowNotifications = EFalse;
   165             
   165             
   166             if ( iNotifications == NULL )
   166             if ( iNotifications == NULL )
   167                 {
   167                 {
   168                 iNotifications = new ( ELeave ) HssNotifications( *this );
   168                 iNotifications = new ( ELeave ) HssNotifications( *this );
   169                 iMgtClient->ActivateNotificationsL( *iNotifications );
   169                 iMgtClient->ActivateNotificationsL( *iNotifications );
   170                 }
   170                 }
   171             HandleOrderNotifications( aMessage );
   171             HandleOrderNotifications( aMessage );
   172             break;
   172             break;
   173         case EHssCancelNotifications :
   173         case EHssCancelNotifications :
   174             DEBUG( "CHotSpotSession::CancelNotifications" );
       
   175             iAllowNotifications = EFalse;
   174             iAllowNotifications = EFalse;
   176             iMgtClient->CancelNotifications( );
   175             iMgtClient->CancelNotifications( );
   177         
   176         
   178             if ( iNotifications != NULL )
   177             if ( iNotifications != NULL )
   179                 {
   178                 {
   257             indx = iServer.FindMessage( iIapId, EHssStartLogin );
   256             indx = iServer.FindMessage( iIapId, EHssStartLogin );
   258             if ( KErrNotFound != indx )
   257             if ( KErrNotFound != indx )
   259                 {
   258                 {
   260                 if ( value == KErrNone )
   259                 if ( value == KErrNone )
   261                     {
   260                     {
   262                     DEBUG( "EHssLoginComplete1" );
       
   263                     iServer.CompleteMessage( indx, KErrNone );
   261                     iServer.CompleteMessage( indx, KErrNone );
   264                     }
   262                     }
   265                 else
   263                 else
   266                     {
   264                     {
   267                     DEBUG( "EHssLoginComplete2" );
       
   268                     iServer.CompleteMessage( indx, KErrCancel );
   265                     iServer.CompleteMessage( indx, KErrCancel );
   269                     iServer.SetLogoutFlag( ETrue );
   266                     iServer.SetLogoutFlag( ETrue );
   270                     }
   267                     }
   271                 }
   268                 }
   272             
   269             
   301                 err = ProcessStartLoginL( iIapId, iNetId );
   298                 err = ProcessStartLoginL( iIapId, iNetId );
   302                 // If client not found, an error was returned. 
   299                 // If client not found, an error was returned. 
   303                 // Otherwise message completed elsewhere. 
   300                 // Otherwise message completed elsewhere. 
   304                 if ( KErrNone != err )
   301                 if ( KErrNone != err )
   305                     {
   302                     {
   306                     indx = iServer.FindMessage(iIapId, EHssStartLogin );
   303                     indx = iServer.FindMessage( iIapId, EHssStartLogin );
   307                     if ( indx >= 0 )
   304                     if ( indx >= 0 )
   308                         {
   305                         {
   309                         iServer.CompleteMessage( indx , KErrNone );
   306                         iServer.CompleteMessage( indx , KErrNone );
   310                         }
   307                         }
   311                     else
   308                     else
   464         case EHssGetIAP:
   461         case EHssGetIAP:
   465             aMessage.WriteL( 0, iapPackage );
   462             aMessage.WriteL( 0, iapPackage );
   466             aMessage.Complete( KErrNone );
   463             aMessage.Complete( KErrNone );
   467             break;
   464             break;
   468         case EHssUiState:
   465         case EHssUiState:
   469             ProcessUiState( aMessage );
   466             TRAP_IGNORE( ProcessUiStateL( aMessage ) );
       
   467             // Just complete the message
       
   468             aMessage.Complete( KErrNone );
   470             break;
   469             break;
   471         case EHssStartBrowser:
   470         case EHssStartBrowser:
   472             {
   471             {
   473             TInt len = aMessage.GetDesLength( 0 );
   472             TInt len = aMessage.GetDesLength( 0 );
   474             iIapId = ( TInt )aMessage.Int1();
   473             iIapId = ( TInt )aMessage.Int1();
   628     TInt indx( KErrNone );
   627     TInt indx( KErrNone );
   629     switch ( aResult )
   628     switch ( aResult )
   630         {
   629         {
   631         case EConnectionOk :
   630         case EConnectionOk :
   632             // Create IAP first, then complete the message to connection.
   631             // Create IAP first, then complete the message to connection.
   633             TRAP_IGNORE( iIapSettingsHandler->CreateIapL() );
   632             TRAP_IGNORE( iIapSettingsHandler->CreateIapL( EFalse ) );
   634             indx = iServer.FindMessage( iIapId, EHssStartLogin );
   633             indx = iServer.FindMessage( iIapId, EHssStartLogin );
   635             if ( KErrNotFound != indx )
   634             if ( KErrNotFound != indx )
   636                 {
   635                 {
   637                 iServer.CompleteMessage( indx, KErrNone );    
   636                 iServer.CompleteMessage( indx, KErrNone );    
   638                 }
   637                 }
  1036         aMessage.Complete( KErrNone );
  1035         aMessage.Complete( KErrNone );
  1037         }
  1036         }
  1038     }
  1037     }
  1039     
  1038     
  1040 // -----------------------------------------------------------------------------
  1039 // -----------------------------------------------------------------------------
  1041 // ProcessUiState
  1040 // ProcessUiStateL
  1042 // -----------------------------------------------------------------------------
  1041 // -----------------------------------------------------------------------------
  1043 //    
  1042 //    
  1044 void CHotSpotSession::ProcessUiState( const RMessage2& aMessage )
  1043 void CHotSpotSession::ProcessUiStateL( const RMessage2& aMessage )
  1045     {
  1044     {
  1046     DEBUG( "CHotSpotSession::ProcessUiState()" );
  1045     DEBUG( "CHotSpotSession::ProcessUiStateL()" );
  1047     TBool completeMsg = EFalse;
  1046     TBool completeMsg = EFalse;
  1048     TInt indx( KErrNone );
  1047     TInt indx( KErrNone );
  1049     TInt indxBrowser( KErrNone );
  1048     TInt indxBrowser( KErrNone );
  1050     TInt ret( KErrNone );
  1049     TInt ret( KErrNone );
  1051     iIapId = ( TInt )aMessage.Int0();
  1050     iIapId = ( TInt )aMessage.Int0();
  1055     THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state
  1054     THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state
  1056     switch ( uiState )
  1055     switch ( uiState )
  1057         {
  1056         {
  1058         case EHsBrowserUiRunning:
  1057         case EHsBrowserUiRunning:
  1059             {
  1058             {
  1060             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiRunning" );
  1059             DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiRunning" );
  1061             break;
  1060             break;
  1062             }
  1061             }
  1063         case EHsBrowserUiAuthenticatedOk:
  1062         case EHsBrowserUiAuthenticatedOk:
  1064             {
  1063             {
  1065             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedOk" );
  1064             DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk" );
  1066 
  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             
  1067             completeMsg = ETrue;
  1090             completeMsg = ETrue;
       
  1091             DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk Done" );
  1068             break;
  1092             break;
  1069                }
  1093                }
  1070         case EHsBrowserUiAuthenticatedNok:
  1094         case EHsBrowserUiAuthenticatedNok:
  1071             {
  1095             {
  1072             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedNok" );
  1096             DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedNok" );
       
  1097             
  1073             completeMsg = ETrue;
  1098             completeMsg = ETrue;
  1074             break;
  1099             break;
  1075             }
  1100             }
  1076         case EHsBrowserUiClosed:
  1101         case EHsBrowserUiClosed:
  1077             {
  1102             {
  1078             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiClosed" );
  1103             DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiClosed" );
  1079             completeMsg = ETrue;
  1104             completeMsg = ETrue;
  1080             break;
  1105             break;
  1081             }
  1106             }
  1082         default:
  1107         default:
  1083             {
  1108             {
  1084             DEBUG( "CHotSpotSession::ProcessUiState() default" );
  1109             DEBUG( "CHotSpotSession::ProcessUiStateL() default" );
  1085             completeMsg = ETrue;
  1110             completeMsg = ETrue;
  1086             }
  1111             }
  1087         }
  1112         }
  1088 		
  1113 		
  1089     if ( completeMsg )
  1114     if ( completeMsg )
  1090         {
  1115         {
  1091         // complete messages EHssStartLogin/EHssStartBrowser
  1116         // complete messages EHssStartLogin/EHssStartBrowser
  1092         if ( indx >= 0 )
  1117         if ( indx >= 0 )
  1093             {
  1118             {
  1094             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartLogin" );
  1119             DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartLogin" );
  1095             iServer.CompleteMessage( indx , KErrNone );
  1120             iServer.CompleteMessage( indx , KErrNone );
  1096             aMessage.Complete( KErrNone );
  1121             }
  1097             }
  1122         
  1098         else if ( indxBrowser >= 0 )
  1123         if ( indxBrowser >= 0 )
  1099             {
  1124             {
  1100             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartBrowser" );
  1125             DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartBrowser" );
  1101             iServer.CompleteMessage( indxBrowser, ret );
  1126             iServer.CompleteMessage( indxBrowser, ret );
  1102             aMessage.Complete( KErrNone );
       
  1103             }
       
  1104         else
       
  1105             {
       
  1106             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssUiState" );
       
  1107             aMessage.Complete( KErrNotFound );
       
  1108             }
  1127             }
  1109         }
  1128         }
  1110     }    
  1129     }    
  1111     
  1130     
  1112 // -----------------------------------------------------------------------------
  1131 // -----------------------------------------------------------------------------