hotspotfw/hsclient/src/hssiaphandler.cpp
branchRCL_3
changeset 24 63be7eb3fc78
parent 20 a9524956f6b5
child 25 f28ada11abbf
--- a/hotspotfw/hsclient/src/hssiaphandler.cpp	Thu Aug 19 10:59:40 2010 +0300
+++ b/hotspotfw/hsclient/src/hssiaphandler.cpp	Tue Aug 31 16:18:40 2010 +0300
@@ -18,18 +18,17 @@
 
 
 // INCLUDE FILES
-#include <EapType.h>
 #include <cdbpreftable.h>
 #include "hssiaphandler.h"
 #include "hotspotclientserver.h"
 #include "am_debug.h"
 #include <es_enum.h>
 
-#include <cmconnectionmethodext.h>
+#include <cmconnectionmethod.h>
 #include <cmconnectionmethoddef.h>
-#include <cmmanagerext.h>
+#include <cmmanager.h>
 #include <cmmanagerdef.h>
-#include <cmdestinationext.h>
+#include <cmdestination.h>
 
 // CONSTANTS
 const TInt  KRetryCount   = 20;
@@ -44,9 +43,9 @@
 // -----------------------------------------------------------------------------
 //
 CHssIapHandler::CHssIapHandler( )
-	{
+    {
     DEBUG("CHssIapHandler::CHssIapHandler");
-	}
+    }
 
 // -----------------------------------------------------------------------------
 // ConstructL
@@ -75,15 +74,15 @@
 // -----------------------------------------------------------------------------
 //
 CHssIapHandler::~CHssIapHandler()
-	{
-	DEBUG("CHssIapHandler::~CHssIapHandler()");
+    {
+    DEBUG("CHssIapHandler::~CHssIapHandler()");
     
-	if ( iWLANRecord != NULL )
-		{
-		delete iWLANRecord;
-		}
-	iWLANRecord = NULL;
-	}
+    if ( iWLANRecord != NULL )
+        {
+        delete iWLANRecord;
+        }
+    iWLANRecord = NULL;
+    }
 
 // -----------------------------------------------------------------------------
 // ChangeSettingsL
@@ -97,23 +96,14 @@
     DEBUG("CHssIapHandler::ChangeSettingsL");
     TInt ret( KErrNone );
     
-    RCmManagerExt cmManager;
+    RCmManager cmManager;
     cmManager.OpenL();
     CleanupClosePushL( cmManager );
     
-    TUint easyWlanId = cmManager.EasyWlanIdL();
-    
-    // Easy WLAN can't be modified
-    if ( easyWlanId == aIapID )
-    	{
-        CleanupStack::PopAndDestroy( &cmManager ); 
-    	return KErrPermissionDenied;
-    	}
-    
     // Read WLAN table service id
     TUint32 serviceId(0);
-	RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapID );
-	CleanupClosePushL( plugin );
+    RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapID );
+    CleanupClosePushL( plugin );
     serviceId = plugin.GetIntAttributeL( EWlanServiceId );
     DEBUG1("CHssIapHandler::ChangeSettingsL WLAN serviceId: %d", serviceId);
     
@@ -129,7 +119,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 );
@@ -160,9 +150,9 @@
     // -> Destination can become unusable.
     TInt secMode = aSettings.iSecurityMode;
     if ( secMode > EHssWpa2Only )
-    	{
-    	secMode = EHssAllowUnsecure;
-    	}
+        {
+        secMode = EHssAllowUnsecure;
+        }
     
     if( secMode == EHssWep )
         {
@@ -198,89 +188,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 );
-            	}
-        }
-    
     // Update access point, be prepared that Commsdat might be locked
     TInt errCode( KErrLocked );
     TInt retryCount( 0 );
@@ -301,10 +214,10 @@
         // override previous ret value only when error happened        	    	
         ret = errCode;
         }
-    
+
     CleanupStack::PopAndDestroy( dbSession );
     DEBUG("CHssIapHandler::ChangeSettingsL DONE");
-    return ret;
+	return ret;
     }
  
 // -----------------------------------------------------------------------------
@@ -398,65 +311,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
@@ -478,78 +332,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
 // -----------------------------------------------------------------------------
 //
@@ -557,11 +339,11 @@
     {
     DEBUG( "CHssIapHandler::GetNetworkIdL()" );
     
-    RCmManagerExt cmManager;
+    RCmManager cmManager;
     cmManager.OpenL();
     CleanupClosePushL( cmManager );
 
-    RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapId );
+    RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapId );
     CleanupClosePushL( plugin );
     
     aNetId = plugin.GetIntAttributeL( ECmNetworkId );
@@ -589,7 +371,7 @@
     RArray<TUint32> destArray = RArray<TUint32>( 10 );  // KCmArrayGranularity instead of 10
     CleanupClosePushL( destArray );
 
-    RCmManagerExt cmManager;
+    RCmManager cmManager;
     cmManager.OpenL();
     CleanupClosePushL( cmManager );    
 
@@ -597,7 +379,7 @@
 
     for (TInt i = 0; i < destArray.Count(); i++)
         {
-        RCmDestinationExt dest = cmManager.DestinationL( destArray[i] );
+        RCmDestination dest = cmManager.DestinationL( destArray[i] );
         CleanupClosePushL( dest );
 
         for (TInt j = 0; j < dest.ConnectionMethodCount(); j++)