hotspotfw/hsserver/src/hotspotsession.cpp
changeset 3 ff3b37722600
parent 2 6e4b6261703d
child 8 c2bc3f8c7777
child 19 10810c91db26
equal deleted inserted replaced
2:6e4b6261703d 3:ff3b37722600
    45 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    46 //
    46 //
    47 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
    47 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
    48     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
    48     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
    49     iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue )
    49     iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue )
    50 	{
    50     {
    51 	
    51     
    52 	}
    52     }
    53 
    53 
    54 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    55 // ConstructL
    55 // ConstructL
    56 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    57 //
    57 //
    81 // ----------------------------------------------------------------------------------------
    81 // ----------------------------------------------------------------------------------------
    82 // ~CHotSpotSession
    82 // ~CHotSpotSession
    83 // ----------------------------------------------------------------------------------------
    83 // ----------------------------------------------------------------------------------------
    84 //
    84 //
    85 CHotSpotSession::~CHotSpotSession()
    85 CHotSpotSession::~CHotSpotSession()
    86 	{
    86     {
    87 	DEBUG( "CHotSpotSession::~CHotSpotSession()" );
    87     DEBUG( "CHotSpotSession::~CHotSpotSession()" );
    88 	iPendingNotifications.Close();
    88     iPendingNotifications.Close();
    89  	if ( iMgtClient != NULL )
    89     if ( iMgtClient != NULL )
    90         {
    90         {
    91         iMgtClient->CancelNotifications();
    91         iMgtClient->CancelNotifications();
    92         delete iMgtClient;
    92         delete iMgtClient;
    93         }
    93         }
    94  	iMgtClient = NULL;
    94         
    95  	
    95     if ( iIapSettingsHandler != NULL )
    96  	if ( iIapSettingsHandler != NULL )
       
    97         {
    96         {
    98         delete iIapSettingsHandler;
    97         delete iIapSettingsHandler;
    99         }
    98         }
   100  	iIapSettingsHandler = NULL;
    99     
   101     
       
   102  	   
       
   103     if ( iClient != NULL )
   100     if ( iClient != NULL )
   104         {
   101         {
   105         delete iClient;
   102         delete iClient;
   106         }
   103         }
   107     iClient = NULL;
       
   108     
   104     
   109     if ( iNotifications != NULL )
   105     if ( iNotifications != NULL )
   110         {
   106         {
   111         delete iNotifications;
   107         delete iNotifications;
   112         }
   108         }
   113     iNotifications = NULL;
       
   114     
   109     
   115     if ( iLoginTimer != NULL )
   110     if ( iLoginTimer != NULL )
   116         {
   111         {
   117         iLoginTimer->Cancel();
   112         iLoginTimer->Cancel();
   118         delete iLoginTimer;
   113         delete iLoginTimer;
   119         }
   114         }
   120     iLoginTimer = NULL;
       
   121     
   115     
   122     if ( iLogoutTimer != NULL )
   116     if ( iLogoutTimer != NULL )
   123         {
   117         {
   124         iLogoutTimer->Cancel();
   118         iLogoutTimer->Cancel();
   125         delete iLogoutTimer;
   119         delete iLogoutTimer;
   126         }
   120         }
   127     iLogoutTimer = NULL;
       
   128     
   121     
   129     if ( iIcts != NULL )
   122     if ( iIcts != NULL )
   130         {
   123         {
   131         delete iIcts;
   124         delete iIcts;
   132         }
   125         }
   133     iIcts = NULL;
       
   134     DEBUG( "CHotSpotSession::~CHotSpotSession() Done" );
   126     DEBUG( "CHotSpotSession::~CHotSpotSession() Done" );
   135 	}
   127     }
   136 	
   128     
   137 // ----------------------------------------------------------------------------------------
   129 // ----------------------------------------------------------------------------------------
   138 // ServiceL
   130 // ServiceL
   139 // ----------------------------------------------------------------------------------------
   131 // ----------------------------------------------------------------------------------------
   140 //
   132 //
   141 void CHotSpotSession::ServiceL( const RMessage2& aMessage )
   133 void CHotSpotSession::ServiceL( const RMessage2& aMessage )
   142 	{
   134     {
   143 	DEBUG1( "CHotSpotSession::ServiceL message: %d", aMessage.Function() );
   135     DEBUG1( "CHotSpotSession::ServiceL message: %d", aMessage.Function() );
   144 	TRAPD( err, DispatchMessageL( aMessage) );
   136     TRAPD( err, DispatchMessageL( aMessage) );
   145 	if (err != KErrNone)
   137     if (err != KErrNone)
   146         {
   138         {
   147         // Something went wrong. Complete message to let
   139         // Something went wrong. Complete message to let
   148         // the client to continue
   140         // the client to continue
   149         aMessage.Complete(err);
   141         aMessage.Complete(err);
   150         } 
   142         } 
   151 	}
   143     }
   152 // ----------------------------------------------------------------------------------------
   144 // ----------------------------------------------------------------------------------------
   153 // ServiceL
   145 // ServiceL
   154 // ----------------------------------------------------------------------------------------
   146 // ----------------------------------------------------------------------------------------
   155 //
   147 //
   156 void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage )
   148 void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage )
   159     TUint value1(NULL);
   151     TUint value1(NULL);
   160     TInt value2(NULL);
   152     TInt value2(NULL);
   161     TInt err(KErrNone);
   153     TInt err(KErrNone);
   162     TInt indx(KErrNone);
   154     TInt indx(KErrNone);
   163     TPckgBuf<TInt> iapPackage( iIapId );
   155     TPckgBuf<TInt> iapPackage( iIapId );
   164 	
   156     
   165     switch ( aMessage.Function() )
   157     switch ( aMessage.Function() )
   166         {
   158         {
   167         case EHssActivateNotifications :
   159         case EHssActivateNotifications :
   168             iAllowNotifications = EFalse;
   160             iAllowNotifications = EFalse;
   169    			DEBUG( "CHotSpotSession::ActivateNotificationsL" );
   161             DEBUG( "CHotSpotSession::ActivateNotificationsL" );
   170    			if ( iNotifications == NULL )
   162             if ( iNotifications == NULL )
   171    				{
   163                 {
   172    				DEBUG( "CHotSpotSession::DispatchMessageL activated !!!" );
   164                 DEBUG( "CHotSpotSession::DispatchMessageL activated !!!" );
   173    				iNotifications = new (ELeave) HssNotifications(*this);
   165                 iNotifications = new (ELeave) HssNotifications(*this);
   174 				iMgtClient->ActivateNotificationsL( *iNotifications );
   166                 iMgtClient->ActivateNotificationsL( *iNotifications );
   175  				}
   167                 }
   176             HandleOrderNotifications( aMessage );
   168             HandleOrderNotifications( aMessage );
   177             break;
   169             break;
   178         case EHssCancelNotifications :
   170         case EHssCancelNotifications :
   179 		    iAllowNotifications = EFalse;
   171             iAllowNotifications = EFalse;
   180    			DEBUG( "CHotSpotSession::CancelNotifications" );
   172             DEBUG( "CHotSpotSession::CancelNotifications" );
   181    			iMgtClient->CancelNotifications( );
   173             iMgtClient->CancelNotifications( );
   182    			if ( iNotifications != NULL )
   174             if ( iNotifications != NULL )
   183    		    	{
   175                 {
   184    		    	delete iNotifications;
   176                 delete iNotifications;
   185    		    	}
   177                 }
   186    		    iNotifications = NULL;
   178             iNotifications = NULL;
   187    			HandleCancelNotifications( aMessage );
   179             HandleCancelNotifications( aMessage );
   188             break;
   180             break;
   189         case EHssGetScanResults :
   181         case EHssGetScanResults :
   190             // Handled now in client side. Left here for future use.
   182             // Handled now in client side. Left here for future use.
   191             break;
   183             break;
   192         case EHssRegister :
   184         case EHssRegister :
   193         	ProcessRegisterL( aMessage );
   185             ProcessRegisterL( aMessage );
   194             break;
   186             break;
   195         case EHssUnRegister :
   187         case EHssUnRegister :
   196         	ProcessUnRegisterL( aMessage );
   188             ProcessUnRegisterL( aMessage );
   197             break;
   189             break;
   198         case EHssJoin :
   190         case EHssJoin :
   199 		    iAllowNotifications = EFalse;
   191             iAllowNotifications = EFalse;
   200             // IAP id
   192             // IAP id
   201             value1 = ( TInt )aMessage.Int0();
   193             value1 = ( TInt )aMessage.Int0();
   202             iIapId = value1;
   194             iIapId = value1;
   203             indx = iServer.FindMessage(value1, EHssStart );
   195             indx = iServer.FindMessage(value1, EHssStart );
   204             if ( indx >= 0 )
   196             if ( indx >= 0 )
   205                 {
   197                 {
   206             	iServer.CompleteMessage( indx , KErrNone );
   198                 iServer.CompleteMessage( indx , KErrNone );
   207                 }
   199                 }
   208             else
   200             else
   209                 {
   201                 {
   210                 indx = iServer.FindMessage(value1, EHssStartAgain );
   202                 indx = iServer.FindMessage(value1, EHssStartAgain );
   211                 if ( indx >= 0 )
   203                 if ( indx >= 0 )
   221             iServer.SetAssociationFlag( EFalse ); 
   213             iServer.SetAssociationFlag( EFalse ); 
   222              // IAP id
   214              // IAP id
   223             iIapId = ( TInt )aMessage.Int0();
   215             iIapId = ( TInt )aMessage.Int0();
   224             indx = iServer.FindMessage(iIapId, EHssStart );
   216             indx = iServer.FindMessage(iIapId, EHssStart );
   225             if ( indx >= 0 )
   217             if ( indx >= 0 )
   226             {
   218                 {
   227             	iServer.CompleteMessage( indx , KErrAbort);
   219                 iServer.CompleteMessage( indx , KErrAbort);
   228             }
   220                 }
   229 	        else
   221             else
   230             {
   222                 {
   231              	indx = iServer.FindMessage(iIapId, EHssStartAgain );
   223                 indx = iServer.FindMessage(iIapId, EHssStartAgain );
   232                 if ( indx >= 0 )
   224                 if ( indx >= 0 )
   233                 {
   225                     {
   234                 	iServer.CompleteMessage( indx , KErrAbort );
   226                     iServer.CompleteMessage( indx , KErrAbort );
   235                 }
   227                     }
   236             }
   228                 }
   237             
   229             
   238             aMessage.Complete( KErrNone );
   230             aMessage.Complete( KErrNone );
   239             break;
   231             break;
   240         case EHssStop :
   232         case EHssStop :
   241             iAllowNotifications = EFalse;
   233             iAllowNotifications = EFalse;
   242            	iServer.SetLogoutFlag( ETrue );
   234             iServer.SetLogoutFlag( ETrue );
   243            		
   235                    
   244            	iLoginTimer->Cancel();
   236             iLoginTimer->Cancel();
   245             iLogoutTimer->Cancel();
   237             iLogoutTimer->Cancel();
   246             // IAP id
   238             // IAP id
   247             value1 = ( TInt )aMessage.Int0();
   239             value1 = ( TInt )aMessage.Int0();
   248             for (TInt counter = EHssGetScanResults; counter <EHssServerShutdown ;counter++)
   240             for (TInt counter = EHssGetScanResults; counter <EHssServerShutdown ;counter++)
   249             {
   241                 {
   250             	indx = iServer.FindMessage(value1, THotSpotCommands(counter ));
   242                 indx = iServer.FindMessage(value1, THotSpotCommands(counter ));
   251             	if ( indx >= 0 )
   243                 if ( indx >= 0 )
   252             	{
   244                     {
   253             		iServer.CompleteMessage( indx , KErrCancel);
   245                     iServer.CompleteMessage( indx , KErrCancel);
   254             	}
   246                     }
   255             }
   247                 }
   256                         
   248                         
   257             aMessage.Complete( KErrNone );
   249             aMessage.Complete( KErrNone );
   258             break;
   250             break;
   259         case EHssLoginComplete :
   251         case EHssLoginComplete :
   260 		    iAllowNotifications = EFalse;
   252             iAllowNotifications = EFalse;
   261             // IAP id
   253             // IAP id
   262             value1 = ( TInt )aMessage.Int0();
   254             value1 = ( TInt )aMessage.Int0();
   263             // ret value
   255             // ret value
   264             value2 = ( TInt )aMessage.Int1();
   256             value2 = ( TInt )aMessage.Int1();
   265             
   257             
   267             
   259             
   268             DEBUG1( "EHssLoginComplete value2: %d", value2 );
   260             DEBUG1( "EHssLoginComplete value2: %d", value2 );
   269             indx = iServer.FindMessage( value1, EHssStartLogin );
   261             indx = iServer.FindMessage( value1, EHssStartLogin );
   270             if ( KErrNotFound != indx )
   262             if ( KErrNotFound != indx )
   271                 {
   263                 {
   272             	if (value2 == KErrNone)
   264                 if (value2 == KErrNone)
   273             	    {
   265                     {
   274             	    DEBUG( "EHssLoginComplete1" );
   266                     DEBUG( "EHssLoginComplete1" );
   275                 	iServer.CompleteMessage( indx, KErrNone );
   267                     iServer.CompleteMessage( indx, KErrNone );
   276             	    }
   268                     }
   277             	else
   269                 else
   278             	    {
   270                     {
   279             	    DEBUG( "EHssLoginComplete2" );
   271                     DEBUG( "EHssLoginComplete2" );
   280             		iServer.CompleteMessage( indx, KErrCancel );
   272                     iServer.CompleteMessage( indx, KErrCancel );
   281                     iServer.SetLogoutFlag( ETrue );
   273                     iServer.SetLogoutFlag( ETrue );
   282             	    }
   274                     }
   283             	    
       
   284                 }
   275                 }
   285             
   276             
   286             aMessage.Complete( KErrNone );
   277             aMessage.Complete( KErrNone );
   287             break;
   278             break;
   288         case EHssLogoutComplete :
   279         case EHssLogoutComplete :
   289 		    iAllowNotifications = EFalse;
   280             iAllowNotifications = EFalse;
   290 		    iLogoutTimer->Cancel();
   281             iLogoutTimer->Cancel();
   291 		    
   282             
   292             // IAP id
   283             // IAP id
   293             value1 = ( TInt )aMessage.Int0();
   284             value1 = ( TInt )aMessage.Int0();
   294             
   285             
   295             indx = iServer.FindMessage( value1, EHssCloseConnection );
   286             indx = iServer.FindMessage( value1, EHssCloseConnection );
   296             if ( KErrNotFound != indx )
   287             if ( KErrNotFound != indx )
   330                         }
   321                         }
   331                     }
   322                     }
   332                 }
   323                 }
   333             break;
   324             break;
   334         case EHssCancelLogin :
   325         case EHssCancelLogin :
   335         	iLoginTimer->Cancel();
   326             iLoginTimer->Cancel();
   336             // if client doesn't exist (is NULL), Login(.) has not been 
   327             // if client doesn't exist (is NULL), Login(.) has not been 
   337             // called to client -> that is CancelLogin() not needed to call
   328             // called to client -> that is CancelLogin() not needed to call
   338             if ( iClient != NULL )
   329             if ( iClient != NULL )
   339                 {
   330                 {
   340                 iClient->CancelLogin( iIapId );
   331                 iClient->CancelLogin( iIapId );
   346                 iServer.CompleteMessage( indx , err );
   337                 iServer.CompleteMessage( indx , err );
   347                 }
   338                 }
   348             aMessage.Complete( KErrNone );
   339             aMessage.Complete( KErrNone );
   349             break;
   340             break;
   350         case EHssStart:
   341         case EHssStart:
   351         	// IAP id
   342             // IAP id
   352         	iServer.SetLoginFlag( ETrue );
   343             iServer.SetLoginFlag( ETrue );
   353         	iIapId = ( TInt )aMessage.Int0();
   344             iIapId = ( TInt )aMessage.Int0();
   354             err = iServer.SaveMessage( iIapId, aMessage, EHssStart ); 
   345             err = iServer.SaveMessage( iIapId, aMessage, EHssStart ); 
   355            if ( err != KErrNone)
   346            if ( err != KErrNone)
   356                 {
   347                 {
   357                 aMessage.Complete( err );  
   348                 aMessage.Complete( err );  
   358                 }
   349                 }
   388                 // else -> client is created and called 
   379                 // else -> client is created and called 
   389                 // WLAN agent waits for 30 seconds before continuing connection setup.
   380                 // WLAN agent waits for 30 seconds before continuing connection setup.
   390                 }
   381                 }
   391             break;
   382             break;
   392         case EHssStartAgain:
   383         case EHssStartAgain:
   393         	// IAP id
   384             // IAP id
   394         	iServer.SetLoginFlag( ETrue );
   385             iServer.SetLoginFlag( ETrue );
   395         	iIapId = ( TInt )aMessage.Int0();
   386             iIapId = ( TInt )aMessage.Int0();
   396             err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain ); 
   387             err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain ); 
   397            if ( err != KErrNone)
   388            if ( err != KErrNone)
   398                 {
   389                 {
   399                 aMessage.Complete( err );  
   390                 aMessage.Complete( err );  
   400                 }
   391                 }
   412                         {
   403                         {
   413                         aMessage.Complete( err );
   404                         aMessage.Complete( err );
   414                         }
   405                         }
   415                     }
   406                     }
   416                 }
   407                 }
   417         	break;
   408             break;
   418         	
   409             
   419         case EHssCancel:
   410         case EHssCancel:
   420        		iLoginTimer->Cancel();
   411                iLoginTimer->Cancel();
   421             iLogoutTimer->Cancel();
   412             iLogoutTimer->Cancel();
   422          	// IAP id
   413             // IAP id
   423         	iIapId = ( TInt )aMessage.Int0();
   414             iIapId = ( TInt )aMessage.Int0();
   424             if ( iServer.GetAssociationFlagValue() )
   415             if ( iServer.GetAssociationFlagValue() )
   425                 {
   416                 {
   426                 // We are in association phase and Agent failed it for some reason
   417                 // We are in association phase and Agent failed it for some reason
   427                 ProcessAssociationStatus( iIapId, EFalse );
   418                 ProcessAssociationStatus( iIapId, EFalse );
   428                 }
   419                 }
   429             
   420             
   430             indx = iServer.FindMessage(iIapId, EHssStart );
   421             indx = iServer.FindMessage(iIapId, EHssStart );
   431             if ( indx >= 0 )
   422             if ( indx >= 0 )
   432             	{
   423                 {
   433             	iServer.CompleteMessage( indx , KErrCancel );
   424                 iServer.CompleteMessage( indx , KErrCancel );
   434             	}
   425                 }
   435             indx = iServer.FindMessage(iIapId, EHssStartAgain );
   426             indx = iServer.FindMessage(iIapId, EHssStartAgain );
   436             if ( indx >= 0 )
   427             if ( indx >= 0 )
   437             	{
   428                 {
   438             	iServer.CompleteMessage( indx , KErrCancel );
   429                 iServer.CompleteMessage( indx , KErrCancel );
   439             	}
   430                 }
   440             indx = iServer.FindMessage(iIapId, EHssCloseConnection );
   431             indx = iServer.FindMessage(iIapId, EHssCloseConnection );
   441             if ( indx >= 0 )
   432             if ( indx >= 0 )
   442             	{
   433                 {
   443             	iServer.CompleteMessage( indx , KErrCancel );
   434                 iServer.CompleteMessage( indx , KErrCancel );
   444             	}
   435                 }
   445             //Not needed to send Logout()
   436             //Not needed to send Logout()
   446             //iServer.SetLogoutFlag( ETrue )
   437             //iServer.SetLogoutFlag( ETrue )
   447             //ProcessCloseL( iIapId )
   438             //ProcessCloseL( iIapId )
   448 			aMessage.Complete( KErrNone );
   439             aMessage.Complete( KErrNone );
   449         break;
   440         break;
   450         
   441         
   451         case EHssCloseConnection:
   442         case EHssCloseConnection:
   452             iLoginTimer->Cancel();
   443             iLoginTimer->Cancel();
   453             iLogoutTimer->Cancel();       	
   444             iLogoutTimer->Cancel();           
   454         
   445         
   455         	// IAP id
   446             // IAP id
   456         	iIapId = ( TInt )aMessage.Int0();
   447             iIapId = ( TInt )aMessage.Int0();
   457 
   448 
   458             if ( iServer.GetAssociationFlagValue() )
   449             if ( iServer.GetAssociationFlagValue() )
   459                 {
   450                 {
   460                 // We are in association phase and Agent failed it for some reason
   451                 // We are in association phase and Agent failed it for some reason
   461                 ProcessAssociationStatus( iIapId, EFalse );
   452                 ProcessAssociationStatus( iIapId, EFalse );
   489         case EHssServerShutdown:
   480         case EHssServerShutdown:
   490             ProcessServerShutdown( aMessage );
   481             ProcessServerShutdown( aMessage );
   491             break;
   482             break;
   492             
   483             
   493         case EHssGetIAP:
   484         case EHssGetIAP:
   494 	        aMessage.WriteL( 0, iapPackage );
   485             aMessage.WriteL( 0, iapPackage );
   495             aMessage.Complete( KErrNone );
   486             aMessage.Complete( KErrNone );
   496             break;
   487             break;
   497             
   488             
   498         case EHssUiState:
   489         case EHssUiState:
   499             ProcessUiState( aMessage );
   490             ProcessUiState( aMessage );
   500             break;
   491             break;
   501         case EHssStartBrowser:
   492         case EHssStartBrowser:
   502             {   
   493             {   
   503         	TInt len = aMessage.GetDesLength( 0 );
   494             TInt len = aMessage.GetDesLength( 0 );
   504         	iIapId = ( TInt )aMessage.Int1();
   495             iIapId = ( TInt )aMessage.Int1();
   505         	iNetId = ( TInt )aMessage.Int2();
   496             iNetId = ( TInt )aMessage.Int2();
   506         	err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser );
   497             err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser );
   507         	HBufC* buf = HBufC::NewLC( len ); 
   498             HBufC* buf = HBufC::NewLC( len ); 
   508             TPtr ptr( buf->Des() );
   499             TPtr ptr( buf->Des() );
   509             User::LeaveIfError( aMessage.Read( 0, ptr ) );     
   500             User::LeaveIfError( aMessage.Read( 0, ptr ) );     
   510             
   501             
   511             AuthenticateL( ptr );
   502             AuthenticateL( ptr );
   512             
   503             
   513             CleanupStack::PopAndDestroy(buf);
   504             CleanupStack::PopAndDestroy(buf);
   514             }
   505             }
   515         	break;
   506             break;
   516         	
   507             
   517         case EHssSetTimerValues:
   508         case EHssSetTimerValues:
   518             {
   509             {
   519             TUid clientUid( TUid::Uid( aMessage.Int0() ) );
   510             TUid clientUid( TUid::Uid( aMessage.Int0() ) );
   520             TUint loginTimerValue = aMessage.Int1();
   511             TUint loginTimerValue = aMessage.Int1();
   521             TUint logoutTimerValue = aMessage.Int2();
   512             TUint logoutTimerValue = aMessage.Int2();
   588     DEBUG( "CHotSpotSession::AddNotification" );
   579     DEBUG( "CHotSpotSession::AddNotification" );
   589 
   580 
   590     TNotification notif;
   581     TNotification notif;
   591     notif.id = aNotification;
   582     notif.id = aNotification;
   592     notif.data = aData;
   583     notif.data = aData;
   593 	if ( iIsNotificationRequestPending )
   584     if ( iIsNotificationRequestPending )
   594         {
   585         {
   595 		DEBUG( "CHotSpotSession::AddNotification added to array. Request found..." );
   586         DEBUG( "CHotSpotSession::AddNotification added to array. Request found..." );
   596     	iPendingNotifications.Append( notif );
   587         iPendingNotifications.Append( notif );
   597     	HandleNotification(); // check is there client waiting for notification
   588         HandleNotification(); // check is there client waiting for notification
   598   		}
   589         }
   599     }
   590     }
   600 
   591 
   601 // ---------------------------------------------------------
   592 // ---------------------------------------------------------
   602 // HandleNotification
   593 // HandleNotification
   603 // ---------------------------------------------------------
   594 // ---------------------------------------------------------
   604 //
   595 //
   605 void CHotSpotSession::HandleNotification()
   596 void CHotSpotSession::HandleNotification()
   606     {
   597     {
   607     DEBUG( "CHotSpotSession::HandleNotification" );
   598     DEBUG( "CHotSpotSession::HandleNotification" );
   608 
   599 
   609 	// Check if we allow notifications
   600     // Check if we allow notifications
   610 	if (iAllowNotifications == TRUE)
   601     if (iAllowNotifications == TRUE)
   611 		{
   602         {
   612     	// Check is there message to wait notification and 
   603         // Check is there message to wait notification and 
   613     	// notification that is not sent.
   604         // notification that is not sent.
   614     	if ( iIsNotificationRequestPending && iPendingNotifications.Count() != 0 )
   605         if ( iIsNotificationRequestPending && iPendingNotifications.Count() != 0 )
   615         	{
   606             {
   616         	DEBUG( "CHotSpotSession::HandleNotification - sending response..." );
   607             DEBUG( "CHotSpotSession::HandleNotification - sending response..." );
   617         	iIsNotificationRequestPending = EFalse;
   608             iIsNotificationRequestPending = EFalse;
   618 
   609 
   619         	THssPckgData data;
   610             THssPckgData data;
   620         	TPckg<THssPckgData> pckg( data );
   611             TPckg<THssPckgData> pckg( data );
   621         	data.data = iPendingNotifications[0].data;
   612             data.data = iPendingNotifications[0].data;
   622         	TInt ret( iPendingNotificationRequest.Write( 0, pckg ) );
   613             TInt ret( iPendingNotificationRequest.Write( 0, pckg ) );
   623         	if ( ret != KErrNone )
   614             if ( ret != KErrNone )
   624             	{
   615                 {
   625             	iPendingNotificationRequest.Complete( ret );
   616                 iPendingNotificationRequest.Complete( ret );
   626             	return;
   617                 return;
   627             	}
   618                 }
   628         	iPendingNotificationRequest.Complete( iPendingNotifications[0].id );
   619             iPendingNotificationRequest.Complete( iPendingNotifications[0].id );
   629         	iPendingNotifications.Reset();
   620             iPendingNotifications.Reset();
   630         	}
   621             }
   631 		}
   622         }
   632 	}
   623     }
   633 
   624 
   634 // -----------------------------------------------------------------------------
   625 // -----------------------------------------------------------------------------
   635 // TestInternetConnectivityL
   626 // TestInternetConnectivityL
   636 // -----------------------------------------------------------------------------
   627 // -----------------------------------------------------------------------------
   637 //
   628 //
   639     {
   630     {
   640     DEBUG("CHotSpotSession::TestInternetConnectivityL");
   631     DEBUG("CHotSpotSession::TestInternetConnectivityL");
   641     if ( iIcts != NULL )
   632     if ( iIcts != NULL )
   642         {
   633         {
   643         delete iIcts;
   634         delete iIcts;
       
   635         iIcts = NULL;
   644         }
   636         }
   645    
   637    
   646     iIcts = CIctsClientInterface::NewL( iIapId, iNetId, *this );
   638     iIcts = CIctsClientInterface::NewL( iIapId, iNetId, *this );
   647     iIcts->StartL();
   639     iIcts->StartL();
   648     }
   640     }
   744 // ---------------------------------------------------------
   736 // ---------------------------------------------------------
   745 // ProcessRegisterL
   737 // ProcessRegisterL
   746 // ---------------------------------------------------------
   738 // ---------------------------------------------------------
   747 //
   739 //
   748 void CHotSpotSession::ProcessRegisterL( const RMessage2& aMessage )
   740 void CHotSpotSession::ProcessRegisterL( const RMessage2& aMessage )
   749 	{
   741     {
   750 	DEBUG("CHotSpotSession::ProcessRegisterL");
   742     DEBUG("CHotSpotSession::ProcessRegisterL");
   751 	
   743     
   752 	iAllowNotifications = EFalse;
   744     iAllowNotifications = EFalse;
   753     TBufC< KIapNameLength > iapName;
   745     TBufC< KIapNameLength > iapName;
   754     TPckgBuf< TIapName > iapPckg;
   746     TPckgBuf< TIapName > iapPckg;
   755     TUid clientUid;
   747     TUid clientUid;
   756     TPckgBuf< TClientUid > uidPckg;
   748     TPckgBuf< TClientUid > uidPckg;
   757     TPckgBuf<TInt> iapPackage( iIapId );
   749     TPckgBuf<TInt> iapPackage( iIapId );
   758 	
   750     
   759     // Read message
   751     // Read message
   760     aMessage.ReadL( 0, uidPckg );
   752     aMessage.ReadL( 0, uidPckg );
   761     clientUid = uidPckg().ClientUid();
   753     clientUid = uidPckg().ClientUid();
   762     aMessage.ReadL( 1, iapPckg );
   754     aMessage.ReadL( 1, iapPckg );
   763     iapName = iapPckg().IapName();
   755     iapName = iapPckg().IapName();
   779         //TRAP(err, iIapSettingsHandler->DeleteIapL( iapId ))
   771         //TRAP(err, iIapSettingsHandler->DeleteIapL( iapId ))
   780         // Error, we are returning 0 to client
   772         // Error, we are returning 0 to client
   781         // and no IAP is created
   773         // and no IAP is created
   782         aMessage.Complete( KErrNone );
   774         aMessage.Complete( KErrNone );
   783         }
   775         }
   784 	}
   776     }
   785 
   777 
   786 // ---------------------------------------------------------
   778 // ---------------------------------------------------------
   787 // ProcessUnRegisterL
   779 // ProcessUnRegisterL
   788 // ---------------------------------------------------------
   780 // ---------------------------------------------------------
   789 //
   781 //
   790 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage )
   782 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage )
   791 	{
   783     {
   792 	DEBUG("CHotSpotSession::ProcessUnRegisterL");
   784     DEBUG("CHotSpotSession::ProcessUnRegisterL");
   793 	iAllowNotifications = EFalse;
   785     iAllowNotifications = EFalse;
   794     TInt ret( KErrNone );
   786     TInt ret( KErrNone );
   795 
   787 
   796     // Read message
   788     // Read message
   797     TInt iapId = ( TInt )aMessage.Int0();
   789     TInt iapId = ( TInt )aMessage.Int0();
   798     
   790     
   811         {
   803         {
   812         ret = KErrPermissionDenied;
   804         ret = KErrPermissionDenied;
   813         }
   805         }
   814         
   806         
   815     aMessage.Complete( ret ); 
   807     aMessage.Complete( ret ); 
   816 	}
   808     }
   817 
   809 
   818 // -----------------------------------------------------------------------------
   810 // -----------------------------------------------------------------------------
   819 // ProcessStartLogin
   811 // ProcessStartLogin
   820 // -----------------------------------------------------------------------------
   812 // -----------------------------------------------------------------------------
   821 //   
   813 //   
   828     iIapId = aIapId;
   820     iIapId = aIapId;
   829     
   821     
   830     // Check if Easy WLAN.
   822     // Check if Easy WLAN.
   831     TRAP_IGNORE( EasyWlanIdL() );
   823     TRAP_IGNORE( EasyWlanIdL() );
   832     if ( iEasyWlanId == aIapId )
   824     if ( iEasyWlanId == aIapId )
   833     	{
   825         {
   834     	 DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   826          DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   835         // Just test internet connectivity and complete message later
   827         // Just test internet connectivity and complete message later
   836         TestInternetConnectivityL();
   828         TestInternetConnectivityL();
   837 		ret = KErrNone;
   829         ret = KErrNone;
   838         return ret;
   830         return ret;
   839     	}
   831         }
   840     
   832     
   841     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
   833     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
   842     
   834     
   843     // 3rd party client was found
   835     // 3rd party client was found
   844     if ( clientUid != TUid::Null() )
   836     if ( clientUid != TUid::Null() )
   870 TInt CHotSpotSession::ProcessStartL( const TUint aIapId )
   862 TInt CHotSpotSession::ProcessStartL( const TUint aIapId )
   871     {
   863     {
   872     DEBUG("CHotSpotSession::ProcessStart");
   864     DEBUG("CHotSpotSession::ProcessStart");
   873     
   865     
   874     TInt ret( KErrNone );
   866     TInt ret( KErrNone );
   875    	TBuf8<KExtensionAPILength> extAPI;
   867     TBuf8<KExtensionAPILength> extAPI;
   876     
   868     
   877     iIapSettingsHandler->FindClientL( aIapId, iClientUid, extAPI );
   869     iIapSettingsHandler->FindClientL( aIapId, iClientUid, extAPI );
   878     if ( iClientUid == TUid::Null() )
   870     if ( iClientUid == TUid::Null() )
   879         {
   871         {
   880         DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
   872         DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
   895             TBuf8<KExtensionAPILength> nullBuf;
   887             TBuf8<KExtensionAPILength> nullBuf;
   896             ret = CreateClient( iClientUid, nullBuf );
   888             ret = CreateClient( iClientUid, nullBuf );
   897             }
   889             }
   898         
   890         
   899         if ( ret == KErrNone )
   891         if ( ret == KErrNone )
   900     		{
   892             {
   901     		iServer.SetAssociationFlag( ETrue ); 
   893             iServer.SetAssociationFlag( ETrue ); 
   902     		iMgtClient->ActivateNotificationsL( *this );
   894             iMgtClient->ActivateNotificationsL( *this );
   903          	iClient->Start( aIapId );    
   895             iClient->Start( aIapId );    
   904         	}
   896             }
   905         }
   897         }
   906     DEBUG1("CHotSpotSession::ProcessStartL DONE ret%d", ret);
   898     DEBUG1("CHotSpotSession::ProcessStartL DONE ret%d", ret);
   907 	return ret;
   899     return ret;
   908     }
   900     }
   909     
   901     
   910 // -----------------------------------------------------------------------------
   902 // -----------------------------------------------------------------------------
   911 // ProcessStartAgain
   903 // ProcessStartAgain
   912 // -----------------------------------------------------------------------------
   904 // -----------------------------------------------------------------------------
   916     DEBUG("CHotSpotSession::ProcessStartAgain");
   908     DEBUG("CHotSpotSession::ProcessStartAgain");
   917     TInt ret( KErrNone );
   909     TInt ret( KErrNone );
   918       
   910       
   919     // Client exists if StartAgain is called.
   911     // Client exists if StartAgain is called.
   920     if ( iClient == NULL )
   912     if ( iClient == NULL )
   921         {	
   913         {    
   922        	TBuf8<KExtensionAPILength> nullBuf;
   914            TBuf8<KExtensionAPILength> nullBuf;
   923         ret = CreateClient( iClientUid, nullBuf );
   915         ret = CreateClient( iClientUid, nullBuf );
   924         }
   916         }
   925     
   917     
   926  	if (  ret == KErrNone )
   918     if (  ret == KErrNone )
   927    		{
   919         {
   928    		iServer.SetAssociationFlag( ETrue ); // Send association status
   920         iServer.SetAssociationFlag( ETrue ); // Send association status
   929    		iClient->Update( aIapId );   
   921         iClient->Update( aIapId );   
   930    		}    
   922         }    
   931 
   923 
   932 	return ret;
   924     return ret;
   933     }
   925     }
   934 // -----------------------------------------------------------------------------
   926 // -----------------------------------------------------------------------------
   935 // ProcessAssociationStatus
   927 // ProcessAssociationStatus
   936 // -----------------------------------------------------------------------------
   928 // -----------------------------------------------------------------------------
   937 //   
   929 //   
   961     {
   953     {
   962     DEBUG("CHotSpotSession::CreateClient");
   954     DEBUG("CHotSpotSession::CreateClient");
   963     TInt err( KErrNone );
   955     TInt err( KErrNone );
   964     if ( aUidText == KNullDesC8 )
   956     if ( aUidText == KNullDesC8 )
   965         {
   957         {
   966        	DEBUG("CHotSpotSession::CreateClient iHotspotExtension = EFalse;");
   958         DEBUG("CHotSpotSession::CreateClient iHotspotExtension = EFalse;");
   967         iHotspotExtension = EFalse;
   959         iHotspotExtension = EFalse;
   968         TRAP( err, iClient = CHssClientPlugin::NewL( aUid, aUidText ) );
   960         TRAP( err, iClient = CHssClientPlugin::NewL( aUid, aUidText ) );
   969         DEBUG1("CHotSpotSession::CreateClient err: %d", err );
   961         DEBUG1("CHotSpotSession::CreateClient err: %d", err );
   970         }
   962         }
   971     else
   963     else
  1002         if ( iClient == NULL )
   994         if ( iClient == NULL )
  1003             {
   995             {
  1004             TBuf8<KExtensionAPILength> nullBuf;
   996             TBuf8<KExtensionAPILength> nullBuf;
  1005             ret = CreateClient( clientUid, nullBuf );
   997             ret = CreateClient( clientUid, nullBuf );
  1006             }
   998             }
  1007 		else
   999         else
  1008 		    {
  1000             {
  1009 		    ret = KErrNone;   
  1001             ret = KErrNone;   
  1010 		    }
  1002             }
  1011 		iLogoutTimer->After( iServer.GetLogoutTimeMicroSecs( clientUid ) );
  1003         iLogoutTimer->After( iServer.GetLogoutTimeMicroSecs( clientUid ) );
  1012         if ( ret == KErrNone && !iServer.GetLogoutFlagValue() )
  1004         if ( ret == KErrNone && !iServer.GetLogoutFlagValue() )
  1013         	{
  1005             {
  1014         	DEBUG("CHotSpotSession::ProcessCloseL send Logout()");
  1006             DEBUG("CHotSpotSession::ProcessCloseL send Logout()");
  1015             iClient->Logout( aIapId );
  1007             iClient->Logout( aIapId );
  1016         	iServer.SetLogoutFlag( ETrue );
  1008             iServer.SetLogoutFlag( ETrue );
  1017         	iServer.SetLoginFlag( EFalse );
  1009             iServer.SetLoginFlag( EFalse );
  1018             }
  1010             }
  1019         else
  1011         else
  1020             {
  1012             {
  1021             ret = KErrNotFound;
  1013             ret = KErrNotFound;
  1022             }    
  1014             }    
  1023       
  1015       
  1024         }
  1016         }
  1025 	return ret;
  1017     return ret;
  1026     }
  1018     }
  1027  
  1019  
  1028 // -----------------------------------------------------------------------------
  1020 // -----------------------------------------------------------------------------
  1029 // ProcessServerShutdown
  1021 // ProcessServerShutdown
  1030 // -----------------------------------------------------------------------------
  1022 // -----------------------------------------------------------------------------
  1052 // -----------------------------------------------------------------------------
  1044 // -----------------------------------------------------------------------------
  1053 // ProcessUiState
  1045 // ProcessUiState
  1054 // -----------------------------------------------------------------------------
  1046 // -----------------------------------------------------------------------------
  1055 //    
  1047 //    
  1056 void CHotSpotSession::ProcessUiState( const RMessage2& aMessage )
  1048 void CHotSpotSession::ProcessUiState( const RMessage2& aMessage )
  1057 	{
  1049     {
  1058     DEBUG( "CHotSpotSession::ProcessUiState()" );
  1050     DEBUG( "CHotSpotSession::ProcessUiState()" );
  1059     TBool completeMsg = EFalse;
  1051     TBool completeMsg = EFalse;
  1060     TInt indx( KErrNone );
  1052     TInt indx( KErrNone );
  1061     TInt indxBrowser( KErrNone );
  1053     TInt indxBrowser( KErrNone );
  1062     TInt ret( KErrNone );
  1054     TInt ret( KErrNone );
  1064 
  1056 
  1065     indx = iServer.FindMessage( iIapId, EHssStartLogin );
  1057     indx = iServer.FindMessage( iIapId, EHssStartLogin );
  1066     indxBrowser = iServer.FindMessage( iIapId, EHssStartBrowser );
  1058     indxBrowser = iServer.FindMessage( iIapId, EHssStartBrowser );
  1067     THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state
  1059     THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state
  1068     switch ( uiState )
  1060     switch ( uiState )
  1069    		{
  1061         {
  1070    		case EHsBrowserUiRunning:
  1062         case EHsBrowserUiRunning:
  1071    			{
  1063             {
  1072    			DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiRunning" );
  1064             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiRunning" );
  1073    			break;
  1065             break;
  1074    			}
  1066             }
  1075    	    case EHsBrowserUiAuthenticatedOk:
  1067         case EHsBrowserUiAuthenticatedOk:
  1076    	        {
  1068             {
  1077    	        DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedOk" );
  1069             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedOk" );
  1078 
  1070 
  1079             completeMsg = ETrue;
  1071             completeMsg = ETrue;
  1080             break;
  1072             break;
  1081    	        }
  1073                }
  1082    	    case EHsBrowserUiAuthenticatedNok:
  1074         case EHsBrowserUiAuthenticatedNok:
  1083    	        {
  1075             {
  1084    		    DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedNok" );
  1076             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedNok" );
  1085    		    completeMsg = ETrue;
       
  1086    		    break;
       
  1087    		    }
       
  1088    	    case EHsBrowserUiClosed:
       
  1089    	        {
       
  1090    	        DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiClosed" );
       
  1091             completeMsg = ETrue;
  1077             completeMsg = ETrue;
  1092             break;
  1078             break;
  1093    	        }
  1079             }
  1094    	    default:
  1080         case EHsBrowserUiClosed:
  1095    	    	{
  1081             {
  1096    	    	DEBUG( "CHotSpotSession::ProcessUiState() default" );
  1082             DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiClosed" );
  1097             completeMsg = ETrue;
  1083             completeMsg = ETrue;
  1098    	    	}
  1084             break;
  1099    	    }
  1085             }
       
  1086         default:
       
  1087             {
       
  1088             DEBUG( "CHotSpotSession::ProcessUiState() default" );
       
  1089             completeMsg = ETrue;
       
  1090             }
       
  1091         }
       
  1092 		
  1100     if ( completeMsg )
  1093     if ( completeMsg )
  1101    	    {
  1094         {
  1102         // complete messages EHssStartLogin/EHssStartBrowser
  1095         // complete messages EHssStartLogin/EHssStartBrowser
  1103         if ( indx >= 0 )
  1096         if ( indx >= 0 )
  1104            {
  1097             {
  1105            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartLogin" );
  1098             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartLogin" );
  1106            iServer.CompleteMessage( indx , KErrNone );
  1099             iServer.CompleteMessage( indx , KErrNone );
  1107            aMessage.Complete( KErrNone );
  1100             aMessage.Complete( KErrNone );
  1108            }
  1101             }
  1109         else if ( indxBrowser >= 0 )
  1102         else if ( indxBrowser >= 0 )
  1110         	{
  1103             {
  1111         	DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartBrowser" );
  1104             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartBrowser" );
  1112             iServer.CompleteMessage( indxBrowser, ret );
  1105             iServer.CompleteMessage( indxBrowser, ret );
  1113             aMessage.Complete( KErrNone );
  1106             aMessage.Complete( KErrNone );
  1114         	}
  1107             }
  1115            else
  1108         else
  1116            {
  1109             {
  1117            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssUiState" );
  1110             DEBUG( "CHotSpotSession::ProcessUiState() completing EHssUiState" );
  1118            aMessage.Complete( KErrNotFound );
  1111             aMessage.Complete( KErrNotFound );
  1119            }
  1112             }
  1120         }
  1113         }
  1121     }    
  1114     }    
  1122     
  1115     
  1123 // -----------------------------------------------------------------------------
  1116 // -----------------------------------------------------------------------------
  1124 // Authenticate()
  1117 // Authenticate()