hotspotfw/hsserver/src/hotspotserver.cpp
changeset 3 ff3b37722600
parent 2 6e4b6261703d
child 10 dff6ebfd236f
equal deleted inserted replaced
2:6e4b6261703d 3:ff3b37722600
    14 * Description:       Implementation of HotSpot Plugin Server
    14 * Description:       Implementation of HotSpot Plugin Server
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 
       
    20 
       
    21 
       
    22 
    19 // INCLUDE FILES
    23 // INCLUDE FILES
    20 #include <e32std.h>
    24 #include <e32std.h>
    21 #include <f32file.h>
    25 #include <f32file.h>
    22 #include <wlanmgmtclient.h>
    26 #include <wlanmgmtclient.h>
    23 #include <wlanmgmtinterface.h>
    27 #include <wlanmgmtinterface.h>
   108 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   109 // PanicClient
   113 // PanicClient
   110 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   111 //    
   115 //    
   112 void PanicClient(const RMessagePtr2& aMessage,THotspotPanic aPanic)
   116 void PanicClient(const RMessagePtr2& aMessage,THotspotPanic aPanic)
   113 	{
   117     {
   114 	_LIT(KPanic,"HotspotServer");
   118     _LIT(KPanic,"HotspotServer");
   115 	aMessage.Panic(KPanic,aPanic);
   119     aMessage.Panic(KPanic,aPanic);
   116 	}
   120     }
   117 
   121 
   118 // ============================ MEMBER FUNCTIONS ===============================
   122 // ============================ MEMBER FUNCTIONS ===============================
   119     
   123     
   120 // -----------------------------------------------------------------------------
   124 // -----------------------------------------------------------------------------
   121 // CHotSpotServer
   125 // CHotSpotServer
   122 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   123 //
   127 //
   124 CHotSpotServer::CHotSpotServer()
   128 CHotSpotServer::CHotSpotServer()
   125 	:CPolicyServer( EPriorityStandard, THotSpotServerPlatSecPolicy, ESharableSessions )
   129     :CPolicyServer( EPriorityStandard, THotSpotServerPlatSecPolicy, ESharableSessions )
   126     {
   130     {
   127 	}
   131     }
   128 
   132 
   129 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   130 // NewLC
   134 // NewLC
   131 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   132 //
   136 //
   133 CHotSpotServer* CHotSpotServer::NewLC()
   137 CHotSpotServer* CHotSpotServer::NewLC()
   134 	{
   138     {
   135 	DEBUG("**** HotSpotServer: CHotSpotServer::NewLC");
   139     DEBUG("**** HotSpotServer: CHotSpotServer::NewLC");
   136 	CHotSpotServer* self = new(ELeave) CHotSpotServer;
   140     CHotSpotServer* self = new(ELeave) CHotSpotServer;
   137 	CleanupStack::PushL(self);
   141     CleanupStack::PushL(self);
   138 	self->ConstructL();
   142     self->ConstructL();
   139 	return self;
   143     return self;
   140 	}
   144     }
   141 
   145 
   142 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   143 // ~CHotSpotServer
   147 // ~CHotSpotServer
   144 // -----------------------------------------------------------------------------
   148 // -----------------------------------------------------------------------------
   145 //
   149 //
   146 CHotSpotServer::~CHotSpotServer()
   150 CHotSpotServer::~CHotSpotServer()
   147 	{
   151     {
   148 	DEBUG("**** HotSpotServer: CHotSpotServer::~CHotSpotServer");
   152     DEBUG("**** HotSpotServer: CHotSpotServer::~CHotSpotServer");
   149     
   153     
   150     iMap.Close();
   154     iMap.Close();
   151     iNotificationArray.Close();
   155     iNotificationArray.Close();
   152     iLoginLogoutTimerArray.Close();
   156     iLoginLogoutTimerArray.Close();
   153     
   157     
   154  	if ( iMgtClient != NULL )
   158      if ( iMgtClient != NULL )
   155         {
   159         {
   156 #ifndef __WINS__	
   160 #ifndef __WINS__    
   157         iMgtClient->CancelNotifications();
   161         iMgtClient->CancelNotifications();
   158 #endif
   162 #endif
   159         delete iMgtClient;
   163         delete iMgtClient;
   160         }
   164         }
   161  	iMgtClient = NULL;
   165     }
   162  	
       
   163 	}
       
   164 
   166 
   165 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   166 // ConstructL
   168 // ConstructL
   167 // -----------------------------------------------------------------------------
   169 // -----------------------------------------------------------------------------
   168 //
   170 //
   188 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   189 // ConnectionStateChanged
   191 // ConnectionStateChanged
   190 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   191 //
   193 //
   192 void CHotSpotServer::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
   194 void CHotSpotServer::ConnectionStateChanged( TWlanConnectionMode  aNewState ) 
   193 	{
   195     {
   194 	DEBUG1( "CHotSpotServer::ConnectionStateChanged() aNewState=%d", aNewState );
   196     DEBUG1( "CHotSpotServer::ConnectionStateChanged() aNewState=%d", aNewState );
   195     if ( aNewState == EWlanConnectionModeNotConnected )
   197     if ( aNewState == EWlanConnectionModeNotConnected )
   196     	{
   198         {
   197     	if ( iMgtClient != NULL )
   199         if ( iMgtClient != NULL )
   198             {
   200             {
   199 #ifndef __WINS__
   201 #ifndef __WINS__
   200             iMgtClient->CancelNotifications();
   202             iMgtClient->CancelNotifications();
   201 #endif
   203 #endif
   202             }
   204             }
   203     	
   205         
   204      	TRAPD(err, CheckIapsL());
   206          TRAPD(err, CheckIapsL());
   205      	if ( err != KErrNone )
   207          if ( err != KErrNone )
   206      		{
   208              {
   207      		DEBUG1("CHotSpotServer::ConnectionStateChanged(): %d", err);
   209              DEBUG1("CHotSpotServer::ConnectionStateChanged(): %d", err);
   208      		}
   210              }
   209     	}
   211         }
   210     }
   212     }
   211 
   213 
   212 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   213 // CheckIapsL
   215 // CheckIapsL
   214 // -----------------------------------------------------------------------------
   216 // -----------------------------------------------------------------------------
   215 //
   217 //
   216 void CHotSpotServer::CheckIapsL()
   218 void CHotSpotServer::CheckIapsL()
   217     {
   219     {
   218     DEBUG("CHotSpotServer::CheckIapsL");
   220     DEBUG("CHotSpotServer::CheckIapsL");
   219  	 	
   221           
   220  	_LIT(KMarkFirst, "[" );
   222      _LIT(KMarkFirst, "[" );
   221  	_LIT(KMarkLast, "]" );
   223      _LIT(KMarkLast, "]" );
   222  	// This is needed to be checked only once per boot
   224      // This is needed to be checked only once per boot
   223 	if ( iIapCheckValue == EFalse )
   225     if ( iIapCheckValue == EFalse )
   224 	    {
   226         {
   225 		iIapCheckValue = ETrue;
   227         iIapCheckValue = ETrue;
   226 		
   228         
   227 		RCmManagerExt cmManager;
   229         RCmManagerExt cmManager;
   228 	    cmManager.OpenL();
   230         cmManager.OpenL();
   229 	    CleanupClosePushL(cmManager);
   231         CleanupClosePushL(cmManager);
   230 
   232 
   231 	    TBool supportedBearersOnly = ETrue;
   233         TBool supportedBearersOnly = ETrue;
   232 	    TBool legacyCmsOnly = EFalse;
   234         TBool legacyCmsOnly = EFalse;
   233 	    
   235         
   234 	    RArray<TUint32> cmArray;
   236         RArray<TUint32> cmArray;
   235         CleanupClosePushL( cmArray );
   237         CleanupClosePushL( cmArray );
   236 	    
   238         
   237 	    cmManager.ConnectionMethodL( cmArray, supportedBearersOnly, legacyCmsOnly );
   239         cmManager.ConnectionMethodL( cmArray, supportedBearersOnly, legacyCmsOnly );
   238 	    DEBUG1("CHotSpotServer::CheckIapsL count: %d", cmArray.Count());  
   240         DEBUG1("CHotSpotServer::CheckIapsL count: %d", cmArray.Count());  
   239 	    for( TInt i = 0; i < cmArray.Count(); i++ )
   241         for( TInt i = 0; i < cmArray.Count(); i++ )
   240 	    	{
   242             {
   241 	    	RCmConnectionMethodExt cm;
   243             RCmConnectionMethodExt cm;
   242 		    TRAPD( err, cm = cmManager.ConnectionMethodL( cmArray[i] ) );
   244             TRAPD( err, cm = cmManager.ConnectionMethodL( cmArray[i] ) );
   243 		    DEBUG1("CHotSpotServer::CheckIapsL: err %d", err ); 
   245             DEBUG1("CHotSpotServer::CheckIapsL: err %d", err ); 
   244 		    if ( KErrNone == err )
   246             if ( KErrNone == err )
   245 		    	{
   247                 {
   246 		    	HBufC* client( NULL );
   248                 HBufC* client( NULL );
   247 		    	TRAPD( errr, client = cm.GetStringAttributeL( EWlanServiceExtensionTableName ));
   249                 TRAPD( errr, client = cm.GetStringAttributeL( EWlanServiceExtensionTableName ));
   248 		    	DEBUG1("CHotSpotServer::CheckIapsL: errr %d", errr );  
   250                 DEBUG1("CHotSpotServer::CheckIapsL: errr %d", errr );  
   249 		    	if( KErrNone == errr )
   251                 if( KErrNone == errr )
   250 		    		{
   252                     {
   251 		    		TBuf<KIapNameLength> clientUid;
   253                     TBuf<KIapNameLength> clientUid;
   252 		    		TUid uid(TUid::Null());
   254                     TUid uid(TUid::Null());
   253 		    		
   255                     
   254 		    		clientUid.Copy( client->Des() );
   256                     clientUid.Copy( client->Des() );
   255                     delete client;
   257                     delete client;
   256 		    		TInt indx = clientUid.Find( KMarkFirst );
   258                     TInt indx = clientUid.Find( KMarkFirst );
   257 		    		if ( KErrNotFound != indx )
   259                     if ( KErrNotFound != indx )
   258 						{
   260                         {
   259 						DEBUG("CHotSpotServer::CheckIapsL Client is found");
   261                         DEBUG("CHotSpotServer::CheckIapsL Client is found");
   260 						clientUid.Delete( indx, 1 );
   262                         clientUid.Delete( indx, 1 );
   261 					    indx = clientUid.Find( KMarkLast );
   263                         indx = clientUid.Find( KMarkLast );
   262 						if ( KErrNotFound != indx )
   264                         if ( KErrNotFound != indx )
   263 							{
   265                             {
   264 							clientUid.Delete( indx, 1 );
   266                             clientUid.Delete( indx, 1 );
   265 							}
   267                             }
   266 						// Convert TBuf to TUid
   268                         // Convert TBuf to TUid
   267 						TLex lex( clientUid );
   269                         TLex lex( clientUid );
   268 						TUint value( 0 );
   270                         TUint value( 0 );
   269 						User::LeaveIfError( lex.Val( value, EHex ) );
   271                         User::LeaveIfError( lex.Val( value, EHex ) );
   270 						uid.iUid = value; 
   272                         uid.iUid = value; 
   271 						 	   		
   273                                         
   272 						// Try to find if 3rd party client exists.
   274                         // Try to find if 3rd party client exists.
   273 						// Delete IAP if no client.
   275                         // Delete IAP if no client.
   274 						CHssClientPlugin* plugin(NULL);
   276                         CHssClientPlugin* plugin(NULL);
   275 						TBuf8<KExtensionAPILength> nullBuf;
   277                         TBuf8<KExtensionAPILength> nullBuf;
   276 						TRAPD( error, plugin = CHssClientPlugin::NewL( uid, nullBuf ) );
   278                         TRAPD( error, plugin = CHssClientPlugin::NewL( uid, nullBuf ) );
   277 				        delete plugin;
   279                         delete plugin;
   278 
   280 
   279 						DEBUG1("CHotSpotServer::CheckIapsL find client error: %d", error );
   281                         DEBUG1("CHotSpotServer::CheckIapsL find client error: %d", error );
   280 						if ( error == KErrNotFound )
   282                         if ( error == KErrNotFound )
   281 							{
   283                             {
   282 		    	   			cm.DeleteL();
   284                             cm.DeleteL();
   283 							}
   285                             }
   284 		    	   		}
   286                            }
   285 		    		}
   287                     }
   286 		    	}
   288                 }
   287 		    DEBUG("CHotSpotServer::CheckIapsLOK");
   289             DEBUG("CHotSpotServer::CheckIapsLOK");
   288 	    	}
   290             }
   289         CleanupStack::PopAndDestroy( &cmArray );
   291         CleanupStack::PopAndDestroy( &cmArray );
   290         CleanupStack::PopAndDestroy( &cmManager );
   292         CleanupStack::PopAndDestroy( &cmManager );
   291 		}
   293         }
   292 	DEBUG("CHotSpotServer::CheckIapsL Done");
   294     DEBUG("CHotSpotServer::CheckIapsL Done");
   293     }
   295     }
   294 
   296 
   295 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   296 // NewSessionL
   298 // NewSessionL
   297 // -----------------------------------------------------------------------------
   299 // -----------------------------------------------------------------------------
   298 //
   300 //
   299 CSession2* CHotSpotServer::NewSessionL( const TVersion& aVersion, 
   301 CSession2* CHotSpotServer::NewSessionL( const TVersion& aVersion, 
   300                                         const RMessage2& /* aMessage */ ) const
   302                                         const RMessage2& /* aMessage */ ) const
   301     {
   303     {
   302 	TVersion version( KHotSpotMajorVersionNumber,
   304     TVersion version( KHotSpotMajorVersionNumber,
   303                       KHotSpotMinorVersionNumber,
   305                       KHotSpotMinorVersionNumber,
   304                       KHotSpotBuildVersionNumber );
   306                       KHotSpotBuildVersionNumber );
   305 
   307 
   306     if ( !User::QueryVersionSupported( version, aVersion ) )
   308     if ( !User::QueryVersionSupported( version, aVersion ) )
   307         {
   309         {
   308         User::Leave( KErrNotSupported );
   310         User::Leave( KErrNotSupported );
   309         }
   311         }
   310 
   312 
   311 	DEBUG("**** CHotSpotServer::NewSessionL");
   313     DEBUG("**** CHotSpotServer::NewSessionL");
   312 	CHotSpotSession* session = 
   314     CHotSpotSession* session = 
   313         CHotSpotSession::NewL( const_cast<CHotSpotServer&>( *this ) );
   315         CHotSpotSession::NewL( const_cast<CHotSpotServer&>( *this ) );
   314     return session;
   316     return session;
   315     }
   317     }
   316 
   318 
   317 // ---------------------------------------------------------
   319 // ---------------------------------------------------------
   494 // -----------------------------------------------------------------------------
   496 // -----------------------------------------------------------------------------
   495 // RunError
   497 // RunError
   496 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
   497 //
   499 //
   498 TInt CHotSpotServer::RunError( TInt aError )
   500 TInt CHotSpotServer::RunError( TInt aError )
   499 	{
   501     {
   500     // error from CHotSpotSession::ServiceL
   502     // error from CHotSpotSession::ServiceL
   501     Message().Complete( aError );
   503     Message().Complete( aError );
   502     // Continue  reading client requests
   504     // Continue  reading client requests
   503     ReStart();
   505     ReStart();
   504     return (KErrNone);
   506     return (KErrNone);
   505 	}
   507     }
   506 
   508 
   507 // -----------------------------------------------------------------------------
   509 // -----------------------------------------------------------------------------
   508 // GetLoginTimerMicroSecs
   510 // GetLoginTimerMicroSecs
   509 // -----------------------------------------------------------------------------
   511 // -----------------------------------------------------------------------------
   510 //
   512 //