hotspotfw/hsserver/src/hotspotsession.cpp
changeset 2 6e4b6261703d
parent 0 56b72877c1cb
child 3 ff3b37722600
equal deleted inserted replaced
1:d07e190ed096 2:6e4b6261703d
    21 #include "hotspotserver.h"
    21 #include "hotspotserver.h"
    22 #include "hotspotsession.h"
    22 #include "hotspotsession.h"
    23 #include "hssnotif.h"
    23 #include "hssnotif.h"
    24 #include "hsslogintimer.h"
    24 #include "hsslogintimer.h"
    25 #include "hsslogouttimer.h"
    25 #include "hsslogouttimer.h"
       
    26 #include "hssclientinterface.h"
       
    27 #include "am_debug.h"
    26 #include <internetconnectivitycrkeys.h>
    28 #include <internetconnectivitycrkeys.h>
    27 #include <WlanCdbCols.h>
    29 #include <WlanCdbCols.h>
    28 #include <starterclient.h>
    30 #include <starterclient.h>
    29 #include "e32std.h"
    31 #include <cmmanagerext.h>
    30 #include "am_debug.h"
    32 #include <e32std.h>
    31 #include <ecom.h>
    33 #include <ecom.h>
    32 #include "hssclientinterface.h"
       
    33 #include <f32file.h>
    34 #include <f32file.h>
    34 #include <apgcli.h>
    35 #include <apgcli.h>
    35 
    36 
    36 // Forward declarations
    37 // Forward declarations
    37 class CWlanMgmtClient;
    38 class CWlanMgmtClient;
    60     iIapSettingsHandler = CHssIapSettingsHandler::NewL();
    61     iIapSettingsHandler = CHssIapSettingsHandler::NewL();
    61     iLoginTimer = CHssLoginTimer::NewL( *this );
    62     iLoginTimer = CHssLoginTimer::NewL( *this );
    62     iLogoutTimer = CHssLogoutTimer::NewL( *this );
    63     iLogoutTimer = CHssLogoutTimer::NewL( *this );
    63     
    64     
    64     iMgtClient = CWlanMgmtClient::NewL();
    65     iMgtClient = CWlanMgmtClient::NewL();
    65     
       
    66     iRepository = CRepository::NewL( KCRUidInternetConnectivitySettings );
       
    67     }
    66     }
    68 
    67 
    69 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    70 // NewL
    69 // NewL
    71 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
   124         {
   123         {
   125         iLogoutTimer->Cancel();
   124         iLogoutTimer->Cancel();
   126         delete iLogoutTimer;
   125         delete iLogoutTimer;
   127         }
   126         }
   128     iLogoutTimer = NULL;
   127     iLogoutTimer = NULL;
   129     
       
   130     if ( iRepository != NULL )
       
   131         {
       
   132         delete iRepository;
       
   133         }
       
   134     iRepository = NULL;
       
   135     
   128     
   136     if ( iIcts != NULL )
   129     if ( iIcts != NULL )
   137         {
   130         {
   138         delete iIcts;
   131         delete iIcts;
   139         }
   132         }
   647     DEBUG("CHotSpotSession::TestInternetConnectivityL");
   640     DEBUG("CHotSpotSession::TestInternetConnectivityL");
   648     if ( iIcts != NULL )
   641     if ( iIcts != NULL )
   649         {
   642         {
   650         delete iIcts;
   643         delete iIcts;
   651         }
   644         }
   652     TInt connectivityTestAllowed( EIctsRunAutomatically );
   645    
   653     iRepository->Get( KIctsTestPermission, connectivityTestAllowed );
   646     iIcts = CIctsClientInterface::NewL( iIapId, iNetId, *this );
   654     DEBUG1("CHotSpotSession::TestInternetConnectivityL: %d", connectivityTestAllowed);
   647     iIcts->StartL();
   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     }
   648     }
   670 
   649 
   671 // -----------------------------------------------------------------------------
   650 // -----------------------------------------------------------------------------
   672 // ConnectivityObserver
   651 // ConnectivityObserver
   673 // -----------------------------------------------------------------------------
   652 // -----------------------------------------------------------------------------
   810 //
   789 //
   811 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage )
   790 void CHotSpotSession::ProcessUnRegisterL( const RMessage2& aMessage )
   812 	{
   791 	{
   813 	DEBUG("CHotSpotSession::ProcessUnRegisterL");
   792 	DEBUG("CHotSpotSession::ProcessUnRegisterL");
   814 	iAllowNotifications = EFalse;
   793 	iAllowNotifications = EFalse;
   815    
   794     TInt ret( KErrNone );
       
   795 
   816     // Read message
   796     // Read message
   817     TInt iapId = ( TInt )aMessage.Int0();
   797     TInt iapId = ( TInt )aMessage.Int0();
   818     
   798     
   819     TInt ret( KErrNone );
       
   820     // Check that this is not Easy WLAN
   799     // Check that this is not Easy WLAN
   821     if ( iServer.GetEasyWlanId() != iapId  )
   800     TRAP_IGNORE( EasyWlanIdL() );
       
   801     if ( iEasyWlanId != iapId  )
   822         {
   802         {
   823         TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
   803         TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
   824         // return KErrGeneral if IAP removal is not successful
   804         // return KErrGeneral if IAP removal is not successful
   825         if ( err != KErrNone )
   805         if ( err != KErrNone )
   826             {
   806             {
   845     TInt ret( KErrNotFound );
   825     TInt ret( KErrNotFound );
   846     TUid clientUid;
   826     TUid clientUid;
   847     TBuf8<KExtensionAPILength> extAPI;
   827     TBuf8<KExtensionAPILength> extAPI;
   848     iIapId = aIapId;
   828     iIapId = aIapId;
   849     
   829     
   850     // This is Easy WLAN. 
   830     // Check if Easy WLAN.
   851     if ( iServer.GetEasyWlanId() == aIapId )
   831     TRAP_IGNORE( EasyWlanIdL() );
       
   832     if ( iEasyWlanId == aIapId )
   852     	{
   833     	{
   853     	 DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   834     	 DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
   854         // Just test internet connectivity and complete message later
   835         // Just test internet connectivity and complete message later
   855         TestInternetConnectivityL();
   836         TestInternetConnectivityL();
   856 		ret = KErrNone;
   837 		ret = KErrNone;
  1166 
  1147 
  1167     DEBUG("CHotSpotSession::AuthenticateLC() done");
  1148     DEBUG("CHotSpotSession::AuthenticateLC() done");
  1168     }
  1149     }
  1169 
  1150 
  1170 // -----------------------------------------------------------------------------
  1151 // -----------------------------------------------------------------------------
       
  1152 // EasyWlanIdL
       
  1153 // -----------------------------------------------------------------------------
       
  1154 //
       
  1155 void CHotSpotSession::EasyWlanIdL()
       
  1156     {
       
  1157     DEBUG("CHotSpotSession::EasyWlanIdL()");
       
  1158     // Set to default value just in case
       
  1159     iEasyWlanId = KEasyWlanServiceId; 
       
  1160     
       
  1161     RCmManagerExt cmManager;
       
  1162     cmManager.OpenL();
       
  1163     CleanupClosePushL( cmManager );
       
  1164     
       
  1165     iEasyWlanId = cmManager.EasyWlanIdL();
       
  1166     DEBUG1("CHotSpotSession::EasyWlanIdL() ret: % d", iEasyWlanId);
       
  1167     CleanupStack::PopAndDestroy( &cmManager );
       
  1168     }
       
  1169 
       
  1170 // -----------------------------------------------------------------------------
  1171 // ConnectionStateChanged
  1171 // ConnectionStateChanged
  1172 // -----------------------------------------------------------------------------
  1172 // -----------------------------------------------------------------------------
  1173 //
  1173 //
  1174 void CHotSpotSession::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
  1174 void CHotSpotSession::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
  1175     {
  1175     {