hotspotfw/hsclient/src/hssiaphandler.cpp
changeset 25 001d4d78e350
parent 22 498f36116140
child 32 5bbf13e885a0
--- a/hotspotfw/hsclient/src/hssiaphandler.cpp	Mon May 03 13:32:51 2010 +0300
+++ b/hotspotfw/hsclient/src/hssiaphandler.cpp	Fri May 14 16:56:58 2010 +0300
@@ -18,7 +18,6 @@
 
 
 // INCLUDE FILES
-#include <EapType.h>
 #include <cdbpreftable.h>
 #include "hssiaphandler.h"
 #include "hotspotclientserver.h"
@@ -40,9 +39,9 @@
 // -----------------------------------------------------------------------------
 //
 CHssIapHandler::CHssIapHandler( )
-	{
+    {
     DEBUG("CHssIapHandler::CHssIapHandler");
-	}
+    }
 
 // -----------------------------------------------------------------------------
 // ConstructL
@@ -71,15 +70,15 @@
 // -----------------------------------------------------------------------------
 //
 CHssIapHandler::~CHssIapHandler()
-	{
-	DEBUG("CHssIapHandler::~CHssIapHandler()");
+    {
+    DEBUG("CHssIapHandler::~CHssIapHandler()");
     
-	if ( iWLANRecord != NULL )
-		{
-		delete iWLANRecord;
-		}
-	iWLANRecord = NULL;
-	}
+    if ( iWLANRecord != NULL )
+        {
+        delete iWLANRecord;
+        }
+    iWLANRecord = NULL;
+    }
 
 // -----------------------------------------------------------------------------
 // ChangeSettingsL
@@ -108,8 +107,8 @@
     
     // Read WLAN table service id
     TUint32 serviceId(0);
-	RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapID );
-	CleanupClosePushL( plugin );
+    RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapID );
+    CleanupClosePushL( plugin );
     serviceId = plugin.GetIntAttributeL( EWlanServiceId );
     DEBUG1("CHssIapHandler::ChangeSettingsL WLAN serviceId: %d", serviceId);
     
@@ -125,7 +124,7 @@
     CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion());
     CleanupStack::PushL( dbSession );
     iWLANRecord = static_cast<CMDBGenericRecord*>
-    	( CCDRecordBase::RecordFactoryL( 0));
+        ( CCDRecordBase::RecordFactoryL( 0 ) );
             
     iWLANRecord->InitializeL( KGenericTable(),NULL );
     iWLANRecord->SetRecordId( serviceId );
@@ -156,9 +155,9 @@
     // -> Destination can become unusable.
     TInt secMode = aSettings.iSecurityMode;
     if ( secMode > EHssWpa2Only )
-    	{
-    	secMode = EHssAllowUnsecure;
-    	}
+        {
+        secMode = EHssAllowUnsecure;
+        }
     
     if( secMode == EHssWep )
         {
@@ -194,88 +193,12 @@
             *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaKeyLength)) = aSettings.iWPAKeyLength;
             *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk;
             }
-        else // Use EAP
+        else // Use EAP. EAP settings can be set with EAP API.
             {
             DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode > EHssWep -> EAP");
             *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk;
             }
         }
-      
-    // access point updated EAP data can be now set if needed
-    if ( ( !aSettings.iEnableWpaPsk ) && secMode > EHssWep )
-        {
-        DEBUG("CHssIapHandler::ChangeSettingsL -> Set EAP data");
-        TBuf8<KEapListMaxLength> enabledEapList;
-        for (TInt i=0;i<aSettings.iEapDataArray.Count();i++)
-            {
-            TBuf8< KEapExpandedIdLength > eapTypeCue;
-            TChar eapCode;
-            GetEapTypeDesC(aSettings.iEapDataArray[i]->iEAPType, eapTypeCue, eapCode );
-        
-            CEapType* eapType = NULL;
-            TRAPD( error, ( eapType = CEapType::NewL( eapTypeCue, ELan, serviceId ) ) );
-            DEBUG1(" CEapType::NewL error: %d", error);
-            if ( ( error == KErrNone ) && eapType )
-                {
-                CleanupStack::PushL( eapType );
-                EAPSettings* eapSettings = new (ELeave) EAPSettings;
-                
-                ConvertEApSettings( *aSettings.iEapDataArray[i], *eapSettings );
-                
-                // Set EAP tunneling
-                if ( aSettings.iEapDataArray[i]->iEncapsulatedInside != EAPSettings::EEapNone )
-                	{
-                	DEBUG("iEncapsulatedInside != EAPSettings::EEapNone");
-                	eapType->SetTunnelingType( 
-                			static_cast<TInt> ( aSettings.iEapDataArray[i]->iEncapsulatedInside ) );
-                	}
-                else // Write to EAP list
-                	{
-                	DEBUG("CHssIapHandler::ChangeSettingsL -> Add to EAP list");
-                	TBuf8<8> expandedForm;
-    	            expandedForm.AppendFill( 0xFE, 1 );
-    	            if ( THssEapSettings::EEapPlainMschapv2 == aSettings.iEapDataArray[i]->iEAPType )
-    	            	{
-    	            	expandedForm.AppendFill( 0xFF, 3 );
-    	            	}
-    	            else{
-    	            	expandedForm.AppendFill( 0x00, 6 );
-    	            	}
-    	       
-    	            expandedForm.AppendFill( eapCode, 1 );
-    	               	           
-    	            enabledEapList.Append( expandedForm );      
-    	        	}
-                
-                DEBUG("CHssIapHandler::ChangeSettingsL -> eapType->SetConfigurationL");
-                TRAPD( eapErr, eapType->SetConfigurationL( *eapSettings ) );
-                DEBUG1(" eapType->SetConfigurationL error: %d", eapErr);
-                if( eapErr != KErrNone )
-                	{
-                	CleanupStack::PopAndDestroy( eapType );
-                	CleanupStack::PopAndDestroy( dbSession );
-                    DEBUG("CHssIapHandler::ChangeSettingsL EapError DONE");
-                    return eapErr;
-                	}
-                CleanupStack::PopAndDestroy( eapType );
-                }
-            if ( error != KErrNone )
-                {
-                DEBUG("CHssIapHandler::ChangeSettingsL Eap error");
-                CleanupStack::PopAndDestroy( dbSession );
-                return error;
-                }
-            }
-       
-            // Set enabled EAP list
-            if ( enabledEapList.Length() > 0 )
-        		{
-        		DEBUG("CHssIapHandler::ChangeSettingsL -> Set EAP list");
-	            CMDBField<TDesC8>* eaps = (CMDBField<TDesC8>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanEnabledEaps );
-	            //eaps->SetMaxLengthL( eapList16.Length() )
-	            eaps->SetL( enabledEapList );
-            	}
-        }
     // now update the access point
     iWLANRecord->ModifyL( *dbSession );
     
@@ -375,65 +298,6 @@
     
     aPackedKey->SetL( wepBuf);
     }
-
-// -----------------------------------------------------------------------------
-// ConvertEApSettings
-// -----------------------------------------------------------------------------
-//
-void CHssIapHandler::ConvertEApSettings( THssEapSettings& aHssEap, EAPSettings& aEap )
-    {
-    DEBUG("CHssIapHandler::ConvertEApSettings");
-    aEap.iEAPType = static_cast<EAPSettings::TEapType>(aHssEap.iEAPType);
-    aEap.iUsernamePresent = aHssEap.iUsernamePresent;
-    aEap.iUsername = aHssEap.iUsername;
-    aEap.iPasswordPresent = aHssEap.iPasswordPresent;
-    aEap.iPassword = aHssEap.iPassword;
-    aEap.iRealmPresent = aHssEap.iRealmPresent;
-    aEap.iRealm = aHssEap.iRealm;
-    aEap.iUsePseudonymsPresent = aHssEap.iUsePseudonymsPresent;
-    aEap.iUsePseudonyms = aHssEap.iUsePseudonyms;
-    aEap.iVerifyServerRealmPresent = aHssEap.iVerifyServerRealmPresent;
-    aEap.iVerifyServerRealm = aHssEap.iVerifyServerRealm;
-    aEap.iRequireClientAuthenticationPresent = aHssEap.iRequireClientAuthenticationPresent;
-    aEap.iRequireClientAuthentication = aHssEap.iRequireClientAuthentication;
-    aEap.iSessionValidityTimePresent = aHssEap.iSessionValidityTimePresent;
-    aEap.iSessionValidityTime = aHssEap.iSessionValidityTime;
-    aEap.iCipherSuitesPresent = aHssEap.iCipherSuitesPresent;
-    
-    for( TInt i = 0; i < aHssEap.iCipherSuitesCount; i++ )
-        {
-        aEap.iCipherSuites.Append( aHssEap.iCipherSuites[i] );
-        }
-    aEap.iPEAPVersionsPresent = aHssEap.iPEAPVersionsPresent;
-    aEap.iPEAPv0Allowed = aHssEap.iPEAPv0Allowed;
-    aEap.iPEAPv1Allowed = aHssEap.iPEAPv1Allowed;
-    aEap.iPEAPv2Allowed = aHssEap.iPEAPv2Allowed;
-    aEap.iCertificatesPresent = aHssEap.iCertificatesPresent;
-    for( TInt i = 0; i < aHssEap.iCertificatesCount; i++ )
-        {
-        DEBUG("CHssIapHandler::ConvertEApSettings Certificates present");
-        CertificateEntry entry;
-        
-        entry.iCertType = static_cast<CertificateEntry::TCertType>( aHssEap.iCertificates[i]->iCertType );
-        entry.iSubjectNamePresent = aHssEap.iCertificates[i]->iSubjectNamePresent;
-        entry.iSubjectName = aHssEap.iCertificates[i]->iSubjectName;
-        entry.iIssuerNamePresent = aHssEap.iCertificates[i]->iIssuerNamePresent;
-        entry.iIssuerName = aHssEap.iCertificates[i]->iIssuerName;
-        entry.iSerialNumberPresent= aHssEap.iCertificates[i]->iSerialNumberPresent;
-        entry.iSerialNumber = aHssEap.iCertificates[i]->iSerialNumber;
-        entry.iSubjectKeyIDPresent = aHssEap.iCertificates[i]->iSubjectKeyIDPresent;
-        entry.iSubjectKeyID = aHssEap.iCertificates[i]->iSubjectKeyID;
-        
-        entry.iThumbprintPresent = aHssEap.iCertificates[i]->iThumbprintPresent;
-        entry.iThumbprint = aHssEap.iCertificates[i]->iThumbprint;
-        TRAP_IGNORE( aEap.iCertificates.AppendL( entry ) ); // Memory problem, ignored...
-        }
-    aEap.iEncapsulatedEAPTypesPresent = aHssEap.iEncapsulatedEAPTypesPresent;
-    for( TInt i = 0; i < aHssEap.iEncapsulatedEAPTypesCount; i++ )
-        {
-        aEap.iEncapsulatedEAPTypes.Append( aHssEap.iEncapsulatedEAPTypes[i] );
-        }
-    }
     
 // -----------------------------------------------------------------------------
 // ConvertAsciiToHex
@@ -455,78 +319,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// GetEapTypeDesC
-// -----------------------------------------------------------------------------
-//
-void CHssIapHandler::GetEapTypeDesC( TUint aEapType, TDes8& aEapString, TChar& aEapCode )
-    {
-    DEBUG1( "CHssIapHandler::GetEapTypeDesC aEapType: %d", aEapType );
-    switch ( aEapType )
-        {
-            // EapNone
-            case 0:
-                aEapString.Copy( KEapNoneId, KEapExpandedIdLength );
-                aEapCode = KEapNoneId[7];
-                break;
-            // KEapGtc
-            case 6:
-            	aEapString.Copy( KEapGtcId, KEapExpandedIdLength );
-            	aEapCode = KEapGtcId[7];
-                break;
-            // KEapTls
-            case 13:
-            	aEapString.Copy( KEapTlsId, KEapExpandedIdLength );
-            	aEapCode = KEapTlsId[7];
-                break;
-            // KEapLeap
-            case 17:
-            	aEapString.Copy( KEapLeapId, KEapExpandedIdLength );
-            	aEapCode = KEapLeapId[7];
-                break;
-            // KEapSim
-            case 18:
-            	aEapString.Copy( KEapSimId, KEapExpandedIdLength );
-            	aEapCode = KEapSimId[7];
-                break;
-            // KEapTtls
-            case 21:
-            	aEapString.Copy( KEapTtlsId, KEapExpandedIdLength );
-            	aEapCode = KEapTtlsId[7];
-                break;
-            // KEapAka
-            case 23:
-            	aEapString.Copy( KEapAkaId, KEapExpandedIdLength );
-            	aEapCode = KEapAkaId[7];
-                break;
-            // KEapPeap
-            case 25:
-            	aEapString.Copy( KEapPeapId, KEapExpandedIdLength );
-            	aEapCode = KEapPeapId[7];
-                break;
-            // KEapMschapv2
-            case 26:
-            	aEapString.Copy( KEapMschapv2Id, KEapExpandedIdLength );
-            	aEapCode = KEapMschapv2Id[7];
-                break;
-            // KEapSecurid
-            case 32:
-            	aEapString.Copy( KEapSecuridId, KEapExpandedIdLength );
-            	aEapCode = KEapSecuridId[7];
-                break;
-            // KEapPlainMschapv2
-            case 99:
-            	aEapString.Copy( KEapPlainMschapv2Id, KEapExpandedIdLength );
-            	aEapCode = KEapPlainMschapv2Id[7];
-            	break;
-            default:
-            	aEapString.Copy( KEapNoneId, KEapExpandedIdLength );
-            	aEapCode = KEapNoneId[7];
-                break;
-        }
-    DEBUG( "CHssIapHandler::GetEapTypeDesC DONE" );
-    }
-
-// -----------------------------------------------------------------------------
 // GetNetworkIdL
 // -----------------------------------------------------------------------------
 //