--- a/hotspotfw/hsserver/src/hotspotsession.cpp Tue Jan 26 13:04:04 2010 +0200
+++ b/hotspotfw/hsserver/src/hotspotsession.cpp Fri Apr 16 16:07:56 2010 +0300
@@ -148,29 +148,29 @@
void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage )
{
DEBUG( "CHotSpotSession::DispatchMessageL()" );
- TUint value1(NULL);
- TInt value2(NULL);
- TInt err(KErrNone);
- TInt indx(KErrNone);
+ TInt value( NULL );
+ TInt err( KErrNone );
+ TInt indx( KErrNone );
TPckgBuf<TInt> iapPackage( iIapId );
switch ( aMessage.Function() )
{
case EHssActivateNotifications :
+ DEBUG( "CHotSpotSession::ActivateNotificationsL" );
iAllowNotifications = EFalse;
- DEBUG( "CHotSpotSession::ActivateNotificationsL" );
+
if ( iNotifications == NULL )
{
- DEBUG( "CHotSpotSession::DispatchMessageL activated !!!" );
- iNotifications = new (ELeave) HssNotifications(*this);
+ iNotifications = new ( ELeave ) HssNotifications( *this );
iMgtClient->ActivateNotificationsL( *iNotifications );
}
HandleOrderNotifications( aMessage );
break;
case EHssCancelNotifications :
+ DEBUG( "CHotSpotSession::CancelNotifications" );
iAllowNotifications = EFalse;
- DEBUG( "CHotSpotSession::CancelNotifications" );
iMgtClient->CancelNotifications( );
+
if ( iNotifications != NULL )
{
delete iNotifications;
@@ -178,9 +178,6 @@
iNotifications = NULL;
HandleCancelNotifications( aMessage );
break;
- case EHssGetScanResults :
- // Handled now in client side. Left here for future use.
- break;
case EHssRegister :
ProcessRegisterL( aMessage );
break;
@@ -189,17 +186,16 @@
break;
case EHssJoin :
iAllowNotifications = EFalse;
- // IAP id
- value1 = ( TInt )aMessage.Int0();
- iIapId = value1;
- indx = iServer.FindMessage(value1, EHssStart );
+ iIapId = ( TInt )aMessage.Int0();
+
+ indx = iServer.FindMessage( iIapId, EHssStart );
if ( indx >= 0 )
{
iServer.CompleteMessage( indx , KErrNone );
}
else
{
- indx = iServer.FindMessage(value1, EHssStartAgain );
+ indx = iServer.FindMessage( iIapId, EHssStartAgain );
if ( indx >= 0 )
{
iServer.CompleteMessage( indx , KErrNone );
@@ -211,8 +207,8 @@
iServer.SetLogoutFlag( ETrue );
// Do not send association status to client
iServer.SetAssociationFlag( EFalse );
- // IAP id
iIapId = ( TInt )aMessage.Int0();
+
indx = iServer.FindMessage(iIapId, EHssStart );
if ( indx >= 0 )
{
@@ -226,42 +222,38 @@
iServer.CompleteMessage( indx , KErrAbort );
}
}
-
aMessage.Complete( KErrNone );
break;
case EHssStop :
iAllowNotifications = EFalse;
iServer.SetLogoutFlag( ETrue );
-
iLoginTimer->Cancel();
iLogoutTimer->Cancel();
- // IAP id
- value1 = ( TInt )aMessage.Int0();
- for (TInt counter = EHssGetScanResults; counter <EHssServerShutdown ;counter++)
+ iIapId = ( TInt )aMessage.Int0();
+
+ for ( TInt counter = EHssGetScanResults;
+ counter <EHssServerShutdown ;counter++ )
{
- indx = iServer.FindMessage(value1, THotSpotCommands(counter ));
+ indx = iServer.FindMessage( iIapId,
+ THotSpotCommands( counter ) );
if ( indx >= 0 )
{
- iServer.CompleteMessage( indx , KErrCancel);
+ iServer.CompleteMessage( indx , KErrCancel );
}
}
-
aMessage.Complete( KErrNone );
break;
case EHssLoginComplete :
iAllowNotifications = EFalse;
- // IAP id
- value1 = ( TInt )aMessage.Int0();
- // ret value
- value2 = ( TInt )aMessage.Int1();
+ iLoginTimer->Cancel();
+ iIapId = ( TInt )aMessage.Int0();
+ value = ( TInt )aMessage.Int1();
- iLoginTimer->Cancel();
-
- DEBUG1( "EHssLoginComplete value2: %d", value2 );
- indx = iServer.FindMessage( value1, EHssStartLogin );
+ DEBUG1( "EHssLoginComplete return value: %d", value );
+ indx = iServer.FindMessage( iIapId, EHssStartLogin );
if ( KErrNotFound != indx )
{
- if (value2 == KErrNone)
+ if ( value == KErrNone )
{
DEBUG( "EHssLoginComplete1" );
iServer.CompleteMessage( indx, KErrNone );
@@ -279,11 +271,9 @@
case EHssLogoutComplete :
iAllowNotifications = EFalse;
iLogoutTimer->Cancel();
+ iIapId = ( TInt )aMessage.Int0();
- // IAP id
- value1 = ( TInt )aMessage.Int0();
-
- indx = iServer.FindMessage( value1, EHssCloseConnection );
+ indx = iServer.FindMessage( iIapId, EHssCloseConnection );
if ( KErrNotFound != indx )
{
iServer.CompleteMessage( indx, KErrNone );
@@ -294,10 +284,9 @@
case EHssStartLogin :
// Do not send association status, since it's already done.
iServer.SetAssociationFlag( EFalse );
- // IAP id
iIapId = ( TInt )aMessage.Int0();
- // Network id
iNetId = ( TInt )aMessage.Int1();
+
err = iServer.SaveMessage( iIapId, aMessage, EHssStartLogin );
if ( KErrNone != err )
{
@@ -339,18 +328,17 @@
aMessage.Complete( KErrNone );
break;
case EHssStart:
- // IAP id
iServer.SetLoginFlag( ETrue );
iIapId = ( TInt )aMessage.Int0();
err = iServer.SaveMessage( iIapId, aMessage, EHssStart );
- if ( err != KErrNone)
+
+ if ( err != KErrNone)
{
aMessage.Complete( err );
}
else
{
TRAPD( startLeaved, err = ProcessStartL( iIapId ) );
-
if ( startLeaved != KErrNone)
{
indx = iServer.FindMessage(iIapId, EHssStart );
@@ -363,7 +351,6 @@
aMessage.Complete( KErrNotSupported );
}
}
-
else if ( err != KErrNone)
{
indx = iServer.FindMessage(iIapId, EHssStart );
@@ -376,16 +363,14 @@
aMessage.Complete( KErrNotSupported );
}
}
- // else -> client is created and called
- // WLAN agent waits for 30 seconds before continuing connection setup.
}
break;
case EHssStartAgain:
- // IAP id
iServer.SetLoginFlag( ETrue );
iIapId = ( TInt )aMessage.Int0();
err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain );
- if ( err != KErrNone)
+
+ if ( err != KErrNone)
{
aMessage.Complete( err );
}
@@ -406,12 +391,11 @@
}
}
break;
+ case EHssCancel:
+ iLoginTimer->Cancel();
+ iLogoutTimer->Cancel();
+ iIapId = ( TInt )aMessage.Int0();
- case EHssCancel:
- iLoginTimer->Cancel();
- iLogoutTimer->Cancel();
- // IAP id
- iIapId = ( TInt )aMessage.Int0();
if ( iServer.GetAssociationFlagValue() )
{
// We are in association phase and Agent failed it for some reason
@@ -433,17 +417,11 @@
{
iServer.CompleteMessage( indx , KErrCancel );
}
- //Not needed to send Logout()
- //iServer.SetLogoutFlag( ETrue )
- //ProcessCloseL( iIapId )
aMessage.Complete( KErrNone );
- break;
-
+ break;
case EHssCloseConnection:
iLoginTimer->Cancel();
iLogoutTimer->Cancel();
-
- // IAP id
iIapId = ( TInt )aMessage.Int0();
if ( iServer.GetAssociationFlagValue() )
@@ -476,21 +454,18 @@
}
}
break;
-
case EHssServerShutdown:
ProcessServerShutdown( aMessage );
break;
-
case EHssGetIAP:
aMessage.WriteL( 0, iapPackage );
aMessage.Complete( KErrNone );
break;
-
case EHssUiState:
ProcessUiState( aMessage );
break;
case EHssStartBrowser:
- {
+ {
TInt len = aMessage.GetDesLength( 0 );
iIapId = ( TInt )aMessage.Int1();
iNetId = ( TInt )aMessage.Int2();
@@ -502,26 +477,25 @@
AuthenticateL( ptr );
CleanupStack::PopAndDestroy(buf);
+ break;
}
- break;
-
case EHssSetTimerValues:
{
TUid clientUid( TUid::Uid( aMessage.Int0() ) );
+ TBuf<KUidLength> uid;
+ uid.Copy( clientUid.Name() );
+ ModifyClientUid( uid );
TUint loginTimerValue = aMessage.Int1();
TUint logoutTimerValue = aMessage.Int2();
- iServer.SetTimerValues( clientUid, loginTimerValue, logoutTimerValue );
+ iServer.SetTimerValues( uid, loginTimerValue, logoutTimerValue );
aMessage.Complete( KErrNone );
+ break;
}
- break;
-
default:
aMessage.Complete( KErrNotSupported );
- //PanicClient( aMessage, EBadRequest )
break;
}
iAllowNotifications = TRUE;
-
}
// ---------------------------------------------------------
@@ -698,16 +672,17 @@
iServer.CompleteMessage( indx, KErrCancel );
}
- TUid clientUid;
TBuf8<KExtensionAPILength> extAPI;
- TRAP_IGNORE( iIapSettingsHandler->FindClientL( iIapId, clientUid, extAPI ) );
-
- // 3rd party client was found
- if ( clientUid != TUid::Null() )
+ TBuf<KUidLength> clientUid;
+ TInt err = iServer.GetClientUid( iIapId, clientUid );
+
+ if ( err != KErrNotFound )
{
DEBUG("CHotSpotSession::LoginTimeout clientUid = CLIENT");
+ ConvertTBufToTUid( clientUid );
TBuf8<KExtensionAPILength> nullBuf;
- TInt ret = CreateClient( clientUid, nullBuf );
+
+ TInt ret = CreateClient( iClientUid, nullBuf );
DEBUG1("CHotSpotSession::LoginTimeout CreateClient ret: %d", ret);
if ( KErrNone == ret )
{
@@ -754,21 +729,24 @@
aMessage.ReadL( 1, iapPckg );
iapName = iapPckg().IapName();
+ TBuf<KIapNameLength> bufUid;
+ bufUid.Copy( clientUid.Name() );
+ ModifyClientUid( bufUid );
+
TUint32 iapId( 0 );
- // TRAPD needed here so that 0 can be returned if DeleteIapL leaves
+
TInt ret( KErrNone );
- TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, clientUid ));
+ TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, bufUid ));
DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId );
DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret );
if ( KErrNone == ret )
{
+ iServer.SetClientIap( iapId, bufUid );
aMessage.Complete( iapId );
}
else
{
- // TRAP needed here so that 0 can be returned if DeleteIapL leaves
- //TRAP(err, iIapSettingsHandler->DeleteIapL( iapId ))
// Error, we are returning 0 to client
// and no IAP is created
aMessage.Complete( KErrNone );
@@ -787,10 +765,10 @@
// Read message
TInt iapId = ( TInt )aMessage.Int0();
-
+ iServer.RemoveClientIap( iapId );
// Check that this is not Easy WLAN
- TRAP_IGNORE( EasyWlanIdL() );
- if ( iEasyWlanId != iapId )
+ TInt easyWlan = iServer.GetEasyWlanId();
+ if ( easyWlan != iapId )
{
TRAPD( err, iIapSettingsHandler->DeleteIapL( iapId ) );
// return KErrGeneral if IAP removal is not successful
@@ -802,9 +780,9 @@
else
{
ret = KErrPermissionDenied;
- }
-
+ }
aMessage.Complete( ret );
+ DEBUG("CHotSpotSession::ProcessUnRegisterL DONE");
}
// -----------------------------------------------------------------------------
@@ -815,13 +793,12 @@
{
DEBUG("CHotSpotSession::ProcessStartLogin");
TInt ret( KErrNotFound );
- TUid clientUid;
TBuf8<KExtensionAPILength> extAPI;
iIapId = aIapId;
// Check if Easy WLAN.
- TRAP_IGNORE( EasyWlanIdL() );
- if ( iEasyWlanId == aIapId )
+ TInt easyWlan = iServer.GetEasyWlanId();
+ if ( easyWlan == aIapId )
{
DEBUG("CHotSpotSession::ProcessStartLogin Easy WLAN detected");
// Just test internet connectivity and complete message later
@@ -830,14 +807,16 @@
return ret;
}
- iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
+ TBuf<KUidLength> clientUid;
+ TInt err = iServer.GetClientUid( aIapId, clientUid );
- // 3rd party client was found
- if ( clientUid != TUid::Null() )
+ if ( err != KErrNotFound )
{
DEBUG("CHotSpotSession::ProcessStartLogin clientUid = CLIENT");
+ ConvertTBufToTUid( clientUid );
TBuf8<KExtensionAPILength> nullBuf;
- ret = CreateClient( clientUid, nullBuf );
+
+ ret = CreateClient( iClientUid, nullBuf );
if ( KErrNone == ret && iServer.GetLoginFlagValue() )
{
@@ -865,9 +844,10 @@
TInt ret( KErrNone );
TBuf8<KExtensionAPILength> extAPI;
+ TBuf<KUidLength> clientUid;
- iIapSettingsHandler->FindClientL( aIapId, iClientUid, extAPI );
- if ( iClientUid == TUid::Null() )
+ TInt err = iServer.GetClientUid( aIapId, clientUid );
+ if ( err != KErrNone )
{
DEBUG("CHotSpotSession::ProcessStartL clientUid = EMPTY");
@@ -876,6 +856,8 @@
else
{
DEBUG("CHotSpotSession::ProcessStartL clientUid = CLIENT");
+ ConvertTBufToTUid( clientUid );
+ TBuf8<KExtensionAPILength> nullBuf;
// Try first with API extension defined
ret = CreateClient( iClientUid, extAPI );
@@ -911,7 +893,7 @@
// Client exists if StartAgain is called.
if ( iClient == NULL )
{
- TBuf8<KExtensionAPILength> nullBuf;
+ TBuf8<KExtensionAPILength> nullBuf;
ret = CreateClient( iClientUid, nullBuf );
}
@@ -978,11 +960,11 @@
{
DEBUG("CHotSpotSession::ProcessCloseL");
TInt ret( KErrNone );
- TUid clientUid;
TBuf8<KExtensionAPILength> extAPI;
-
- iIapSettingsHandler->FindClientL( aIapId, clientUid, extAPI );
- if ( clientUid == TUid::Null() )
+ TBuf<KUidLength> clientUid;
+
+ TInt err = iServer.GetClientUid( aIapId, clientUid );
+ if ( err != KErrNone )
{
DEBUG("CHotSpotSession::ProcessCloseL clientUid = EMPTY");
// do nothing
@@ -993,8 +975,15 @@
DEBUG("CHotSpotSession::ProcessCloseL clientUid = CLIENT");
if ( iClient == NULL )
{
+ //Convert TBuf to TUid
+ TLex lex( clientUid );
+ TUint value( 0 );
+ lex.Val( value, EHex );
+ iClientUid = TUid::Null();
+ iClientUid.iUid = value;
TBuf8<KExtensionAPILength> nullBuf;
- ret = CreateClient( clientUid, nullBuf );
+
+ ret = CreateClient( iClientUid, nullBuf );
}
else
{
@@ -1142,22 +1131,36 @@
}
// -----------------------------------------------------------------------------
-// EasyWlanIdL
+// ModifyClientUid
// -----------------------------------------------------------------------------
//
-void CHotSpotSession::EasyWlanIdL()
+void CHotSpotSession::ModifyClientUid( TDes& aUid )
{
- DEBUG("CHotSpotSession::EasyWlanIdL()");
- // Set to default value just in case
- iEasyWlanId = KEasyWlanServiceId;
-
- RCmManagerExt cmManager;
- cmManager.OpenL();
- CleanupClosePushL( cmManager );
-
- iEasyWlanId = cmManager.EasyWlanIdL();
- DEBUG1("CHotSpotSession::EasyWlanIdL() ret: % d", iEasyWlanId);
- CleanupStack::PopAndDestroy( &cmManager );
+ DEBUG("CHotSpotSession::ModifyClientUid");
+ TInt indx = aUid.Find( KMark1 );
+ if ( KErrNotFound != indx )
+ {
+ aUid.Delete( indx, 1 );
+ indx = aUid.Find( KMark2 );
+ if ( KErrNotFound != indx )
+ {
+ aUid.Delete( indx, 1 );
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// ConvertTBufToTUid
+// -----------------------------------------------------------------------------
+//
+void CHotSpotSession::ConvertTBufToTUid( TDes& aUid )
+ {
+ DEBUG("CHotSpotSession::ConvertTBufToTUid");
+ TLex lex( aUid );
+ TUint value( 0 );
+ lex.Val( value, EHex );
+ iClientUid = TUid::Null();
+ iClientUid.iUid = value;
}
// -----------------------------------------------------------------------------
@@ -1168,32 +1171,32 @@
{
DEBUG1( "CHotSpotSession::ConnectionStateChanged() aNewState=%d", aNewState );
switch ( aNewState )
+ {
+ case EWlanConnectionModeSearching:
{
- case EWlanConnectionModeSearching:
- {
- break;
- }
- case EWlanConnectionModeInfrastructure:
- case EWlanConnectionModeSecureInfra:
- {
- iMgtClient->CancelNotifications();
- ProcessAssociationStatus( iIapId, ETrue );
- break;
- }
- case EWlanConnectionModeAdhoc:
- case EWlanConnectionModeNotConnected:
- {
- iMgtClient->CancelNotifications();
- iServer.SetAssociationFlag( EFalse );
- break;
- }
- default:
- {
- iMgtClient->CancelNotifications();
- iServer.SetAssociationFlag( EFalse );
- }
+ break;
+ }
+ case EWlanConnectionModeInfrastructure:
+ case EWlanConnectionModeSecureInfra:
+ {
+ iMgtClient->CancelNotifications();
+ ProcessAssociationStatus( iIapId, ETrue );
+ break;
}
-
+ case EWlanConnectionModeAdhoc:
+ case EWlanConnectionModeNotConnected:
+ {
+ iMgtClient->CancelNotifications();
+ iServer.SetAssociationFlag( EFalse );
+ break;
+ }
+ default:
+ {
+ iMgtClient->CancelNotifications();
+ iServer.SetAssociationFlag( EFalse );
+ }
+ }
+
}
// end of file