hotspotfw/hsserver/src/hotspotsession.cpp
changeset 0 56b72877c1cb
child 2 6e4b6261703d
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation of HotSpot Server Session
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "hotspotserver.h"
       
    22 #include "hotspotsession.h"
       
    23 #include "hssnotif.h"
       
    24 #include "hsslogintimer.h"
       
    25 #include "hsslogouttimer.h"
       
    26 #include <internetconnectivitycrkeys.h>
       
    27 #include <WlanCdbCols.h>
       
    28 #include <starterclient.h>
       
    29 #include "e32std.h"
       
    30 #include "am_debug.h"
       
    31 #include <ecom.h>
       
    32 #include "hssclientinterface.h"
       
    33 #include <f32file.h>
       
    34 #include <apgcli.h>
       
    35 
       
    36 // Forward declarations
       
    37 class CWlanMgmtClient;
       
    38 class MWlanMgmtNotifications;
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CHotSpotPluginSession
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CHotSpotSession::CHotSpotSession( CHotSpotServer& aServer ) :
       
    47     iServer( aServer ), iClient( NULL ), iSrvNotifications ( NULL ), 
       
    48     iNotificationHandle( NULL ), iAllowNotifications( ETrue ), iHotspotExtension( ETrue )
       
    49 	{
       
    50 	
       
    51 	}
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // ConstructL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CHotSpotSession::ConstructL()
       
    58     {
       
    59     DEBUG( "CHotSpotSession::ConstructL()" );
       
    60     iIapSettingsHandler = CHssIapSettingsHandler::NewL();
       
    61     iLoginTimer = CHssLoginTimer::NewL( *this );
       
    62     iLogoutTimer = CHssLogoutTimer::NewL( *this );
       
    63     
       
    64     iMgtClient = CWlanMgmtClient::NewL();
       
    65     
       
    66     iRepository = CRepository::NewL( KCRUidInternetConnectivitySettings );
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // NewL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CHotSpotSession* CHotSpotSession::NewL( CHotSpotServer& aServer )
       
    74     {
       
    75     CHotSpotSession* self = new( ELeave ) CHotSpotSession( aServer );
       
    76     CleanupStack::PushL( self );
       
    77     self->ConstructL();
       
    78     CleanupStack::Pop( self ); // Should this class have a 2-way constructor?
       
    79     return self;
       
    80     }
       
    81     
       
    82 // ----------------------------------------------------------------------------------------
       
    83 // ~CHotSpotSession
       
    84 // ----------------------------------------------------------------------------------------
       
    85 //
       
    86 CHotSpotSession::~CHotSpotSession()
       
    87 	{
       
    88 	DEBUG( "CHotSpotSession::~CHotSpotSession()" );
       
    89 	iPendingNotifications.Close();
       
    90  	if ( iMgtClient != NULL )
       
    91         {
       
    92         iMgtClient->CancelNotifications();
       
    93         delete iMgtClient;
       
    94         }
       
    95  	iMgtClient = NULL;
       
    96  	
       
    97  	if ( iIapSettingsHandler != NULL )
       
    98         {
       
    99         delete iIapSettingsHandler;
       
   100         }
       
   101  	iIapSettingsHandler = NULL;
       
   102     
       
   103  	   
       
   104     if ( iClient != NULL )
       
   105         {
       
   106         delete iClient;
       
   107         }
       
   108     iClient = NULL;
       
   109     
       
   110     if ( iNotifications != NULL )
       
   111         {
       
   112         delete iNotifications;
       
   113         }
       
   114     iNotifications = NULL;
       
   115     
       
   116     if ( iLoginTimer != NULL )
       
   117         {
       
   118         iLoginTimer->Cancel();
       
   119         delete iLoginTimer;
       
   120         }
       
   121     iLoginTimer = NULL;
       
   122     
       
   123     if ( iLogoutTimer != NULL )
       
   124         {
       
   125         iLogoutTimer->Cancel();
       
   126         delete iLogoutTimer;
       
   127         }
       
   128     iLogoutTimer = NULL;
       
   129     
       
   130     if ( iRepository != NULL )
       
   131         {
       
   132         delete iRepository;
       
   133         }
       
   134     iRepository = NULL;
       
   135     
       
   136     if ( iIcts != NULL )
       
   137         {
       
   138         delete iIcts;
       
   139         }
       
   140     iIcts = NULL;
       
   141     DEBUG( "CHotSpotSession::~CHotSpotSession() Done" );
       
   142 	}
       
   143 	
       
   144 // ----------------------------------------------------------------------------------------
       
   145 // ServiceL
       
   146 // ----------------------------------------------------------------------------------------
       
   147 //
       
   148 void CHotSpotSession::ServiceL( const RMessage2& aMessage )
       
   149 	{
       
   150 	DEBUG1( "CHotSpotSession::ServiceL message: %d", aMessage.Function() );
       
   151 	TRAPD( err, DispatchMessageL( aMessage) );
       
   152 	if (err != KErrNone)
       
   153         {
       
   154         // Something went wrong. Complete message to let
       
   155         // the client to continue
       
   156         aMessage.Complete(err);
       
   157         } 
       
   158 	}
       
   159 // ----------------------------------------------------------------------------------------
       
   160 // ServiceL
       
   161 // ----------------------------------------------------------------------------------------
       
   162 //
       
   163 void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage )
       
   164     {
       
   165     DEBUG( "CHotSpotSession::DispatchMessageL()" );
       
   166     TUint value1(NULL);
       
   167     TInt value2(NULL);
       
   168     TInt err(KErrNone);
       
   169     TInt indx(KErrNone);
       
   170     TPckgBuf<TInt> iapPackage( iIapId );
       
   171 	
       
   172     switch ( aMessage.Function() )
       
   173         {
       
   174         case EHssActivateNotifications :
       
   175             iAllowNotifications = EFalse;
       
   176    			DEBUG( "CHotSpotSession::ActivateNotificationsL" );
       
   177    			if ( iNotifications == NULL )
       
   178    				{
       
   179    				DEBUG( "CHotSpotSession::DispatchMessageL activated !!!" );
       
   180    				iNotifications = new (ELeave) HssNotifications(*this);
       
   181 				iMgtClient->ActivateNotificationsL( *iNotifications );
       
   182  				}
       
   183             HandleOrderNotifications( aMessage );
       
   184             break;
       
   185         case EHssCancelNotifications :
       
   186 		    iAllowNotifications = EFalse;
       
   187    			DEBUG( "CHotSpotSession::CancelNotifications" );
       
   188    			iMgtClient->CancelNotifications( );
       
   189    			if ( iNotifications != NULL )
       
   190    		    	{
       
   191    		    	delete iNotifications;
       
   192    		    	}
       
   193    		    iNotifications = NULL;
       
   194    			HandleCancelNotifications( aMessage );
       
   195             break;
       
   196         case EHssGetScanResults :
       
   197             // Handled now in client side. Left here for future use.
       
   198             break;
       
   199         case EHssRegister :
       
   200         	ProcessRegisterL( aMessage );
       
   201             break;
       
   202         case EHssUnRegister :
       
   203         	ProcessUnRegisterL( aMessage );
       
   204             break;
       
   205         case EHssJoin :
       
   206 		    iAllowNotifications = EFalse;
       
   207             // IAP id
       
   208             value1 = ( TInt )aMessage.Int0();
       
   209             iIapId = value1;
       
   210             indx = iServer.FindMessage(value1, EHssStart );
       
   211             if ( indx >= 0 )
       
   212                 {
       
   213             	iServer.CompleteMessage( indx , KErrNone );
       
   214                 }
       
   215             else
       
   216                 {
       
   217                 indx = iServer.FindMessage(value1, EHssStartAgain );
       
   218                 if ( indx >= 0 )
       
   219                     {
       
   220                     iServer.CompleteMessage( indx , KErrNone );
       
   221                     }
       
   222                 }
       
   223             aMessage.Complete( KErrNone );
       
   224             break;
       
   225         case EHssCancelStart :
       
   226             iServer.SetLogoutFlag( ETrue );
       
   227             // Do not send association status to client
       
   228             iServer.SetAssociationFlag( EFalse ); 
       
   229              // IAP id
       
   230             iIapId = ( TInt )aMessage.Int0();
       
   231             indx = iServer.FindMessage(iIapId, EHssStart );
       
   232             if ( indx >= 0 )
       
   233             {
       
   234             	iServer.CompleteMessage( indx , KErrAbort);
       
   235             }
       
   236 	        else
       
   237             {
       
   238              	indx = iServer.FindMessage(iIapId, EHssStartAgain );
       
   239                 if ( indx >= 0 )
       
   240                 {
       
   241                 	iServer.CompleteMessage( indx , KErrAbort );
       
   242                 }
       
   243             }
       
   244             
       
   245             aMessage.Complete( KErrNone );
       
   246             break;
       
   247         case EHssStop :
       
   248             iAllowNotifications = EFalse;
       
   249            	iServer.SetLogoutFlag( ETrue );
       
   250            		
       
   251            	iLoginTimer->Cancel();
       
   252             iLogoutTimer->Cancel();
       
   253             // IAP id
       
   254             value1 = ( TInt )aMessage.Int0();
       
   255             for (TInt counter = EHssGetScanResults; counter <EHssServerShutdown ;counter++)
       
   256             {
       
   257             	indx = iServer.FindMessage(value1, THotSpotCommands(counter ));
       
   258             	if ( indx >= 0 )
       
   259             	{
       
   260             		iServer.CompleteMessage( indx , KErrCancel);
       
   261             	}
       
   262             }
       
   263                         
       
   264             aMessage.Complete( KErrNone );
       
   265             break;
       
   266         case EHssLoginComplete :
       
   267 		    iAllowNotifications = EFalse;
       
   268             // IAP id
       
   269             value1 = ( TInt )aMessage.Int0();
       
   270             // ret value
       
   271             value2 = ( TInt )aMessage.Int1();
       
   272             
       
   273             iLoginTimer->Cancel();
       
   274             
       
   275             DEBUG1( "EHssLoginComplete value2: %d", value2 );
       
   276             indx = iServer.FindMessage( value1, EHssStartLogin );
       
   277             if ( KErrNotFound != indx )
       
   278                 {
       
   279             	if (value2 == KErrNone)
       
   280             	    {
       
   281             	    DEBUG( "EHssLoginComplete1" );
       
   282                 	iServer.CompleteMessage( indx, KErrNone );
       
   283             	    }
       
   284             	else
       
   285             	    {
       
   286             	    DEBUG( "EHssLoginComplete2" );
       
   287             		iServer.CompleteMessage( indx, KErrCancel );
       
   288                     iServer.SetLogoutFlag( ETrue );
       
   289             	    }
       
   290             	    
       
   291                 }
       
   292             
       
   293             aMessage.Complete( KErrNone );
       
   294             break;
       
   295         case EHssLogoutComplete :
       
   296 		    iAllowNotifications = EFalse;
       
   297 		    iLogoutTimer->Cancel();
       
   298 		    
       
   299             // IAP id
       
   300             value1 = ( TInt )aMessage.Int0();
       
   301             
       
   302             indx = iServer.FindMessage( value1, EHssCloseConnection );
       
   303             if ( KErrNotFound != indx )
       
   304                 {
       
   305                 iServer.CompleteMessage( indx, KErrNone );    
       
   306                 }
       
   307             
       
   308             aMessage.Complete( KErrNone );
       
   309             break;
       
   310         case EHssStartLogin :
       
   311             // Do not send association status, since it's already done.
       
   312             iServer.SetAssociationFlag( EFalse ); 
       
   313             // IAP id
       
   314             iIapId = ( TInt )aMessage.Int0();
       
   315             // Network id
       
   316             iNetId = ( TInt )aMessage.Int1();
       
   317             err = iServer.SaveMessage( iIapId, aMessage, EHssStartLogin ); 
       
   318             if ( KErrNone != err )
       
   319                 {
       
   320                 aMessage.Complete( err );  
       
   321                 }
       
   322             else
       
   323                 {
       
   324                 err = ProcessStartLoginL( iIapId, iNetId );
       
   325                 // If client not found, an error was returned. 
       
   326                 // Otherwise message completed elsewhere. 
       
   327                 if ( KErrNone != err )
       
   328                     {
       
   329                     indx = iServer.FindMessage(iIapId, EHssStartLogin );
       
   330                     if ( indx >= 0 )
       
   331                         {
       
   332                         iServer.CompleteMessage( indx , KErrNone );
       
   333                         }
       
   334                     else
       
   335                         {
       
   336                         aMessage.Complete( KErrNone );
       
   337                         }
       
   338                     }
       
   339                 }
       
   340             break;
       
   341         case EHssCancelLogin :
       
   342         	iLoginTimer->Cancel();
       
   343             // if client doesn't exist (is NULL), Login(.) has not been 
       
   344             // called to client -> that is CancelLogin() not needed to call
       
   345             if ( iClient != NULL )
       
   346                 {
       
   347                 iClient->CancelLogin( iIapId );
       
   348                 }
       
   349             
       
   350             indx = iServer.FindMessage(iIapId, EHssStartLogin );
       
   351             if ( indx >= 0 )
       
   352                 {
       
   353                 iServer.CompleteMessage( indx , err );
       
   354                 }
       
   355             aMessage.Complete( KErrNone );
       
   356             break;
       
   357         case EHssStart:
       
   358         	// IAP id
       
   359         	iServer.SetLoginFlag( ETrue );
       
   360         	iIapId = ( TInt )aMessage.Int0();
       
   361             err = iServer.SaveMessage( iIapId, aMessage, EHssStart ); 
       
   362            if ( err != KErrNone)
       
   363                 {
       
   364                 aMessage.Complete( err );  
       
   365                 }
       
   366             else
       
   367                 {
       
   368                 TRAPD( startLeaved, err = ProcessStartL( iIapId ) );
       
   369                 
       
   370                 if ( startLeaved != KErrNone)
       
   371                     {
       
   372                     indx = iServer.FindMessage(iIapId, EHssStart );
       
   373                     if ( indx >= 0 )
       
   374                         {
       
   375                         iServer.CompleteMessage( indx , KErrNotSupported );
       
   376                         }
       
   377                     else
       
   378                         {
       
   379                         aMessage.Complete( KErrNotSupported );
       
   380                         }
       
   381                     }
       
   382                 
       
   383                 else if ( err != KErrNone)
       
   384                     {
       
   385                     indx = iServer.FindMessage(iIapId, EHssStart );
       
   386                     if ( indx >= 0 )
       
   387                         {
       
   388                         iServer.CompleteMessage( indx , KErrNotSupported );
       
   389                         }
       
   390                     else
       
   391                         {
       
   392                         aMessage.Complete( KErrNotSupported );
       
   393                         }
       
   394                     }
       
   395                 // else -> client is created and called 
       
   396                 // WLAN agent waits for 30 seconds before continuing connection setup.
       
   397                 }
       
   398             break;
       
   399         case EHssStartAgain:
       
   400         	// IAP id
       
   401         	iServer.SetLoginFlag( ETrue );
       
   402         	iIapId = ( TInt )aMessage.Int0();
       
   403             err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain ); 
       
   404            if ( err != KErrNone)
       
   405                 {
       
   406                 aMessage.Complete( err );  
       
   407                 }
       
   408             else
       
   409                 {
       
   410                 err = ProcessStartAgain( iIapId );
       
   411                 if (   err != KErrNone)
       
   412                     {
       
   413                     indx = iServer.FindMessage(iIapId, EHssStartAgain );
       
   414                     if ( indx >= 0 )
       
   415                         {
       
   416                         iServer.CompleteMessage( indx , err );
       
   417                         }
       
   418                     else
       
   419                         {
       
   420                         aMessage.Complete( err );
       
   421                         }
       
   422                     }
       
   423                 }
       
   424         	break;
       
   425         	
       
   426         case EHssCancel:
       
   427        		iLoginTimer->Cancel();
       
   428             iLogoutTimer->Cancel();
       
   429          	// IAP id
       
   430         	iIapId = ( TInt )aMessage.Int0();
       
   431             if ( iServer.GetAssociationFlagValue() )
       
   432                 {
       
   433                 // We are in association phase and Agent failed it for some reason
       
   434                 ProcessAssociationStatus( iIapId, EFalse );
       
   435                 }
       
   436             
       
   437             indx = iServer.FindMessage(iIapId, EHssStart );
       
   438             if ( indx >= 0 )
       
   439             	{
       
   440             	iServer.CompleteMessage( indx , KErrCancel );
       
   441             	}
       
   442             indx = iServer.FindMessage(iIapId, EHssStartAgain );
       
   443             if ( indx >= 0 )
       
   444             	{
       
   445             	iServer.CompleteMessage( indx , KErrCancel );
       
   446             	}
       
   447             indx = iServer.FindMessage(iIapId, EHssCloseConnection );
       
   448             if ( indx >= 0 )
       
   449             	{
       
   450             	iServer.CompleteMessage( indx , KErrCancel );
       
   451             	}
       
   452             //Not needed to send Logout()
       
   453             //iServer.SetLogoutFlag( ETrue )
       
   454             //ProcessCloseL( iIapId )
       
   455 			aMessage.Complete( KErrNone );
       
   456         break;
       
   457         
       
   458         case EHssCloseConnection:
       
   459             iLoginTimer->Cancel();
       
   460             iLogoutTimer->Cancel();       	
       
   461         
       
   462         	// IAP id
       
   463         	iIapId = ( TInt )aMessage.Int0();
       
   464 
       
   465             if ( iServer.GetAssociationFlagValue() )
       
   466                 {
       
   467                 // We are in association phase and Agent failed it for some reason
       
   468                 ProcessAssociationStatus( iIapId, EFalse );
       
   469                 }
       
   470             
       
   471             err = iServer.SaveMessage( iIapId, aMessage, EHssCloseConnection ); 
       
   472             if ( KErrNone != err )
       
   473                 {
       
   474                 aMessage.Complete( err );  
       
   475                 }
       
   476             else
       
   477                 {
       
   478                 err = ProcessCloseL( iIapId );
       
   479                 // If client not found, an error was returned. 
       
   480                 // Otherwise message completed elsewhere. 
       
   481                 if ( KErrNone != err )
       
   482                     {
       
   483                     indx = iServer.FindMessage(iIapId, EHssCloseConnection );
       
   484                     if ( indx >= 0 )
       
   485                         {
       
   486                         iServer.CompleteMessage( indx , KErrNone );
       
   487                         }
       
   488                     else
       
   489                         {
       
   490                         aMessage.Complete( KErrNone );
       
   491                         }
       
   492                     }
       
   493                 }
       
   494             break;
       
   495 
       
   496         case EHssServerShutdown:
       
   497             ProcessServerShutdown( aMessage );
       
   498             break;
       
   499             
       
   500         case EHssGetIAP:
       
   501 	        aMessage.WriteL( 0, iapPackage );
       
   502             aMessage.Complete( KErrNone );
       
   503             break;
       
   504             
       
   505         case EHssUiState:
       
   506             ProcessUiState( aMessage );
       
   507             break;
       
   508         case EHssStartBrowser:
       
   509             {   
       
   510         	TInt len = aMessage.GetDesLength( 0 );
       
   511         	iIapId = ( TInt )aMessage.Int1();
       
   512         	iNetId = ( TInt )aMessage.Int2();
       
   513         	err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser );
       
   514         	HBufC* buf = HBufC::NewLC( len ); 
       
   515             TPtr ptr( buf->Des() );
       
   516             User::LeaveIfError( aMessage.Read( 0, ptr ) );     
       
   517             
       
   518             AuthenticateL( ptr );
       
   519             
       
   520             CleanupStack::PopAndDestroy(buf);
       
   521             }
       
   522         	break;
       
   523         	
       
   524         case EHssSetTimerValues:
       
   525             {
       
   526             TUid clientUid( TUid::Uid( aMessage.Int0() ) );
       
   527             TUint loginTimerValue = aMessage.Int1();
       
   528             TUint logoutTimerValue = aMessage.Int2();
       
   529             iServer.SetTimerValues( clientUid, loginTimerValue, logoutTimerValue );
       
   530             aMessage.Complete( KErrNone );
       
   531             }
       
   532             break;
       
   533 
       
   534         default:
       
   535             aMessage.Complete( KErrNotSupported );  
       
   536             //PanicClient( aMessage, EBadRequest )
       
   537             break;
       
   538         }
       
   539        iAllowNotifications = TRUE;
       
   540 
       
   541     }
       
   542 
       
   543 // ---------------------------------------------------------
       
   544 // HandleOrderNotifications
       
   545 // ---------------------------------------------------------
       
   546 //
       
   547 void CHotSpotSession::HandleOrderNotifications( const RMessage2& aMessage )
       
   548     {
       
   549     iPendingNotificationRequest = aMessage;
       
   550     iIsNotificationRequestPending = ETrue;
       
   551     if( !iNotificationHandle ) // == NULL i.e. is not activated
       
   552         {
       
   553         TRAPD( err, iNotificationHandle = CSessionNotification::NewL( *this ) );
       
   554         if ( err == KErrNone )
       
   555             {
       
   556             iServer.NotifyAdd( *iNotificationHandle );
       
   557             }
       
   558         else
       
   559             {
       
   560             iIsNotificationRequestPending = EFalse;
       
   561             aMessage.Complete( err );
       
   562             return;
       
   563             }
       
   564         }
       
   565     HandleNotification(); // check is there any unsent notifications
       
   566     }
       
   567 
       
   568 // ---------------------------------------------------------
       
   569 // HandleCancelNotifications
       
   570 // ---------------------------------------------------------
       
   571 //
       
   572 void CHotSpotSession::HandleCancelNotifications( const RMessage2& aMessage )
       
   573     {
       
   574     if( iIsNotificationRequestPending )
       
   575         {
       
   576         iPendingNotificationRequest.Complete( KErrNone /*EWLMNotificationsCancelled*/ );
       
   577         iIsNotificationRequestPending = EFalse;
       
   578         iPendingNotifications.Reset();
       
   579         }
       
   580     if( iNotificationHandle )
       
   581         {
       
   582         iServer.NotifyRemove( *iNotificationHandle );
       
   583         delete iNotificationHandle;
       
   584         iNotificationHandle = NULL;
       
   585         }
       
   586     aMessage.Complete( KErrNone );
       
   587     }
       
   588         
       
   589 // ---------------------------------------------------------
       
   590 // AddNotification
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CHotSpotSession::AddNotification( TInt aNotification, TDes8& aData )
       
   594     {
       
   595     DEBUG( "CHotSpotSession::AddNotification" );
       
   596 
       
   597     TNotification notif;
       
   598     notif.id = aNotification;
       
   599     notif.data = aData;
       
   600 	if ( iIsNotificationRequestPending )
       
   601         {
       
   602 		DEBUG( "CHotSpotSession::AddNotification added to array. Request found..." );
       
   603     	iPendingNotifications.Append( notif );
       
   604     	HandleNotification(); // check is there client waiting for notification
       
   605   		}
       
   606     }
       
   607 
       
   608 // ---------------------------------------------------------
       
   609 // HandleNotification
       
   610 // ---------------------------------------------------------
       
   611 //
       
   612 void CHotSpotSession::HandleNotification()
       
   613     {
       
   614     DEBUG( "CHotSpotSession::HandleNotification" );
       
   615 
       
   616 	// Check if we allow notifications
       
   617 	if (iAllowNotifications == TRUE)
       
   618 		{
       
   619     	// Check is there message to wait notification and 
       
   620     	// notification that is not sent.
       
   621     	if ( iIsNotificationRequestPending && iPendingNotifications.Count() != 0 )
       
   622         	{
       
   623         	DEBUG( "CHotSpotSession::HandleNotification - sending response..." );
       
   624         	iIsNotificationRequestPending = EFalse;
       
   625 
       
   626         	THssPckgData data;
       
   627         	TPckg<THssPckgData> pckg( data );
       
   628         	data.data = iPendingNotifications[0].data;
       
   629         	TInt ret( iPendingNotificationRequest.Write( 0, pckg ) );
       
   630         	if ( ret != KErrNone )
       
   631             	{
       
   632             	iPendingNotificationRequest.Complete( ret );
       
   633             	return;
       
   634             	}
       
   635         	iPendingNotificationRequest.Complete( iPendingNotifications[0].id );
       
   636         	iPendingNotifications.Reset();
       
   637         	}
       
   638 		}
       
   639 	}
       
   640 
       
   641 // -----------------------------------------------------------------------------
       
   642 // TestInternetConnectivityL
       
   643 // -----------------------------------------------------------------------------
       
   644 //
       
   645 void CHotSpotSession::TestInternetConnectivityL()
       
   646     {
       
   647     DEBUG("CHotSpotSession::TestInternetConnectivityL");
       
   648     if ( iIcts != NULL )
       
   649         {
       
   650         delete iIcts;
       
   651         }
       
   652     TInt connectivityTestAllowed( EIctsRunAutomatically );
       
   653     iRepository->Get( KIctsTestPermission, connectivityTestAllowed );
       
   654     DEBUG1("CHotSpotSession::TestInternetConnectivityL: %d", connectivityTestAllowed);
       
   655     if ( connectivityTestAllowed == EIctsNeverRun )
       
   656         {
       
   657         TInt indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
   658         if ( KErrNotFound != indx )
       
   659             {
       
   660             iServer.CompleteMessage( indx, KErrNone );    
       
   661             }
       
   662         }
       
   663     else
       
   664         {
       
   665         iIcts = CIctsClientInterface::NewL( iIapId, iNetId, *this );
       
   666         iIcts->StartL();
       
   667         }
       
   668     
       
   669     }
       
   670 
       
   671 // -----------------------------------------------------------------------------
       
   672 // ConnectivityObserver
       
   673 // -----------------------------------------------------------------------------
       
   674 //    
       
   675 void CHotSpotSession::ConnectivityObserver( TIctsTestResult aResult, 
       
   676                                             const TDesC& aString )
       
   677     {
       
   678     DEBUG1("CHotSpotSession::ConnectivityObserver result: %d", aResult);
       
   679     TInt indx( KErrNone );
       
   680     switch ( aResult )
       
   681         {
       
   682         case EConnectionOk :
       
   683             indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
   684             if ( KErrNotFound != indx )
       
   685                 {
       
   686                 iServer.CompleteMessage( indx, KErrNone );    
       
   687                 }
       
   688             TRAP_IGNORE( iIapSettingsHandler->CreateIapL() );
       
   689             break;
       
   690         case EHttpAuthenticationNeeded :
       
   691             // Start browser for authentication
       
   692             TRAP_IGNORE( AuthenticateL( aString ) );
       
   693             break;
       
   694         case EConnectionNotOk :
       
   695             indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
   696             if ( KErrNotFound != indx )
       
   697                 {
       
   698                 iServer.CompleteMessage( indx, KErrNone );    
       
   699                 }
       
   700             break;
       
   701         case ETimeout :
       
   702             indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
   703             if ( KErrNotFound != indx )
       
   704                 {
       
   705                 iServer.CompleteMessage( indx, KErrNone );    
       
   706                 }
       
   707             
       
   708             break;
       
   709         default:
       
   710             break;
       
   711         }
       
   712     }
       
   713 
       
   714 // -----------------------------------------------------------------------------
       
   715 // LoginTimeout
       
   716 // -----------------------------------------------------------------------------
       
   717 //   
       
   718 void CHotSpotSession::LoginTimeout()
       
   719     {
       
   720     DEBUG1("CHotSpotSession::LoginTimeout iIapId :%d", iIapId );
       
   721     iServer.SetLogoutFlag( ETrue );
       
   722     
       
   723     // if message is not found, client has not completed it (LoginComplete(..))
       
   724     TInt indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
   725     if ( KErrNotFound != indx )
       
   726         {
       
   727         iServer.CompleteMessage( indx, KErrCancel );    
       
   728         }
       
   729         
       
   730     TUid clientUid;
       
   731     TBuf8<KExtensionAPILength> extAPI;
       
   732     TRAP_IGNORE( iIapSettingsHandler->FindClientL( iIapId, clientUid, extAPI ) );
       
   733     
       
   734     // 3rd party client was found
       
   735     if ( clientUid != TUid::Null() )
       
   736         {
       
   737         DEBUG("CHotSpotSession::LoginTimeout clientUid = CLIENT");
       
   738         TBuf8<KExtensionAPILength> nullBuf;
       
   739         TInt ret = CreateClient( clientUid, nullBuf );
       
   740         DEBUG1("CHotSpotSession::LoginTimeout CreateClient ret: %d", ret);
       
   741         if ( KErrNone == ret )
       
   742             {
       
   743             iClient->CancelLogin( iIapId );           
       
   744             }
       
   745         }
       
   746 
       
   747     DEBUG("CHotSpotSession::LoginTimeout Done");
       
   748     }
       
   749     
       
   750 // -----------------------------------------------------------------------------
       
   751 // LogoutTimeout
       
   752 // -----------------------------------------------------------------------------
       
   753 //   
       
   754 void CHotSpotSession::LogoutTimeout()
       
   755     {
       
   756     DEBUG("CHotSpotSession::LogoutTimeout");
       
   757     // if message is not found, client has not completed it (LogoutComplete(..))
       
   758     TInt indx = iServer.FindMessage( iIapId, EHssCloseConnection );
       
   759     if ( KErrNotFound != indx )
       
   760         {
       
   761         iServer.CompleteMessage( indx, KErrNone );    
       
   762         }
       
   763     }
       
   764 
       
   765 // ---------------------------------------------------------
       
   766 // ProcessRegisterL
       
   767 // ---------------------------------------------------------
       
   768 //
       
   769 void CHotSpotSession::ProcessRegisterL( const RMessage2& aMessage )
       
   770 	{
       
   771 	DEBUG("CHotSpotSession::ProcessRegisterL");
       
   772 	
       
   773 	iAllowNotifications = EFalse;
       
   774     TBufC< KIapNameLength > iapName;
       
   775     TPckgBuf< TIapName > iapPckg;
       
   776     TUid clientUid;
       
   777     TPckgBuf< TClientUid > uidPckg;
       
   778     TPckgBuf<TInt> iapPackage( iIapId );
       
   779 	
       
   780     // Read message
       
   781     aMessage.ReadL( 0, uidPckg );
       
   782     clientUid = uidPckg().ClientUid();
       
   783     aMessage.ReadL( 1, iapPckg );
       
   784     iapName = iapPckg().IapName();
       
   785     
       
   786     TUint32 iapId( 0 );
       
   787     // TRAPD needed here so that 0 can be returned if DeleteIapL leaves
       
   788     TInt ret( KErrNone );
       
   789     TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, clientUid ));
       
   790     DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId );
       
   791     DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret );
       
   792     if ( KErrNone == ret )
       
   793         {
       
   794         aMessage.Complete( iapId );
       
   795         }
       
   796 
       
   797     else 
       
   798         {
       
   799         // TRAP needed here so that 0 can be returned if DeleteIapL leaves
       
   800         //TRAP(err, iIapSettingsHandler->DeleteIapL( iapId ))
       
   801         // Error, we are returning 0 to client
       
   802         // and no IAP is created
       
   803         aMessage.Complete( KErrNone );
       
   804         }
       
   805 	}
       
   806 
       
   807 // ---------------------------------------------------------
       
   808 // ProcessUnRegisterL
       
   809 // ---------------------------------------------------------
       
   810 //
       
   811 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage )
       
   812 	{
       
   813 	DEBUG("CHotSpotSession::ProcessUnRegisterL");
       
   814 	iAllowNotifications = EFalse;
       
   815    
       
   816     // Read message
       
   817     TInt iapId = ( TInt )aMessage.Int0();
       
   818     
       
   819     TInt ret( KErrNone );
       
   820     // Check that this is not Easy WLAN
       
   821     if ( iServer.GetEasyWlanId() != iapId  )
       
   822         {
       
   823         TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
       
   824         // return KErrGeneral if IAP removal is not successful
       
   825         if ( err != KErrNone )
       
   826             {
       
   827             ret = KErrGeneral;
       
   828             }
       
   829         }
       
   830     else
       
   831         {
       
   832         ret = KErrPermissionDenied;
       
   833         }
       
   834         
       
   835     aMessage.Complete( ret ); 
       
   836 	}
       
   837 
       
   838 // -----------------------------------------------------------------------------
       
   839 // ProcessStartLogin
       
   840 // -----------------------------------------------------------------------------
       
   841 //   
       
   842 TInt CHotSpotSession::ProcessStartLoginL( const TUint aIapId, const TUint aNetId )
       
   843     {
       
   844     DEBUG("CHotSpotSession::ProcessStartLogin");
       
   845     TInt ret( KErrNotFound );
       
   846     TUid clientUid;
       
   847     TBuf8<KExtensionAPILength> extAPI;
       
   848     iIapId = aIapId;
       
   849     
       
   850     // This is Easy WLAN. 
       
   851     if ( iServer.GetEasyWlanId() == aIapId )
       
   852     	{
       
   853     	 DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
       
   854         // Just test internet connectivity and complete message later
       
   855         TestInternetConnectivityL();
       
   856 		ret = KErrNone;
       
   857         return ret;
       
   858     	}
       
   859     
       
   860     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
       
   861     
       
   862     // 3rd party client was found
       
   863     if ( clientUid != TUid::Null() )
       
   864         {
       
   865         DEBUG("CHotSpotSession::ProcessStartLogin clientUid = CLIENT");
       
   866         TBuf8<KExtensionAPILength> nullBuf;
       
   867         ret = CreateClient( clientUid, nullBuf );
       
   868         
       
   869         if ( KErrNone == ret && iServer.GetLoginFlagValue() )
       
   870             {
       
   871             iLoginTimer->After( iServer.GetLoginTimeMicroSecs( clientUid ) );
       
   872             DEBUG("CHotSpotSession::ProcessStartLogin iClient->Login( iIapId, iNetId );");
       
   873             iClient->Login( aIapId, aNetId );
       
   874             iServer.SetLogoutFlag( EFalse );           
       
   875             }
       
   876         else
       
   877             {
       
   878             ret = KErrNotFound;
       
   879             }
       
   880         }
       
   881     DEBUG("CHotSpotSession::ProcessStartLogin DONE");
       
   882     return ret;
       
   883     }
       
   884 
       
   885 // -----------------------------------------------------------------------------
       
   886 // ProcessStart
       
   887 // -----------------------------------------------------------------------------
       
   888 //   
       
   889 TInt CHotSpotSession::ProcessStartL( const TUint aIapId )
       
   890     {
       
   891     DEBUG("CHotSpotSession::ProcessStart");
       
   892     
       
   893     TInt ret( KErrNone );
       
   894    	TBuf8<KExtensionAPILength> extAPI;
       
   895     
       
   896     iIapSettingsHandler->FindClientL( aIapId, iClientUid, extAPI );
       
   897     if ( iClientUid == TUid::Null() )
       
   898         {
       
   899         DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
       
   900         
       
   901         ret = KErrNotSupported;
       
   902         }
       
   903     else
       
   904         {
       
   905         DEBUG("CHotSpotSession::ProcessStartL clientUid = CLIENT");
       
   906         
       
   907         // Try first with API extension defined
       
   908         ret = CreateClient( iClientUid, extAPI );
       
   909         
       
   910         if ( ret != KErrNone )
       
   911             {
       
   912             // Client exists, but hasn't implemented API extension
       
   913             // Let's try again without API extension definition
       
   914             TBuf8<KExtensionAPILength> nullBuf;
       
   915             ret = CreateClient( iClientUid, nullBuf );
       
   916             }
       
   917         
       
   918         if ( ret == KErrNone )
       
   919     		{
       
   920     		iServer.SetAssociationFlag( ETrue ); 
       
   921     		iMgtClient->ActivateNotificationsL( *this );
       
   922          	iClient->Start( aIapId );    
       
   923         	}
       
   924         }
       
   925     DEBUG1("CHotSpotSession::ProcessStartL DONE ret%d", ret);
       
   926 	return ret;
       
   927     }
       
   928     
       
   929 // -----------------------------------------------------------------------------
       
   930 // ProcessStartAgain
       
   931 // -----------------------------------------------------------------------------
       
   932 //   
       
   933 TInt CHotSpotSession::ProcessStartAgain( const TUint aIapId )
       
   934     {
       
   935     DEBUG("CHotSpotSession::ProcessStartAgain");
       
   936     TInt ret( KErrNone );
       
   937       
       
   938     // Client exists if StartAgain is called.
       
   939     if ( iClient == NULL )
       
   940         {	
       
   941        	TBuf8<KExtensionAPILength> nullBuf;
       
   942         ret = CreateClient( iClientUid, nullBuf );
       
   943         }
       
   944     
       
   945  	if (  ret == KErrNone )
       
   946    		{
       
   947    		iServer.SetAssociationFlag( ETrue ); // Send association status
       
   948    		iClient->Update( aIapId );   
       
   949    		}    
       
   950 
       
   951 	return ret;
       
   952     }
       
   953 // -----------------------------------------------------------------------------
       
   954 // ProcessAssociationStatus
       
   955 // -----------------------------------------------------------------------------
       
   956 //   
       
   957 TInt CHotSpotSession::ProcessAssociationStatus( const TUint aIapId, TBool aResult )
       
   958     {
       
   959     DEBUG("CHotSpotSession::ProcessAssociationStatus");
       
   960     TInt ret( KErrNone );
       
   961     iServer.SetAssociationFlag( EFalse );
       
   962     if ( iHotspotExtension )
       
   963         { 
       
   964         iHotspotExtension = EFalse;
       
   965         if ( iClient != NULL )
       
   966             {
       
   967             DEBUG("CHotSpotSession::ProcessAssociationStatus sent to client");
       
   968             iClient->WlanAssociationStatus( aIapId, aResult );
       
   969             }
       
   970        }
       
   971     DEBUG("CHotSpotSession::ProcessAssociationStatus Done");
       
   972     return ret;
       
   973     }
       
   974 
       
   975 // -----------------------------------------------------------------------------
       
   976 // CreateClient
       
   977 // -----------------------------------------------------------------------------
       
   978 //   
       
   979 TInt CHotSpotSession::CreateClient( const TUid aUid, TDesC8& aUidText )
       
   980     {
       
   981     DEBUG("CHotSpotSession::CreateClient");
       
   982     TInt err( KErrNone );
       
   983     if ( aUidText == KNullDesC8 )
       
   984         {
       
   985        	DEBUG("CHotSpotSession::CreateClient iHotspotExtension = EFalse;");
       
   986         iHotspotExtension = EFalse;
       
   987         TRAP( err, iClient = CHssClientPlugin::NewL( aUid, aUidText ) );
       
   988         DEBUG1("CHotSpotSession::CreateClient err: %d", err );
       
   989         }
       
   990     else
       
   991         {
       
   992         DEBUG("CHotSpotSession::CreateClient iHotspotExtension = ETrue;");
       
   993         iHotspotExtension = ETrue;
       
   994         TRAP( err, iClient = CHssClientPlugin::NewL( aUid, aUidText ) );
       
   995         DEBUG1("CHotSpotSession::CreateClient err: %d", err );
       
   996         }
       
   997     return err;
       
   998     }
       
   999     
       
  1000 // -----------------------------------------------------------------------------
       
  1001 // ProcessClose
       
  1002 // -----------------------------------------------------------------------------
       
  1003 //   
       
  1004 TInt CHotSpotSession::ProcessCloseL( const TUint aIapId )
       
  1005     {
       
  1006     DEBUG("CHotSpotSession::ProcessCloseL");
       
  1007     TInt ret( KErrNone );
       
  1008     TUid clientUid;
       
  1009     TBuf8<KExtensionAPILength> extAPI;
       
  1010   
       
  1011     iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
       
  1012     if ( clientUid == TUid::Null() )
       
  1013         {
       
  1014         DEBUG("CHotSpotSession::ProcessCloseL clientUid = EMPTY");
       
  1015         // do nothing
       
  1016         ret = KErrNotSupported;
       
  1017         }
       
  1018     else
       
  1019         {
       
  1020         DEBUG("CHotSpotSession::ProcessCloseL clientUid = CLIENT");
       
  1021         if ( iClient == NULL )
       
  1022             {
       
  1023             TBuf8<KExtensionAPILength> nullBuf;
       
  1024             ret = CreateClient( clientUid, nullBuf );
       
  1025             }
       
  1026 		else
       
  1027 		    {
       
  1028 		    ret = KErrNone;   
       
  1029 		    }
       
  1030 		iLogoutTimer->After( iServer.GetLogoutTimeMicroSecs( clientUid ) );
       
  1031         if ( ret == KErrNone && !iServer.GetLogoutFlagValue() )
       
  1032         	{
       
  1033         	DEBUG("CHotSpotSession::ProcessCloseL send Logout()");
       
  1034             iClient->Logout( aIapId );
       
  1035         	iServer.SetLogoutFlag( ETrue );
       
  1036         	iServer.SetLoginFlag( EFalse );
       
  1037             }
       
  1038         else
       
  1039             {
       
  1040             ret = KErrNotFound;
       
  1041             }    
       
  1042       
       
  1043         }
       
  1044 	return ret;
       
  1045     }
       
  1046  
       
  1047 // -----------------------------------------------------------------------------
       
  1048 // ProcessServerShutdown
       
  1049 // -----------------------------------------------------------------------------
       
  1050 //    
       
  1051 void CHotSpotSession::ProcessServerShutdown( const RMessage2& aMessage )
       
  1052     {
       
  1053     DEBUG("CHotSpotSession::ProcessServerShutdown");
       
  1054     TInt shutdown;
       
  1055     
       
  1056     shutdown = ( TInt )aMessage.Int0();
       
  1057     if ( KHssShutdown == shutdown )
       
  1058         {
       
  1059         DEBUG("CHotSpotSession::ProcessServerShutdown shutdown ");
       
  1060         aMessage.Complete( KErrNone );
       
  1061         RProcess server; // Sets the handle-number to the KCurrentProcessHandle
       
  1062         server.Kill( KErrNone );
       
  1063         }
       
  1064     else
       
  1065         {
       
  1066         DEBUG("CHotSpotSession::ProcessServerShutdown else ");
       
  1067         aMessage.Complete( KErrNone );
       
  1068         }
       
  1069     }
       
  1070     
       
  1071 // -----------------------------------------------------------------------------
       
  1072 // ProcessUiState
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //    
       
  1075 void CHotSpotSession::ProcessUiState( const RMessage2& aMessage )
       
  1076 	{
       
  1077     DEBUG( "CHotSpotSession::ProcessUiState()" );
       
  1078     TBool completeMsg = EFalse;
       
  1079     TInt indx( KErrNone );
       
  1080     TInt indxBrowser( KErrNone );
       
  1081     TInt ret( KErrNone );
       
  1082     iIapId = ( TInt )aMessage.Int0();
       
  1083 
       
  1084     indx = iServer.FindMessage( iIapId, EHssStartLogin );
       
  1085     indxBrowser = iServer.FindMessage( iIapId, EHssStartBrowser );
       
  1086     THsBrowserUiStates uiState = ( THsBrowserUiStates ) aMessage.Int1(); // UI state
       
  1087     switch ( uiState )
       
  1088    		{
       
  1089    		case EHsBrowserUiRunning:
       
  1090    			{
       
  1091    			DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiRunning" );
       
  1092    			break;
       
  1093    			}
       
  1094    	    case EHsBrowserUiAuthenticatedOk:
       
  1095    	        {
       
  1096    	        DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedOk" );
       
  1097 
       
  1098             completeMsg = ETrue;
       
  1099             break;
       
  1100    	        }
       
  1101    	    case EHsBrowserUiAuthenticatedNok:
       
  1102    	        {
       
  1103    		    DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiAuthenticatedNok" );
       
  1104    		    completeMsg = ETrue;
       
  1105    		    break;
       
  1106    		    }
       
  1107    	    case EHsBrowserUiClosed:
       
  1108    	        {
       
  1109    	        DEBUG( "CHotSpotSession::ProcessUiState() EHsBrowserUiClosed" );
       
  1110             completeMsg = ETrue;
       
  1111             break;
       
  1112    	        }
       
  1113    	    default:
       
  1114    	    	{
       
  1115    	    	DEBUG( "CHotSpotSession::ProcessUiState() default" );
       
  1116             completeMsg = ETrue;
       
  1117    	    	}
       
  1118    	    }
       
  1119     if ( completeMsg )
       
  1120    	    {
       
  1121         // complete messages EHssStartLogin/EHssStartBrowser
       
  1122         if ( indx >= 0 )
       
  1123            {
       
  1124            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartLogin" );
       
  1125            iServer.CompleteMessage( indx , KErrNone );
       
  1126            aMessage.Complete( KErrNone );
       
  1127            }
       
  1128         else if ( indxBrowser >= 0 )
       
  1129         	{
       
  1130         	DEBUG( "CHotSpotSession::ProcessUiState() completing EHssStartBrowser" );
       
  1131             iServer.CompleteMessage( indxBrowser, ret );
       
  1132             aMessage.Complete( KErrNone );
       
  1133         	}
       
  1134            else
       
  1135            {
       
  1136            DEBUG( "CHotSpotSession::ProcessUiState() completing EHssUiState" );
       
  1137            aMessage.Complete( KErrNotFound );
       
  1138            }
       
  1139         }
       
  1140     }    
       
  1141     
       
  1142 // -----------------------------------------------------------------------------
       
  1143 // Authenticate()
       
  1144 // -----------------------------------------------------------------------------
       
  1145 //    
       
  1146 void CHotSpotSession::AuthenticateL( const TDesC& aString )
       
  1147     {
       
  1148     DEBUG("CHotSpotSession::AuthenticateL()");
       
  1149 
       
  1150     const TInt KBrowserUid = 0x2000AFCC; // hotspot browser application
       
  1151     HBufC* param = HBufC::NewLC( KMaxFileName );
       
  1152     _LIT(tmpString, "%d, %d, %S");
       
  1153     param->Des().Format( tmpString, iIapId, iNetId, &aString );
       
  1154     TUid uid( TUid::Uid( KBrowserUid ) );
       
  1155     RApaLsSession appArcSession;
       
  1156     User::LeaveIfError( appArcSession.Connect() ); // connect to AppArc server
       
  1157     CleanupClosePushL( appArcSession );
       
  1158     TThreadId id;
       
  1159     TInt err = appArcSession.StartDocument( *param, TUid::Uid( KBrowserUid ), id );
       
  1160     if ( err != KErrNone )
       
  1161         {
       
  1162         DEBUG1( "CHotSpotSession::AuthenticateL() StartDocument: %d", err );
       
  1163         }
       
  1164     CleanupStack::PopAndDestroy( &appArcSession );
       
  1165     CleanupStack::PopAndDestroy( param );
       
  1166 
       
  1167     DEBUG("CHotSpotSession::AuthenticateLC() done");
       
  1168     }
       
  1169 
       
  1170 // -----------------------------------------------------------------------------
       
  1171 // ConnectionStateChanged
       
  1172 // -----------------------------------------------------------------------------
       
  1173 //
       
  1174 void CHotSpotSession::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
       
  1175     {
       
  1176     DEBUG1( "CHotSpotSession::ConnectionStateChanged() aNewState=%d", aNewState );
       
  1177     switch ( aNewState )
       
  1178             {
       
  1179             case EWlanConnectionModeSearching:
       
  1180                 {
       
  1181                 break;
       
  1182                 }
       
  1183             case EWlanConnectionModeInfrastructure:
       
  1184             case EWlanConnectionModeSecureInfra:
       
  1185                 {
       
  1186                 iMgtClient->CancelNotifications();
       
  1187                 ProcessAssociationStatus( iIapId, ETrue );
       
  1188                 break;
       
  1189                 }
       
  1190             case EWlanConnectionModeAdhoc:
       
  1191             case EWlanConnectionModeNotConnected:
       
  1192                 {
       
  1193                 iMgtClient->CancelNotifications();
       
  1194                 iServer.SetAssociationFlag( EFalse );
       
  1195                 break;
       
  1196                 }
       
  1197             default:
       
  1198                 {
       
  1199                 iMgtClient->CancelNotifications();
       
  1200                 iServer.SetAssociationFlag( EFalse );
       
  1201                 }
       
  1202             }
       
  1203     
       
  1204     }
       
  1205 
       
  1206 // end of file
       
  1207