hotspotfw/hsserver/src/hotspotsession.cpp
branchRCL_3
changeset 52 b852595f5cbe
parent 44 a9524956f6b5
child 54 63be7eb3fc78
--- a/hotspotfw/hsserver/src/hotspotsession.cpp	Thu Jul 15 19:54:09 2010 +0300
+++ b/hotspotfw/hsserver/src/hotspotsession.cpp	Thu Aug 19 10:59:40 2010 +0300
@@ -50,7 +50,8 @@
 //
 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
-    iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue )
+    iNotificationHandle( NULL ), iAllowNotifications( ETrue ), 
+    iHotspotExtension( ETrue )
     {
     
     }
@@ -160,7 +161,6 @@
     switch ( aMessage.Function() )
         {
         case EHssActivateNotifications :
-            DEBUG( "CHotSpotSession::ActivateNotificationsL" );
             iAllowNotifications = EFalse;
             
             if ( iNotifications == NULL )
@@ -171,7 +171,6 @@
             HandleOrderNotifications( aMessage );
             break;
         case EHssCancelNotifications :
-            DEBUG( "CHotSpotSession::CancelNotifications" );
             iAllowNotifications = EFalse;
             iMgtClient->CancelNotifications( );
         
@@ -259,12 +258,10 @@
                 {
                 if ( value == KErrNone )
                     {
-                    DEBUG( "EHssLoginComplete1" );
                     iServer.CompleteMessage( indx, KErrNone );
                     }
                 else
                     {
-                    DEBUG( "EHssLoginComplete2" );
                     iServer.CompleteMessage( indx, KErrCancel );
                     iServer.SetLogoutFlag( ETrue );
                     }
@@ -303,7 +300,7 @@
                 // Otherwise message completed elsewhere. 
                 if ( KErrNone != err )
                     {
-                    indx = iServer.FindMessage(iIapId, EHssStartLogin );
+                    indx = iServer.FindMessage( iIapId, EHssStartLogin );
                     if ( indx >= 0 )
                         {
                         iServer.CompleteMessage( indx , KErrNone );
@@ -466,7 +463,9 @@
             aMessage.Complete( KErrNone );
             break;
         case EHssUiState:
-            ProcessUiState( aMessage );
+            TRAP_IGNORE( ProcessUiStateL( aMessage ) );
+            // Just complete the message
+            aMessage.Complete( KErrNone );
             break;
         case EHssStartBrowser:
             {
@@ -630,7 +629,7 @@
         {
         case EConnectionOk :
             // Create IAP first, then complete the message to connection.
-            TRAP_IGNORE( iIapSettingsHandler->CreateIapL() );
+            TRAP_IGNORE( iIapSettingsHandler->CreateIapL( EFalse ) );
             indx = iServer.FindMessage( iIapId, EHssStartLogin );
             if ( KErrNotFound != indx )
                 {
@@ -1038,12 +1037,12 @@
     }
     
 // -----------------------------------------------------------------------------
-// ProcessUiState
+// ProcessUiStateL
 // -----------------------------------------------------------------------------
 //    
-void CHotSpotSession::ProcessUiState( const RMessage2& aMessage )
+void CHotSpotSession::ProcessUiStateL( const RMessage2& aMessage )
     {
-    DEBUG( "CHotSpotSession::ProcessUiState()" );
+    DEBUG( "CHotSpotSession::ProcessUiStateL()" );
     TBool completeMsg = EFalse;
     TInt indx( KErrNone );
     TInt indxBrowser( KErrNone );
@@ -1057,31 +1056,57 @@
         {
         case EHsBrowserUiRunning:
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiRunning" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiRunning" );
             break;
             }
         case EHsBrowserUiAuthenticatedOk:
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedOk" );
-
+            DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk" );
+            // Check if Easy WLAN.
+            TInt easyWlan = iServer.GetEasyWlanId();
+            if ( easyWlan != iIapId )
+                {
+                iIapSettingsHandler->MoveIapL( iIapId );
+                // Activate notifications and mark as client IAP so that 
+                // IAP can be deleted after the use.
+                TBuf<KIapNameLength> clientUid;
+                iServer.SetClientIap( iIapId, clientUid );
+                iServer.ActivateWlanNotificationsL();
+                }
+            else
+                {
+                TInt iapId( 0 );
+                iapId = iIapSettingsHandler->CreateIapL( ETrue );
+                if ( iapId > 0 )
+                    {
+                    // Activate notifications and mark as client IAP so that 
+                    // IAP can be deleted after the use.
+                    TBuf<KIapNameLength> clientUid;
+                    iServer.SetClientIap( iapId, clientUid );
+                    iServer.ActivateWlanNotificationsL();
+                    }
+                }
+            
             completeMsg = ETrue;
+            DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedOk Done" );
             break;
                }
         case EHsBrowserUiAuthenticatedNok:
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedNok" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiAuthenticatedNok" );
+            
             completeMsg = ETrue;
             break;
             }
         case EHsBrowserUiClosed:
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiClosed" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() EHsBrowserUiClosed" );
             completeMsg = ETrue;
             break;
             }
         default:
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() default" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() default" );
             completeMsg = ETrue;
             }
         }
@@ -1091,20 +1116,14 @@
         // complete messages EHssStartLogin/EHssStartBrowser
         if ( indx >= 0 )
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartLogin" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartLogin" );
             iServer.CompleteMessage( indx , KErrNone );
-            aMessage.Complete( KErrNone );
             }
-        else if ( indxBrowser >= 0 )
+        
+        if ( indxBrowser >= 0 )
             {
-            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartBrowser" );
+            DEBUG( "CHotSpotSession::ProcessUiStateL() completing EHssStartBrowser" );
             iServer.CompleteMessage( indxBrowser, ret );
-            aMessage.Complete( KErrNone );
-            }
-        else
-            {
-            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssUiState" );
-            aMessage.Complete( KErrNotFound );
             }
         }
     }