omacpadapters/accesspointadapter/Src/CWPAPNapdef.cpp
changeset 42 aa33c2cb9a50
child 56 a9afc3a8dbfa
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Class stores data for one accesspoint
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20  
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "CWPAPNapdef.h"
       
    24 #include <CWPCharacteristic.h>
       
    25 #include <CWPParameter.h>
       
    26 #include <WPAPAdapterResource.rsg>
       
    27 #include <featmgr.h>
       
    28 #include <WPAdapterUtil.h>
       
    29 #include "CWPAPAccesspointItem.h"
       
    30 #include "WPAPAdapter.pan"
       
    31 #include <WlanCdbCols.h>
       
    32 #include <EapType.h>
       
    33 #include <EapSettings.h>
       
    34 #include "ProvisioningDebug.h"
       
    35 #include <cmconnectionmethodext.h>
       
    36 #include <cmpluginpacketdatadef.h>
       
    37 #include <cmpluginwlandef.h>
       
    38 #include <cmmanagerext.h>
       
    39 #include <cmconnectionmethodext.h>
       
    40 #include <commdb.h>
       
    41 #include <WlanCdbCols.h>
       
    42 #include <EapExpandedType.h>
       
    43 #include <centralrepository.h>
       
    44 #include <pdpcontextmanagerinternalcrkeys.h>
       
    45 #include <EapGeneralSettings.h>
       
    46 #include <EapTypeDefinitions.h>
       
    47 
       
    48 const TUint KIapColumn        = 0x00000100;
       
    49 const TUint KLingerColumn     = 0x00000200;
       
    50 const TUint KColumnMask       = 0xFFFFFF00;
       
    51 const TUint KRowMask          = 0x000000FF;
       
    52 
       
    53 // Delay for comms db begintransaction retry (microseconds)
       
    54 const TInt KBeginTransRetryDelay = 1000000; 
       
    55 // Maximum number of retries
       
    56 const  TInt KBeginTransRetryCount = 7;      
       
    57 
       
    58 // ============================ MEMBER FUNCTIONS ===============================
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CWPAPNapdef::NewLC
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CWPAPNapdef* CWPAPNapdef::NewLC( TBool aFollowingLink,
       
    65                                  const TDesC& aDefaultName, 
       
    66                                  CWPCharacteristic& aLogicalCharacteristic,
       
    67                                  CWPCharacteristic& aLink )
       
    68 	{
       
    69 	CWPAPNapdef* self = new(ELeave) CWPAPNapdef( aFollowingLink,
       
    70 	                                             aDefaultName,
       
    71                                                  aLogicalCharacteristic ); 
       
    72 	CleanupStack::PushL( self );
       
    73 	self->ConstructL();
       
    74     aLink.AcceptL( *self );
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // Destructor
       
    80 // -----------------------------------------------------------------------------
       
    81 CWPAPNapdef::~CWPAPNapdef()
       
    82 	{
       
    83 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::~CWPAPNapdef" ) );
       
    84     
       
    85     iEapTypeArray.ResetAndDestroy();
       
    86     iEapTypeArray.Close();
       
    87     iSecSSID.ResetAndDestroy();
       
    88 	iSecSSID.Close();
       
    89     iNameServers.Close();
       
    90   
       
    91 	}
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CWPAPNapdef::ValidateL
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TBool CWPAPNapdef::ValidateL()
       
    98 	{
       
    99 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL" ) );
       
   100 	
       
   101     TBool result( ETrue );
       
   102 
       
   103 	if ( iBearer == KUidWlanBearerType )
       
   104 	    {	    	
       
   105 	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan" ) );
       
   106 	    if ( iWlanSupported )
       
   107 	    	{	    	
       
   108 	    	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan supported" ) );
       
   109 	    	return result;
       
   110 	    	}
       
   111 	    else
       
   112 	    	{
       
   113 	   		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan NOT supported" ) );
       
   114 	    	return EFalse;
       
   115 	    	}
       
   116 	    }
       
   117 	    
       
   118 	// Received unsupported bearer
       
   119 	if( iBearerUnsupported )
       
   120 	    {
       
   121 	    return EFalse;
       
   122 	    }
       
   123 	    
       
   124 	// Didn't receive a bearer value.
       
   125 	if ( iBearer == 0 )
       
   126 		{
       
   127     // Access point address type can also tell the bearer
       
   128 		if( iAccesspointNameType )
       
   129             {
       
   130             TPtrC addrType( iAccesspointNameType->Value() );
       
   131             if( addrType == KAddrTypeAPN )
       
   132                 {
       
   133                 iBearer =KUidPacketDataBearerType;
       
   134                 }
       
   135             }
       
   136         
       
   137         // If still couldn't determine the bearer, default to GPRS
       
   138         if( iBearer == 0 )
       
   139 			{
       
   140 			iBearer = KUidPacketDataBearerType;
       
   141 			}
       
   142 		}
       
   143 		        
       
   144     // "NAP-ADDRESS" (Access point name) must be defined
       
   145     if( iAccesspointName )
       
   146         {
       
   147         if( iAccesspointName->Value() == KNullDesC )
       
   148             {
       
   149             return EFalse;
       
   150             }
       
   151         }
       
   152     else
       
   153         {
       
   154         return EFalse;
       
   155         }
       
   156 
       
   157 	/* 
       
   158 	Combinations of authentication type, username and password and corressponding
       
   159 	value of prompt for password field. AuthType in this table means that provisioning document
       
   160 	contained authtype parameter and it was supported by the implementation.
       
   161 	Provisioning document names are used in table.
       
   162 	x means that value of the specified parameter is received and it was valid.
       
   163 	AuthType received & supported 
       
   164 	| AuthName 
       
   165 	| | AuthSecret 
       
   166 	| |	| "Prompt for Password"
       
   167 		  no
       
   168 	x     no
       
   169       x   no
       
   170 	x x   yes
       
   171         x no
       
   172     x   x yes
       
   173       x x no
       
   174     x x	x no
       
   175 	*/
       
   176 
       
   177 	// Set the "prompt password"-value. See the table above. Value is set to true
       
   178 	// only if we have supported authentication type and either username or password
       
   179 	// is empty.
       
   180 	if ( IsReceived( EWPParameterAuthentication_id ) &&
       
   181 	     ( ( !iPassword && iUserName ) ||( iPassword && !iUserName ) ) )
       
   182 		{
       
   183 		iPromptPassword = ETrue;	
       
   184 		}
       
   185 
       
   186     // IFNETWORKS is a list of possible protocols that a GPRS access points can be 
       
   187     // used for. 
       
   188     if( iBearer == KUidPacketDataBearerType && IsReceived( EWPParameterIfNetworks_id ) )
       
   189         {
       
   190         TLex lex( iIfNetworks->Value() );
       
   191         lex.Mark();
       
   192         do
       
   193             {
       
   194             TChar ch( lex.Get() );
       
   195 
       
   196             if( ( !iPdpType && !ch.IsAlphaDigit() ) || ( !iPdpType && lex.Eos() ) )
       
   197                 {
       
   198 				if(!lex.Eos())
       
   199 					{
       
   200 					lex.UnGet();
       
   201 					}
       
   202                 TPtrC value( lex.MarkedToken() );
       
   203 				if( !lex.Eos() )
       
   204 					{
       
   205 					lex.Inc();
       
   206 					}
       
   207                 
       
   208                 if( value == KIPv6 
       
   209                     && FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
   210                     {
       
   211                     //iPdpType = EIPv6;
       
   212                     // CMManager
       
   213                     iPdpType = RPacketContext::EPdpTypeIPv6;
       
   214                     result = ETrue;
       
   215                     }
       
   216                 else if( value == KIPv6 
       
   217                     && !FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
   218                     {
       
   219                     result = EFalse;
       
   220                     }
       
   221                 else if( value == KIPv4 )
       
   222                     {
       
   223                     //iPdpType = EIPv4;
       
   224                     // CMManager
       
   225                     iPdpType = RPacketContext::EPdpTypeIPv4;
       
   226                     result = ETrue;
       
   227                     }
       
   228                 }
       
   229             } while( !lex.Eos() );
       
   230         }
       
   231 
       
   232 	return result;
       
   233 	}
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CWPAPNapdef::AddItemsL
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 TInt CWPAPNapdef::AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
       
   240                             CWPAPItemBase* aLogicalProxy,
       
   241                             CWPAPItemBase* aPhysicalProxy ) 
       
   242 	{
       
   243 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL" ) );
       
   244 	
       
   245     TInt count( 0 );
       
   246 
       
   247     if( ( iFollowingLink || IsReceived( EWPParameterInternet_id ) 
       
   248                          || IsReceived( EWPParameterWlan_id ) )
       
   249                          && ValidateL() )
       
   250         {
       
   251         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL append" ) );
       
   252         CWPAPAccesspointItem* item = CWPAPAccesspointItem::NewLC(
       
   253                                                              iDefaultName,
       
   254                                                              aLogicalProxy,
       
   255                                                              aPhysicalProxy,
       
   256                                                              this,
       
   257                                                              iCharacteristic );
       
   258         User::LeaveIfError( aItems.Append( item ) );
       
   259         //Internet Parameter is received
       
   260         if (IsReceived(EWPParameterInternet_id) && !iFollowingLink)
       
   261             {
       
   262             SetInternetIndicator(aItems.Count() - 1);
       
   263             }
       
   264 
       
   265         
       
   266         count++;
       
   267         CleanupStack::Pop( item );
       
   268         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL append done" ) );
       
   269         }
       
   270     return count;
       
   271     }
       
   272 
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CWPAPNapdef::SetInternetIndicator
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 void CWPAPNapdef::SetInternetIndicator(TInt aValue)
       
   279     {
       
   280     iInternetIndicator = aValue;
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CWPAPNapdef::GetInternetIndicator
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 TInt CWPAPNapdef::GetInternetIndicator()
       
   288     {
       
   289     return iInternetIndicator;
       
   290     }
       
   291 
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CWPAPNapdef::AddDataL
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 void CWPAPNapdef::AddDataL( /*CApAccessPointItem& aAPItem*/ RCmConnectionMethodExt& aCmItem ) 
       
   298 	{
       
   299 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL" ) );
       
   300 	
       
   301 	TInt err( KErrNone );
       
   302 
       
   303     if ( iBearer == KUidWlanBearerType )    
       
   304 	    {			    	
       
   305 	    	if ( iWlanSupported )
       
   306         	{
       
   307         	// CMManager
       
   308         	AddWlanDataL( aCmItem);
       
   309         	}
       
   310         else
       
   311         	{
       
   312         	// WLAN is disabled (or does not exist) in the device.
       
   313         	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL WLAN disabled." ) );
       
   314         	User::Leave( KErrNotSupported );
       
   315         	}
       
   316 	    }
       
   317     else
       
   318         {	    
       
   319     	if ( iConnectionName )
       
   320     		{
       
   321     		// CMManager
       
   322     		aCmItem.SetStringAttributeL( CMManager::ECmName, (iConnectionName->Value().Left( KNameMaxLength ))); 
       
   323     		}
       
   324     	else // Use default name
       
   325     		{
       
   326     		// CMManager
       
   327     		aCmItem.SetStringAttributeL( CMManager::ECmName, iDefaultName );
       
   328     		}
       
   329     	
       
   330     	if ( iAccesspointName )
       
   331     		{
       
   332     		if ( iBearer == KUidPacketDataBearerType )
       
   333     			{
       
   334     			// CMManager
       
   335     			TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EPacketDataAPName, iAccesspointName->Value() ));
       
   336                 FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL value: %S, err: %d"),
       
   337                                                                      &iAccesspointName->Value(), err));    			                              
       
   338     			}
       
   339     		else
       
   340     			{
       
   341     			// CMManager
       
   342     			TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialDefaultTelNum, iAccesspointName->Value() ));
       
   343                 FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::EApIspDefaultTelNumber value: %S, err: %d"),
       
   344                 			      &iAccesspointName->Value(), err ) );
       
   345     			}
       
   346     		}
       
   347     		
       
   348     	TRAP ( err, aCmItem.UpdateL() );
       
   349 
       
   350     	 if ( iUserName )
       
   351     		{
       
   352     		// CMManager
       
   353     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialLoginName, iUserName->Value() ));
       
   354     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialLoginName value: %S, err: %d"),
       
   355     		                    		      &iUserName->Value(), err));
       
   356     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialIFAuthName, iUserName->Value() ));
       
   357     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialIFAuthName value: %S, err: %d"),
       
   358     		                    		      &iUserName->Value(), err));
       
   359     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIFAuthName, iUserName->Value() ));
       
   360     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFAuthName value: %S, err: %d"),
       
   361     		                    		      &iUserName->Value(), err));
       
   362     		}
       
   363     		
       
   364 		// CMManager
       
   365     	TRAP ( err, aCmItem.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, iPromptPassword));
       
   366     	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFPromptForAuth value: %d, err: %d"),
       
   367     	                            	      iPromptPassword, err ));
       
   368 
       
   369     	if ( iPassword )
       
   370     		{
       
   371     		// CMManager 
       
   372     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialLoginPassword, iPassword->Value() ));
       
   373     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialLoginPassword value: %d, err: %d"),
       
   374     		                		      &iPassword->Value(), err ) );
       
   375     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIFAuthPass, iPassword->Value() ));
       
   376     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFAuthPass value: %d, err: %d"),
       
   377     		                		      &iPassword->Value(), err ) );
       
   378     		}	
       
   379 
       
   380 		// CMManager
       
   381     	TRAP ( err, aCmItem.SetBoolAttributeL( CMManager::ECmDisablePlainTextAuth, iSecureAuthentication ));
       
   382         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EApEApIspDisablePlainTextAuth value: %d, err: %d"),    	                         
       
   383                 	                        iSecureAuthentication, err ) );
       
   384                 	                        
       
   385 			
       
   386         // IPv6 APs always have dynamic phone address
       
   387     	//CMManager
       
   388     	if ( iPhoneIPAddress && iPdpType != RPacketContext::EPdpTypeIPv6 )
       
   389     		{
       
   390     		// CMManager IS CORRECT?
       
   391     		//err = aAPItem.WriteTextL( EApIspIPAddr, iPhoneIPAddress->Value() );
       
   392     		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIPAddress, iPhoneIPAddress->Value() ));
       
   393     		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EApIspIPAddr value: %S, err: %d"),
       
   394                         		     &iPhoneIPAddress->Value(), err ) );
       
   395     		}
       
   396 
       
   397 		TRAP ( err, aCmItem.UpdateL() );
       
   398         for( TInt i( 0 ); i < iNameServers.Count(); i++ )
       
   399             {
       
   400             WriteDNSAddressL( aCmItem, iNameServers[i]->Value() );
       
   401             }
       
   402 		TRAP ( err, aCmItem.UpdateL() );
       
   403         if( FeatureManager::FeatureSupported( KFeatureIdIPv6 )
       
   404             && iPdpType )
       
   405             {
       
   406          	// CMManager
       
   407             TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EPacketDataPDPType, iPdpType ));
       
   408             }
       
   409     
       
   410     if ( err ) err = 0; // prevent compiler warning
       
   411         }
       
   412 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL" ) );
       
   413 	}
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // CWPAPNapdef::AddWlanDataL
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 void CWPAPNapdef::AddWlanDataL( RCmConnectionMethodExt& aCmItem )
       
   420     {
       
   421     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL" ) );
       
   422     
       
   423     if ( !iWlanSupported )
       
   424     	{
       
   425     		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL WLAN NOT supported." ) );
       
   426     		User::Leave( KErrNotSupported);
       
   427     	}
       
   428         
       
   429     TInt err = KErrNone;
       
   430     
       
   431 	if ( iConnectionName )
       
   432 		{
       
   433 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName" ) );
       
   434 		
       
   435 		//Connection name
       
   436 		// CMManager
       
   437 		aCmItem.SetStringAttributeL( CMManager::ECmName, iConnectionName->Value().Left( KNameMaxLength ) );
       
   438 		
       
   439 		// CMManager 
       
   440 		// Network name
       
   441 		aCmItem.SetStringAttributeL( CMManager::EWlanSSID, iConnectionName->Value());
       
   442 		
       
   443         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName err (%d) (%S)"), err, &iConnectionName->Value()));
       
   444 				
       
   445 		}
       
   446 	else // Use default name
       
   447 		{
       
   448 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName default" ) );
       
   449 		aCmItem.SetStringAttributeL( CMManager::EWlanSSID, iDefaultName);
       
   450 		}
       
   451 		   	
       
   452    	//EApWlanNetworkMode Gives network mode, TUint32
       
   453    	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanNetworkMode" ) );
       
   454 	// CMManager
       
   455    	TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EWlanConnectionMode, iNetMode ));
       
   456    	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanNetworkMode err (%d)"), err));
       
   457         
       
   458     //EApWlanSecurityMode The security mode, TUint32
       
   459     if ( iSecMode == 0 )
       
   460         {
       
   461         // This is needed if Provisioning message does not contain SECMODE parameter
       
   462         // AP does not work if secmode is not set
       
   463         iSecMode = CMManager::EWlanSecModeOpen;
       
   464         }
       
   465         
       
   466     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanSecurityMode" ) );
       
   467    	// CMManager, securitymode causes error -1, this will be set manually in SaveWlanData
       
   468    	//TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EWlanSecurityMode, iSecMode ));
       
   469     FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanSecurityMode err (%d)"), err));
       
   470     	
       
   471     if (err)
       
   472         {
       
   473         err = KErrNone;
       
   474         }
       
   475     }
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CWPAPNapdef::WriteDNSAddressL
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 void CWPAPNapdef::WriteDNSAddressL( /*CApAccessPointItem& aAPItem*/ RCmConnectionMethodExt& aCmItem,
       
   482                                     const TDesC& aValue )
       
   483 	{
       
   484     // GPRS access points supports IPv6 only if explicitly stated. 
       
   485     // CMManager
       
   486     TBool apSupportsIPv6( iPdpType == RPacketContext::EPdpTypeIPv6 | iBearer != KUidPacketDataBearerType );
       
   487 
       
   488     // If IPv6 is supported, write the DNS address as IPv6 if
       
   489     // bearer supports IPv6 and the address format is IPv6    
       
   490     if( FeatureManager::FeatureSupported( KFeatureIdIPv6 )
       
   491         && apSupportsIPv6
       
   492         && WPAdapterUtil::CheckIPv6( aValue ) )
       
   493         {
       
   494         // Two name servers per network type
       
   495         if( iNumIPv6NameServers < KTwoNameServersPerNetworkType )
       
   496             {
       
   497             // CMManager
       
   498             TRAPD (err, aCmItem.SetStringAttributeL( CMManager::TConnectionMethodCommonAttributes( 
       
   499             													( CMManager::ECmIP6NameServer1 ) + iNumIPv6NameServers ), aValue ) );
       
   500             User::LeaveIfError( err );
       
   501             iNumIPv6NameServers++;
       
   502             }
       
   503         }
       
   504      else if( CheckIPv4values( aValue) )
       
   505         {
       
   506         // Two name servers per network type
       
   507         if( iNumIPv4NameServers < KTwoNameServersPerNetworkType )
       
   508             {
       
   509             // CMManager 
       
   510             TRAPD ( err, aCmItem.SetStringAttributeL( CMManager::TConnectionMethodCommonAttributes( 
       
   511             													( CMManager::ECmIPNameServer1 ) + iNumIPv4NameServers ), aValue ) );
       
   512             User::LeaveIfError( err );
       
   513             aCmItem.SetBoolAttributeL( CMManager::ECmIPDNSAddrFromServer, EFalse);
       
   514             iNumIPv4NameServers++;
       
   515             }
       
   516         }
       
   517 	}
       
   518 // -----------------------------------------------------------------------------
       
   519 // CWPAPNapdef::CheckAddressPart
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 
       
   523 TBool CWPAPNapdef:: CheckAddressPart( TLex& aLex )
       
   524     {
       
   525     TBool result( aLex.Peek().IsDigit() );
       
   526     aLex.Inc();
       
   527     if( aLex.Peek().IsDigit() )
       
   528         {
       
   529         aLex.Inc();
       
   530         if( aLex.Peek().IsDigit() )
       
   531             {
       
   532             aLex.Inc();
       
   533             }
       
   534         }
       
   535 
       
   536     return result;
       
   537     }
       
   538 
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // CWPAPNapdef::CheckIPv4values
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 
       
   545 TBool CWPAPNapdef::CheckIPv4values( const TDesC& aValue )
       
   546 {
       
   547 	
       
   548 	TLex aLex( aValue );
       
   549 	return CheckAddressPart( aLex ) 
       
   550         && aLex.Get() == '.'
       
   551         && CheckAddressPart( aLex ) 
       
   552         && aLex.Get() == '.'
       
   553         && CheckAddressPart( aLex ) 
       
   554         && aLex.Get() == '.'
       
   555         && CheckAddressPart( aLex )
       
   556         && aLex.Get() == '\0';
       
   557      
       
   558 }
       
   559 // -----------------------------------------------------------------------------
       
   560 // CWPAPNapdef::Name
       
   561 // -----------------------------------------------------------------------------
       
   562 //
       
   563 const TDesC& CWPAPNapdef::Name()
       
   564 	{
       
   565 	if ( iConnectionName )
       
   566 		{
       
   567 		return iConnectionName->Value();
       
   568 		}
       
   569 	else
       
   570 		{
       
   571 		return KNullDesC;
       
   572 		}
       
   573 	}
       
   574 
       
   575 // -----------------------------------------------------------------------------
       
   576 // CWPAPNapdef::VisitL
       
   577 // -----------------------------------------------------------------------------
       
   578 //
       
   579 void CWPAPNapdef::VisitL( CWPCharacteristic& aCharacteristic )
       
   580 	{
       
   581 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic)" ) );
       
   582 	
       
   583 	TInt type = aCharacteristic.Type();
       
   584     FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) type (%d)"), type));
       
   585 	switch ( type )
       
   586 		{
       
   587 		case KWPNapAuthInfo:
       
   588 		case KWPValidity:				
       
   589 			{
       
   590 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) normal" ) );
       
   591 			aCharacteristic.AcceptL( *this );
       
   592 			break;
       
   593 			}
       
   594 		case KWPWLAN:
       
   595 		case KWPWepKey:
       
   596 			{
       
   597 			if( iWlanSupported )
       
   598 				{
       
   599 					FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) accept WLAN characteristic" ) );
       
   600 					aCharacteristic.AcceptL( *this );
       
   601 				}
       
   602 			}
       
   603 		default:
       
   604 			{
       
   605 			if ( ( ( ( aCharacteristic.Name().Compare( KWLAN ) ) == 0 )    ||
       
   606 			     ( ( aCharacteristic.Name().Compare( SECSSID ) ) == 0 )  ||
       
   607 			     ( ( aCharacteristic.Name().Compare( KEAP ) ) == 0 )     ||
       
   608 			     ( ( aCharacteristic.Name().Compare( KCERT ) ) == 0 )    ||
       
   609 			     ( ( aCharacteristic.Name().Compare( KWEP ) ) == 0 ) ) && iWlanSupported )
       
   610 			    {
       
   611 			    if(aCharacteristic.Name().Compare( KEAP ) == 0)
       
   612 			        {
       
   613                     CEapTypeElement* newEap = new (ELeave) CEapTypeElement;
       
   614                     newEap->iEAPSettings = new (ELeave) EAPSettings;
       
   615                	    newEap->iCertificate = new (ELeave) EapCertificateEntry;
       
   616                     iEapTypeArray.AppendL(newEap);
       
   617 			        }
       
   618 			    else if(aCharacteristic.Name().Compare( SECSSID ) == 0)
       
   619 			        {
       
   620                     SECssID* newsecSSID = new (ELeave) SECssID;
       
   621                     newsecSSID->iSSSID = NULL;
       
   622                     newsecSSID->iSUSSID = NULL;
       
   623                     iSecSSID.AppendL(newsecSSID);
       
   624 			        }
       
   625     
       
   626 			    aCharacteristic.AcceptL( *this );
       
   627 			    }
       
   628 			}
       
   629 		}
       
   630 		
       
   631 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) done" ) );
       
   632 	}
       
   633 
       
   634 // -----------------------------------------------------------------------------
       
   635 // CWPAPNapdef::VisitL
       
   636 // -----------------------------------------------------------------------------
       
   637 //
       
   638 void CWPAPNapdef::VisitL( CWPParameter& aParameter )
       
   639 	{
       
   640 	TInt id = aParameter.ID();
       
   641 	TPtrC value( aParameter.Value() );
       
   642 
       
   643 	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::VisitL(CWPParameter) id: %d value: %S"), id, &value));
       
   644 
       
   645 	switch ( id )
       
   646 		{
       
   647 		case EWPParameterName:
       
   648 			{
       
   649 			if ( !iConnectionName )
       
   650 				{
       
   651 				iConnectionName = &aParameter;
       
   652 				}
       
   653 			break;
       
   654 			}
       
   655 		case EWPParameterBearer:
       
   656 			{
       
   657 			if ( iBearer != 0 || iBearerUnsupported )
       
   658 				{
       
   659 				break; // Already received a bearer information
       
   660 				}
       
   661 
       
   662 			if ( value == KGSMGPRS )
       
   663 				{
       
   664 				iBearer = KUidPacketDataBearerType;
       
   665 				}
       
   666 			else if ( value == KWLAN && iWlanSupported )
       
   667 				{
       
   668 				iBearer = KUidWlanBearerType;
       
   669 				MarkReceived( EWPParameterWlan_id );
       
   670 				}				
       
   671 			else
       
   672 				{
       
   673 				// Unsupported bearer type
       
   674 				iBearerUnsupported = ETrue;
       
   675 				}
       
   676 			break;
       
   677 			}
       
   678 		case EWPParameterNapAddress:
       
   679 			{
       
   680 			if ( !iAccesspointName )
       
   681 				{
       
   682 				iAccesspointName = &aParameter;
       
   683 				}
       
   684 			break;
       
   685 			}
       
   686 		case EWPParameterLinger:
       
   687 			{
       
   688 			iLinger = &aParameter;
       
   689 			UdateligerValueL( iLinger );
       
   690 			break;
       
   691 			}
       
   692 		case EWPParameterNapAddrType:
       
   693 			{
       
   694 			if ( !iAccesspointNameType )
       
   695 				{
       
   696 				iAccesspointNameType = &aParameter;
       
   697 				}
       
   698 			break;
       
   699 			}
       
   700 		case EWPParameterAuthName:
       
   701 			{
       
   702 			if ( !iUserName )
       
   703 				{
       
   704 				iUserName = &aParameter;
       
   705 				}
       
   706 			break;
       
   707 			}
       
   708 		case EWPParameterAuthSecret:
       
   709 			{
       
   710 			if ( !iPassword )
       
   711 				{
       
   712 				iPassword = &aParameter;
       
   713 				}
       
   714 			break;
       
   715 			}
       
   716 		case EWPParameterAuthType:
       
   717 			{
       
   718 			// If already received don't accept
       
   719 			if (IsReceived(EWPParameterAuthentication_id))
       
   720 				{
       
   721 				break;
       
   722 				}
       
   723 
       
   724 			if ( value == KCHAP || value == KMD5 )
       
   725 				{
       
   726 				iSecureAuthentication = ETrue;
       
   727 				MarkReceived( EWPParameterAuthentication_id );
       
   728 				}
       
   729 			else if ( value == KPAP )
       
   730 				{
       
   731 				iSecureAuthentication = EFalse;
       
   732 				MarkReceived( EWPParameterAuthentication_id );
       
   733 				}
       
   734 			else
       
   735 				{
       
   736 				// Not supported...
       
   737 				}
       
   738 			break;
       
   739 			}
       
   740 		case EWPParameterLocalAddr: // iPhoneIPAddress
       
   741 			{
       
   742 			if ( !iPhoneIPAddress )
       
   743 				{
       
   744 				iPhoneIPAddress = &aParameter;
       
   745 				}
       
   746 			break;
       
   747 			}
       
   748 		case EWPParameterDNSAddr:
       
   749 			{
       
   750             // All name servers must be stored, as some of them might
       
   751             // be IPv6 and some IPv4
       
   752             User::LeaveIfError( iNameServers.Append( &aParameter ) );
       
   753 			break;
       
   754 			}
       
   755         case EWPParameterIfNetworks:
       
   756             {
       
   757             if( !iIfNetworks )
       
   758                 {
       
   759                 iIfNetworks = &aParameter;
       
   760                 MarkReceived( EWPParameterIfNetworks_id );
       
   761                 }
       
   762             break;
       
   763             }
       
   764         case EWPParameterInternet:
       
   765             {
       
   766             MarkReceived( EWPParameterInternet_id );
       
   767             break;
       
   768             }
       
   769 //JMan for WLan
       
   770         case EWPParameterNapID:
       
   771             {
       
   772             if ( !iNapID )
       
   773                 {
       
   774                 iNapID = &aParameter;
       
   775                 }
       
   776             break;
       
   777             }    
       
   778         // Here case 0 are handled the WLAN parameters that are extensions  
       
   779         // to OMA Client Provisioning parameter set.
       
   780         case 0:
       
   781             {
       
   782         if( iWlanSupported )
       
   783         	{
       
   784         	HandleWLanParametersL( aParameter );
       
   785         	}
       
   786         break;
       
   787             }
       
   788 //JMan for WLan ends
       
   789 		default:
       
   790 			{
       
   791 			}
       
   792 		}
       
   793 	}
       
   794 
       
   795 // -----------------------------------------------------------------------------
       
   796 // CWPAPNapdef::HandleWLanParametersL
       
   797 // -----------------------------------------------------------------------------
       
   798 //
       
   799 void CWPAPNapdef::HandleWLanParametersL( CWPParameter& aParameter )
       
   800 	{
       
   801 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL" ) );
       
   802 	
       
   803 	if( !iWlanSupported )
       
   804 		{
       
   805 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WLAN not supported." ) );
       
   806 		User::Leave( KErrNotSupported );
       
   807 		}
       
   808 	
       
   809 	SECssID* scssid = NULL;
       
   810 	if( iSecSSID.Count() )
       
   811 	{
       
   812 		scssid = iSecSSID[iSecSSID.Count()-1];
       
   813 	}
       
   814 	
       
   815 	TPtrC value( aParameter.Value() );
       
   816     if( ( aParameter.Name().Compare( PRISSID ) ) == 0 )
       
   817         {
       
   818         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriSSID" ) );
       
   819         if ( !iPriSSID )
       
   820             {
       
   821             iPriSSID = &aParameter;
       
   822             }
       
   823         }
       
   824     else if( ( aParameter.Name().Compare( PRIUSSID ) ) == 0 )
       
   825         {
       
   826         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriUSSID" ) );
       
   827         if ( !iPriUSSID )
       
   828             {
       
   829             iPriUSSID = &aParameter;
       
   830             }
       
   831         }// else if
       
   832 
       
   833     else if( ( aParameter.Name().Compare( PRIHSSID ) ) == 0 )
       
   834         {
       
   835         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
       
   836         if ( !iPriHSSID )
       
   837             {
       
   838             iPriHSSID = &aParameter;
       
   839             }
       
   840         }// else if
       
   841         
       
   842     else if( ( aParameter.Name().Compare( SSSID ) ) == 0 )
       
   843         {
       
   844         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
       
   845         if(scssid!=NULL)
       
   846         	{
       
   847         	scssid->iSSSID = &aParameter;
       
   848         	}
       
   849 			  
       
   850 
       
   851         }// else if
       
   852 
       
   853     else if( ( aParameter.Name().Compare( SUSSID ) ) == 0 )
       
   854         {
       
   855         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
       
   856 			  if(scssid!=NULL)
       
   857         	{
       
   858         	scssid->iSUSSID = &aParameter;
       
   859         	}
       
   860         }// else if
       
   861                         
       
   862     else if( ( aParameter.Name().Compare( NETMODE ) ) == 0 )
       
   863         {
       
   864         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode" ) );
       
   865         if ( value == KADHOC )
       
   866 			{
       
   867 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode adhoc" ) );
       
   868 			iNetMode = CMManager::EAdhoc;
       
   869 			}
       
   870         else // default is INFRA
       
   871             {
       
   872             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode infra" ) );
       
   873             iNetMode =CMManager::EInfra;
       
   874             }
       
   875         }
       
   876 
       
   877     else if( ( aParameter.Name().Compare( SECMODE ) ) == 0 )
       
   878         {
       
   879         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode" ) );
       
   880         if ( value == KWEPSEC )
       
   881 			{
       
   882 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWEPSEC" ) );
       
   883 			iSecMode = CMManager::EWlanSecModeWep;
       
   884 			}
       
   885         else if( value == K8021XSEC )
       
   886             {
       
   887             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode K8021XSEC" ) );
       
   888 			iSecMode = CMManager::EWlanSecMode802_1x;
       
   889             }
       
   890         else if( value == KWPASEC )
       
   891             {
       
   892             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPASEC" ) );
       
   893 
       
   894 			iSecMode = CMManager::EWlanSecModeWpa;
       
   895             }
       
   896         else if( value == KWPA2SEC )
       
   897             {
       
   898             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2SEC" ) );
       
   899 			iSecMode = CMManager::EWlanSecModeWpa2;
       
   900             }
       
   901         else if( value == KWPAPRESSEC )
       
   902             {
       
   903             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPAPRESSEC" ) );
       
   904 			iSecMode = CMManager::EWlanSecModeWpa;
       
   905             }
       
   906         else if( value == KWPA2PRESSEC )
       
   907             {
       
   908             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2PRESSEC" ) );
       
   909 			iSecMode = CMManager::EWlanSecModeWpa2;
       
   910             }          
       
   911         else
       
   912             {
       
   913             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode open" ) );
       
   914 			iSecMode = CMManager::EWlanSecModeOpen;
       
   915             }
       
   916         }
       
   917 
       
   918     else if( ( aParameter.Name().Compare( WPAPRESKEYASC ) ) == 0 )
       
   919         {
       
   920         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WPAPRESKEYASC" ) );
       
   921         if ( !iWpaPresKeyAsc )
       
   922             {
       
   923             iWpaPresKeyAsc = &aParameter;
       
   924             }
       
   925         }// else if
       
   926         // indicates the default wepkey index
       
   927     else if( ( aParameter.Name().Compare( DEFAULTWEPIND ) ) == 0 )
       
   928         {
       
   929         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepind" ) );
       
   930 
       
   931         TLex lex( value );
       
   932         lex.Val( iDefaultWepKeyIndex );
       
   933         if ( iDefaultWepKeyIndex >= 4 )
       
   934             {
       
   935             iDefaultWepKeyIndex = 0;
       
   936             }
       
   937         }// else if
       
   938         
       
   939     else if( ( aParameter.Name().Compare( WEPAUTHMODE ) ) == 0 )
       
   940         {
       
   941         if ( value == KWEPAUTHMODEOPEN )
       
   942 			{
       
   943 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode OPEN" ) );
       
   944 			iAuthentication = EAuthOpen;
       
   945 			}
       
   946 		else if ( value == KWEPAUTHMODESHARED )
       
   947 		    {
       
   948 		    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode SHARED" ) );
       
   949 			iAuthentication = EAuthShared;
       
   950 		    }
       
   951         }// else if
       
   952         
       
   953     else if( ( aParameter.Name().Compare( WEPKEYLENGTH ) ) == 0 )
       
   954         {
       
   955         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYLENGTH" ) );
       
   956         if ( !iWepKeyLength )
       
   957             {
       
   958             iWepKeyLength = &aParameter;
       
   959             }
       
   960         }// else if
       
   961     else if( ( aParameter.Name().Compare( WEPKEYINDEX ) ) == 0 )
       
   962         {
       
   963         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYINDEX" ) );
       
   964         TLex lex( value );
       
   965         lex.Val( iWepInd );
       
   966         }// else if 
       
   967     else if( ( aParameter.Name().Compare( WEPKEYDATA ) ) == 0 )
       
   968         {
       
   969         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYDATA" ) );
       
   970 
       
   971         if ( iWepInd <  4 )
       
   972             {
       
   973             const TUint8 K40Bits = 5;
       
   974             const TUint8 K104Bits = 13;
       
   975             const TUint8 K232Bits = 29;
       
   976 
       
   977             TBuf8<KMaxLengthOfKeyData> buf8;
       
   978             StrCopy( buf8, aParameter.Value() );
       
   979             
       
   980             if(buf8.Length() == K232Bits ||
       
   981                 buf8.Length() == K104Bits ||
       
   982                 buf8.Length() == K40Bits  )
       
   983                 {
       
   984                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL ASCI Wep Key" ) );
       
   985                 HBufC8* buf8Conv = HBufC8::NewLC( KMaxLengthOfKeyData );
       
   986                 ConvertAsciiToHex( buf8, buf8Conv );
       
   987                 iKeyData[iWepInd] = *buf8Conv;
       
   988                 iKeyFormat[iWepInd] = CWPAPNapdef::EAscii;
       
   989                 CleanupStack::PopAndDestroy( buf8Conv );
       
   990                 }
       
   991             else if( buf8.Length()==K232Bits*2 ||
       
   992                 buf8.Length()== K104Bits*2 ||
       
   993                 buf8.Length() == K40Bits*2)
       
   994                 {
       
   995                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL HEX Wep Key" ) );
       
   996                 iKeyData[iWepInd] = buf8;
       
   997                 iKeyFormat[iWepInd] = CWPAPNapdef::EHexadecimal;
       
   998                 }
       
   999             }
       
  1000         
       
  1001         }// else if	
       
  1002     
       
  1003     // Handle EAP parameter
       
  1004     HandleEAPParametersCCL( aParameter );        
       
  1005     
       
  1006     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL done" ) );
       
  1007 	}
       
  1008 
       
  1009 // -----------------------------------------------------------------------------
       
  1010 // CWPAPNapdef::HandleEAPParametersL
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 void CWPAPNapdef::HandleEAPParametersCCL( CWPParameter& aParameter )
       
  1014     {
       
  1015 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL" ) );
       
  1016    	
       
  1017    	CEapTypeElement* eap = NULL;
       
  1018    	if ( iEapTypeArray.Count() )
       
  1019    	    {
       
  1020    	    eap = iEapTypeArray[iEapTypeArray.Count()-1];
       
  1021    	    }
       
  1022    	if(!eap)
       
  1023    	    {
       
  1024    	    return;
       
  1025    	    }    
       
  1026    	
       
  1027 	TPtrC value( aParameter.Value() );
       
  1028 	
       
  1029     if( ( aParameter.Name().Compare( EAPTYPE ) ) == 0 )
       
  1030         {
       
  1031         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTYPE" ) );
       
  1032               
       
  1033         ConvertEAPStringToIds( value, eap->iEapTypeString, eap->iEAPSettings->iEAPExpandedType );
       
  1034         
       
  1035         }
       
  1036     else if( ( aParameter.Name().Compare( EAPUSERNAME ) ) == 0 )
       
  1037         {
       
  1038         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSERNAME" ) );
       
  1039         if ( eap->iEAPSettings->iUsername.Length() == 0 )
       
  1040             {
       
  1041             eap->iEAPSettings->iUsername = value;
       
  1042             eap->iEAPSettings->iUsernamePresent = ETrue;
       
  1043             eap->iEAPSettings->iUseAutomaticUsernamePresent = ETrue;
       
  1044             eap->iEAPSettings->iUseAutomaticUsername = EFalse;
       
  1045             }
       
  1046         }// else if 
       
  1047     else if( ( aParameter.Name().Compare( EAPPASSWORD ) ) == 0 )
       
  1048         {
       
  1049         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPASSWORD" ) );
       
  1050         if ( eap->iEAPSettings->iPassword.Length() == 0 )
       
  1051             {
       
  1052             eap->iEAPSettings->iPassword = value;
       
  1053             eap->iEAPSettings->iPasswordPresent = ETrue;
       
  1054             eap->iEAPSettings-> iShowPassWordPromptPresent = ETrue;
       
  1055             eap->iEAPSettings-> iShowPassWordPrompt = EFalse;
       
  1056             }
       
  1057         }// else if 
       
  1058     else if( ( aParameter.Name().Compare( EAPREALM ) ) == 0 )
       
  1059         {
       
  1060         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPREALM" ) );
       
  1061 
       
  1062         if ( eap->iEAPSettings->iRealm.Length() == 0 )
       
  1063             {
       
  1064             eap->iEAPSettings->iRealm = value;
       
  1065             eap->iEAPSettings->iRealmPresent = ETrue;
       
  1066             eap->iEAPSettings->iUseAutomaticRealmPresent = ETrue;
       
  1067             eap->iEAPSettings->iUseAutomaticRealm = EFalse;
       
  1068             }
       
  1069         }// else if 
       
  1070     else if( ( aParameter.Name().Compare( EAPUSEPSEUD ) ) == 0 )
       
  1071         {
       
  1072         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSEPSEUD" ) );
       
  1073         TInt pseudonyms;
       
  1074         TLex lex( value );
       
  1075         lex.Val( pseudonyms );
       
  1076         
       
  1077         eap->iEAPSettings->iUsePseudonymsPresent = ETrue;
       
  1078         if ( pseudonyms == 1 )
       
  1079             {        
       
  1080             eap->iEAPSettings->iUsePseudonyms = ETrue;
       
  1081             }
       
  1082         else
       
  1083             {
       
  1084             eap->iEAPSettings->iUsePseudonyms = EFalse;            
       
  1085             }
       
  1086         }// else if 
       
  1087     else if( ( aParameter.Name().Compare( EAPMAXAUTHS ) ) == 0 )
       
  1088         {
       
  1089         // not supported
       
  1090         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPMAXAUTHS" ) );
       
  1091         }// else if 
       
  1092     else if( ( aParameter.Name().Compare( EAPENCAPS ) ) == 0 )
       
  1093         {
       
  1094         
       
  1095         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPENCAPS" ) );
       
  1096         
       
  1097         TEapExpandedType dummy; 
       
  1098         ConvertEAPStringToIds( value, eap->iEncapsulatingExpandedEapId, dummy );
       
  1099                      
       
  1100         }// else if    
       
  1101     else if( ( aParameter.Name().Compare( EAPVERSERREALM ) ) == 0 )
       
  1102         {
       
  1103         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPVERSERREALM" ) );
       
  1104         
       
  1105         TInt serverRealm;
       
  1106         TLex lex( value );
       
  1107         lex.Val( serverRealm );
       
  1108         
       
  1109         eap->iEAPSettings->iVerifyServerRealmPresent = ETrue;
       
  1110         
       
  1111         if ( serverRealm == 1 )
       
  1112             {        
       
  1113             eap->iEAPSettings->iVerifyServerRealm = ETrue;
       
  1114             }
       
  1115         else
       
  1116             {
       
  1117             eap->iEAPSettings->iVerifyServerRealm = EFalse;            
       
  1118             }
       
  1119         }// else if    
       
  1120     else if( ( aParameter.Name().Compare( EAPCLIENTHAUTH ) ) == 0 )
       
  1121         {
       
  1122         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCLIENTHAUTH" ) );
       
  1123         
       
  1124         TInt clientAuthentication;
       
  1125         TLex lex( value );
       
  1126         lex.Val( clientAuthentication );
       
  1127         
       
  1128         eap->iEAPSettings->iRequireClientAuthenticationPresent = ETrue;
       
  1129         
       
  1130         if ( clientAuthentication == 1 )
       
  1131             {        
       
  1132             eap->iEAPSettings->iRequireClientAuthentication = ETrue;
       
  1133             }
       
  1134         else
       
  1135             {
       
  1136             eap->iEAPSettings->iRequireClientAuthentication = EFalse;            
       
  1137             }
       
  1138         }// else if    
       
  1139     else if( ( aParameter.Name().Compare( EAPSESVALTIME ) ) == 0 )
       
  1140         {
       
  1141         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSESVALTIME" ) );
       
  1142         
       
  1143         TInt sessionValidityTime;
       
  1144         TLex lex( value );
       
  1145         lex.Val( sessionValidityTime );
       
  1146         eap->iEAPSettings->iSessionValidityTime = sessionValidityTime;
       
  1147         eap->iEAPSettings->iSessionValidityTimePresent = ETrue;
       
  1148 
       
  1149         }// else if    
       
  1150     else if( ( aParameter.Name().Compare( EAPCIPSUIT ) ) == 0 )
       
  1151         {
       
  1152         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCIPSUIT" ) );
       
  1153         
       
  1154         TInt cipherSuites;
       
  1155         TLex lex( value );
       
  1156         lex.Val( cipherSuites );
       
  1157         eap->iEAPSettings->iCipherSuites.Append( cipherSuites );
       
  1158         eap->iEAPSettings->iCipherSuitesPresent = ETrue;
       
  1159         
       
  1160         }// else if
       
  1161     else if( ( aParameter.Name().Compare( EAPPEAPV0 ) ) == 0 )
       
  1162         {
       
  1163         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV0" ) );
       
  1164         
       
  1165         TInt peap;
       
  1166         TLex lex( value );
       
  1167         lex.Val( peap );
       
  1168         
       
  1169         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1170         if ( peap == 1 )
       
  1171             {        
       
  1172             eap->iEAPSettings->iPEAPv0Allowed = ETrue;
       
  1173             }
       
  1174         else
       
  1175             {
       
  1176             eap->iEAPSettings->iPEAPv0Allowed = EFalse;            
       
  1177             }
       
  1178         }// else if     
       
  1179     else if( ( aParameter.Name().Compare( EAPPEAPV1 ) ) == 0 )
       
  1180         {
       
  1181         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV1" ) );
       
  1182         TInt peap;
       
  1183         TLex lex( value );
       
  1184         lex.Val( peap );
       
  1185         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1186         if ( peap == 1 )
       
  1187             {        
       
  1188             eap->iEAPSettings->iPEAPv1Allowed = ETrue;
       
  1189             }
       
  1190         else
       
  1191             {
       
  1192             eap->iEAPSettings->iPEAPv1Allowed = EFalse;            
       
  1193             }
       
  1194         }// else if
       
  1195     else if( ( aParameter.Name().Compare( EAPPEAPV2 ) ) == 0 )
       
  1196         {
       
  1197         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV2" ) );
       
  1198         TInt peap;
       
  1199         TLex lex( value );
       
  1200         lex.Val( peap );
       
  1201         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1202         if ( peap == 1 )
       
  1203             {        
       
  1204             eap->iEAPSettings->iPEAPv2Allowed = ETrue;
       
  1205             }
       
  1206         else
       
  1207             {
       
  1208             eap->iEAPSettings->iPEAPv2Allowed = EFalse;            
       
  1209             }
       
  1210         }// else if  
       
  1211         
       
  1212     else if( ( aParameter.Name().Compare( EAPISSNAME ) ) == 0 )
       
  1213         {
       
  1214         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPISSNAME" ) );
       
  1215         
       
  1216         eap->iCertificate->SetSubjectName(value);
       
  1217         eap->iCertificate->SetSubjectNamePresent();
       
  1218         }// else if        
       
  1219         
       
  1220     else if( ( aParameter.Name().Compare( EAPSUBNAME ) ) == 0 )
       
  1221         {
       
  1222         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBNAME" ) );
       
  1223         
       
  1224         eap->iCertificate->SetIssuerName(value);
       
  1225         eap->iCertificate->SetIssuerNamePresent();       
       
  1226         }// else if        
       
  1227         
       
  1228     else if( ( aParameter.Name().Compare( EAPCERTTYPE ) ) == 0 )
       
  1229         {
       
  1230         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCERTTYPE" ) );
       
  1231         if ( value == EAPCERTCA )
       
  1232 			{
       
  1233 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EEapSim" ) );
       
  1234             
       
  1235             eap->iCertificate->SetCertType(EapCertificateEntry::ECA);
       
  1236             eap->iEAPSettings-> iUseAutomaticCACertificatePresent = ETrue;
       
  1237             eap->iEAPSettings-> iUseAutomaticCACertificate = EFalse;
       
  1238 			}
       
  1239 		else
       
  1240 		    {
       
  1241 		    eap->iCertificate->SetCertType(EapCertificateEntry::EUser);
       
  1242 		    }
       
  1243 		// Certificates must be present since this field was added
       
  1244 		eap->iEAPSettings->iCertificatesPresent = ETrue;
       
  1245 		eap->iCertificate->SetIsEnabledPresent();
       
  1246 		eap->iCertificate->SetIsEnabled(ETrue) ;
       
  1247         
       
  1248         }// else if        
       
  1249     else if( ( aParameter.Name().Compare( EAPSERNUM ) ) == 0 )
       
  1250         {
       
  1251         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSERNUM" ) );
       
  1252         
       
  1253         eap->iCertificate->SetSerialNumber(value);
       
  1254         eap->iCertificate->SetSerialNumberPresent();
       
  1255         }// else if
       
  1256         
       
  1257     else if( ( aParameter.Name().Compare( EAPSUBKEYID ) ) == 0 )
       
  1258         {
       
  1259         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBKEYID" ) );
       
  1260            
       
  1261         _LIT(KHexIdLC, "0x");
       
  1262        	_LIT(KHexIdUC, "0X");
       
  1263        	TBuf<2> HexIdBuf;
       
  1264        	TInt keyLen = aParameter.Value().Length();
       
  1265        	
       
  1266        	// setting the given key to the key buffer
       
  1267        	TBuf<KMaxSubKeyLenght> origKey;
       
  1268        	origKey.SetLength(keyLen);
       
  1269        	origKey = aParameter.Value();
       
  1270        	TBuf<KMaxSubKeyLenght> key;
       
  1271        	TLex tmpByte;
       
  1272        	TInt err(KErrNone);
       
  1273        	TUint16 byte;
       
  1274        	
       
  1275        	// Remove possible spaces from the beginning
       
  1276        	origKey.TrimLeft();
       
  1277        	
       
  1278        	// if the key is over two chars long, then we have to check
       
  1279        	// whether there is 0x or 0X in the beginning
       
  1280        	if (origKey.Length() >= 2)
       
  1281             {
       
  1282         	// Copy the two left most characters in to the buffer
       
  1283         	HexIdBuf.Copy(origKey.Left(2));
       
  1284         	
       
  1285         	// If the first characters are 0x or 0X, then they should be ignored
       
  1286         	if (HexIdBuf.Compare(KHexIdLC) == 0
       
  1287         			|| HexIdBuf.Compare(KHexIdUC) == 0)
       
  1288         		{
       
  1289         		// delete two characters
       
  1290         		origKey.Delete(0, 2);
       
  1291         		}
       
  1292             }
       
  1293         
       
  1294        	// looping the subject key through, removing whitespaces
       
  1295        	for (TInt i = 0; i < keyLen; i++)
       
  1296        		{
       
  1297        		// removing white spaces from the left side of the key
       
  1298        		origKey.TrimLeft();
       
  1299        		// check that there are characters left
       
  1300        		if (origKey.Length() >= 2)
       
  1301        			{
       
  1302        			// pick the two left most bytes from the key
       
  1303        			tmpByte = origKey.Left(2);
       
  1304        			// convert byte into binary format
       
  1305        			err = tmpByte.Val(byte, EHex);
       
  1306        			
       
  1307        			// delete two characters from the left side of the character array in the buffer
       
  1308        			origKey.Delete(0, 2);
       
  1309        			
       
  1310        			// check whether conversion to decimal went ok
       
  1311        			if (err != KErrNone)
       
  1312        				{
       
  1313        				// if there are problems, then leave the loop
       
  1314        				break;
       
  1315        				}
       
  1316        			
       
  1317        			// store the appended byte into the key variable
       
  1318        			key.Append(byte);
       
  1319        			}
       
  1320        			
       
  1321        		else if (origKey.Length() == 1)
       
  1322        			{
       
  1323        			// pick the left most bytes from the key
       
  1324        			tmpByte = origKey.Left(1);
       
  1325        			// convert byte into binary format
       
  1326        			err = tmpByte.Val(byte, EHex);
       
  1327        			
       
  1328        			// delete two characters from the left side of the character array in the buffer
       
  1329        			origKey.Delete(0, 1);
       
  1330        			
       
  1331        			// check whether conversion to decimal went ok
       
  1332        			if (err != KErrNone)
       
  1333        				{
       
  1334        				// if there are problems, then leave the loop
       
  1335        				break;
       
  1336        				}
       
  1337        			
       
  1338        			// store the appended byte into the key variable
       
  1339        			key.Append(byte);
       
  1340        			}
       
  1341        		else
       
  1342        			{
       
  1343        			break;
       
  1344        			}
       
  1345        		}
       
  1346        	TBuf8<KMaxSubKeyLenght> keyIdentifier;
       
  1347        	keyIdentifier.Copy(key);
       
  1348        	// store key value only if no errors occurred
       
  1349        	if (err == KErrNone) 
       
  1350        		{
       
  1351        		eap->iCertificate->SetSubjectKeyId(keyIdentifier);
       
  1352        		eap->iCertificate->SetSubjectKeyIdPresent();
       
  1353        		eap->iEAPSettings->iCertificatesPresent = ETrue; 
       
  1354        		}
       
  1355        	}
       
  1356        	
       
  1357         
       
  1358     else if( ( aParameter.Name().Compare( EAPTHUMBPRINT ) ) == 0 )
       
  1359         {
       
  1360         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTHUMBPRINT" ) );
       
  1361         eap->iCertificate->SetThumbprintPresent();
       
  1362         eap->iCertificate->SetThumbprint(value);
       
  1363         }// else if                  
       
  1364     }
       
  1365 
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // CWPAPNapdef::CWPAPNapdef
       
  1369 // C++ default constructor can NOT contain any code, that
       
  1370 // might leave.
       
  1371 // -----------------------------------------------------------------------------
       
  1372 //
       
  1373 CWPAPNapdef::CWPAPNapdef( TBool aFollowingLink,
       
  1374                           const TDesC& aDefaultName, 
       
  1375                           CWPCharacteristic& aLogicalCharacteristic )
       
  1376                         : CWPAPItemBase( aDefaultName ),
       
  1377                           iCharacteristic( aLogicalCharacteristic ),
       
  1378                           iFollowingLink( aFollowingLink )
       
  1379 	{
       
  1380 	}
       
  1381 
       
  1382 // -----------------------------------------------------------------------------
       
  1383 // CWPAPNapdef::ConstructL
       
  1384 // Symbian 2nd phase constructor can leave.
       
  1385 // -----------------------------------------------------------------------------
       
  1386 //
       
  1387 void CWPAPNapdef::ConstructL()
       
  1388 	{
       
  1389 	iLingerValue = NULL;
       
  1390 	iLingerFlag = ETrue;
       
  1391 	iInternetIndicator = -1;
       
  1392 	//checks if Wlan feature is supported
       
  1393   FeatureManager::InitializeLibL();
       
  1394   iWlanSupported = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
  1395   FeatureManager::UnInitializeLib();
       
  1396 	}
       
  1397 
       
  1398 // -----------------------------------------------------------------------------
       
  1399 // CWPAPNapdef::SaveWlanDataL
       
  1400 // -----------------------------------------------------------------------------
       
  1401 //
       
  1402 void CWPAPNapdef::SaveWlanDataL( TUint32 aIapId, CCommsDatabase& aCommsDb )
       
  1403     {
       
  1404     FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL APid: (%d)"),  aIapId) );
       
  1405     
       
  1406     if ( iBearer == KUidWlanBearerType )
       
  1407 	    {
       
  1408         CCommsDbTableView* wLanServiceTable;
       
  1409         
       
  1410         // CMManager
       
  1411         // Search the Iap Service Id using the received IapId
       
  1412         RCmConnectionMethodExt cm = iCm->ConnectionMethodL( aIapId );
       
  1413         TUint32 serviceId = cm.GetIntAttributeL( CMManager::ECmIapServiceId );
       
  1414      	
       
  1415         // The BeginTransaction might fail if someone else has locked CommsDat
       
  1416         TInt dberr = aCommsDb.BeginTransaction();
       
  1417         if( dberr == KErrLocked )
       
  1418             {
       
  1419             // Try BeginTransaction again to get lock
       
  1420             TInt retry = KBeginTransRetryCount;            
       
  1421             while ( retry > 0 && dberr == KErrLocked )
       
  1422                 {                   
       
  1423                 User::After(KBeginTransRetryDelay);
       
  1424                 dberr = aCommsDb.BeginTransaction();
       
  1425                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: Database locked. BeginTransaction retry." ) );
       
  1426                 retry--;
       
  1427                 }
       
  1428             if(dberr != KErrNone)
       
  1429                 {                            
       
  1430                 // Could not get lock to CommsDat at all
       
  1431                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: BeginTransaction failed completely." ) );
       
  1432                 User::Leave( dberr ); 
       
  1433                 }           
       
  1434             }                             
       
  1435         
       
  1436         TInt indexToSec = 0;
       
  1437         wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( 
       
  1438                         TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), serviceId );
       
  1439         TInt errorCode = wLanServiceTable->GotoFirstRecord();
       
  1440 
       
  1441         if ( errorCode == KErrNone )
       
  1442             {
       
  1443             indexToSec = serviceId;
       
  1444             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL updaterecord" ) );
       
  1445             wLanServiceTable->UpdateRecord();
       
  1446             }
       
  1447         else
       
  1448             {
       
  1449             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL insertrecord" ) );
       
  1450             TUint32 dummyUid( 0 );
       
  1451             User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
       
  1452 
       
  1453             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_SERVICE_ID" ) );
       
  1454             // Save link to LAN service
       
  1455             wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId );
       
  1456             indexToSec = aIapId;
       
  1457             }
       
  1458         
       
  1459         // Setting the security mode manually, because CMManager does not do that
       
  1460         wLanServiceTable->WriteUintL( TPtrC( WLAN_SECURITY_MODE ), iSecMode );
       
  1461 
       
  1462     	if( iSecSSID.Count() )
       
  1463 			{
       
  1464 	        CCommsDbTableView* wLanSecserviceTable;
       
  1465 			wLanSecserviceTable = aCommsDb.OpenTableLC( TPtrC( WLAN_SECONDARY_SSID ) ); 
       
  1466 			//CleanupStack::Pop(wLanSecserviceTable); // wLanSecserviceTable
       
  1467 		 	TBuf<4> blank;
       
  1468 		 	blank.Append(KNullDesC);
       
  1469 		    
       
  1470 		    TBool sssid = EFalse;
       
  1471 	        TBool sussid = EFalse;
       
  1472 
       
  1473 	        for(TInt i = 0; i < iSecSSID.Count(); i++ )
       
  1474 	        	{
       
  1475 	        	TUint32 id ;
       
  1476 	        	
       
  1477 		        
       
  1478 		        TInt retval = wLanSecserviceTable->InsertRecord(id);
       
  1479 		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), indexToSec );
       
  1480 		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_ID), id );
       
  1481 
       
  1482 		 	    if( iSecSSID[i]->iSSSID != NULL)
       
  1483 		 	    sssid = ETrue;
       
  1484 		 	    if(iSecSSID[i]->iSUSSID != NULL)
       
  1485 		 	    sussid = ETrue;
       
  1486 		 	    
       
  1487 		 	    if((sssid && iSecSSID[i]->iSSSID->Value() != blank) || (sussid && iSecSSID[i]->iSUSSID->Value() != blank ))
       
  1488 		 	    {
       
  1489 		 		if( sssid )
       
  1490 		 		wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_SCANNED_SSID), iSecSSID[i]->iSSSID->Value());
       
  1491 			
       
  1492 				if(sussid)
       
  1493 				wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_USED_SSID), iSecSSID[i]->iSUSSID->Value());
       
  1494 		        
       
  1495 		 	    }
       
  1496 		 	    wLanSecserviceTable->PutRecordChanges();
       
  1497 		 	    sssid = EFalse;
       
  1498 	            sussid = EFalse;
       
  1499 	        	}
       
  1500 	        	CleanupStack::PopAndDestroy( wLanSecserviceTable );
       
  1501 			}
       
  1502 			
       
  1503 			iSecSSID.ResetAndDestroy();
       
  1504 			iSecSSID.Close();
       
  1505         if ( iPriSSID )
       
  1506             {
       
  1507             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_SSID" ) );
       
  1508             // Save NU_WLAN_SSID
       
  1509         	wLanServiceTable->WriteTextL( TPtrC(NU_WLAN_SSID), iPriSSID->Value() );
       
  1510             }
       
  1511         if ( iPriUSSID )
       
  1512             {        
       
  1513             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_USED_SSID" ) );
       
  1514             // Save WLAN_USED_SSID	
       
  1515     	      wLanServiceTable->WriteTextL( TPtrC(WLAN_USED_SSID), iPriUSSID->Value() );
       
  1516             }
       
  1517         if ( iPriHSSID )
       
  1518             {        
       
  1519     	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_SCAN_SSID" ) );
       
  1520             // Save WLAN_SCAN_SSID
       
  1521     	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), ETrue );
       
  1522             }
       
  1523         else
       
  1524             {
       
  1525     	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), EFalse );            	
       
  1526             }
       
  1527 
       
  1528        	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX" ) );
       
  1529         // Save index of key in use
       
  1530         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), 
       
  1531                                       (TUint32&) iDefaultWepKeyIndex );
       
  1532         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX: (%d)"),  iDefaultWepKeyIndex) );
       
  1533 
       
  1534         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE" ) );
       
  1535         // Open / Shared (0/1)
       
  1536         // Save index of key in use
       
  1537         wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), 
       
  1538                                      ( TUint32& ) iAuthentication );
       
  1539         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE: (%d)"),  iAuthentication) );
       
  1540         
       
  1541         
       
  1542         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY1" ) );
       
  1543         // Save first WEP key
       
  1544         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), iKeyData[0] );
       
  1545         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), 
       
  1546                                  ( TUint32& ) iKeyFormat[0] );
       
  1547         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[0] ) );
       
  1548         
       
  1549         
       
  1550         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY2" ) );
       
  1551         // Save second WEP key
       
  1552         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), iKeyData[1] );
       
  1553         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), 
       
  1554                                  ( TUint32& ) iKeyFormat[1] );
       
  1555         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[1] ) );
       
  1556             
       
  1557         
       
  1558         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY3" ) );
       
  1559         // Save third WEP key
       
  1560         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), iKeyData[2] );
       
  1561         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), 
       
  1562                                  ( TUint32& ) iKeyFormat[2] );
       
  1563         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[2] ) );
       
  1564             
       
  1565             
       
  1566         
       
  1567         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY4" ) );
       
  1568         // Save fourth WEP key
       
  1569         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), iKeyData[3] );
       
  1570         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), 
       
  1571                                  ( TUint32& ) iKeyFormat[3] );
       
  1572         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[3] ) );
       
  1573             
       
  1574         
       
  1575         if ( iWpaPresKeyAsc )
       
  1576             {     
       
  1577             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL convert WPAKEY to ascii" ) );
       
  1578             // convert unicode to 8-bit ascii
       
  1579             TBuf8<KMaxWpaPskLength> wpaKey;
       
  1580             StrCopy( wpaKey, iWpaPresKeyAsc->Value() );
       
  1581             
       
  1582             // Enable WPA Pre Shared key mode
       
  1583             wLanServiceTable->WriteBoolL( TPtrC( WLAN_ENABLE_WPA_PSK ), ETrue );
       
  1584             
       
  1585             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_PRE_SHARED_KEY" ) );
       
  1586             // Save PreShared Key
       
  1587             wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), 
       
  1588                                          wpaKey );
       
  1589             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_KEY_LENGTH" ) ); 
       
  1590             // Save PreShared Key Length
       
  1591             wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), 
       
  1592                                          wpaKey.Length() );                                         
       
  1593             }
       
  1594 
       
  1595         TBuf<KMaxLengthOfEapList> eapList;
       
  1596         eapList.Copy(KEapAll);
       
  1597 
       
  1598         for (TInt i=0;i<iEapTypeArray.Count();i++)
       
  1599             {
       
  1600             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings" ) );
       
  1601             CEapTypeElement* eap = iEapTypeArray[i];
       
  1602             
       
  1603             if ( eap->iEAPSettings->iCertificatesPresent )
       
  1604             	{
       
  1605             	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL Certificate was present." ) );
       
  1606             	eap->iEAPSettings->iCertificates.Append( eap->iCertificate );	
       
  1607             	}                  
       
  1608 
       
  1609             // Save EAP list
       
  1610             if ( eap->iEapTypeString.Length() > 0  
       
  1611             	 && eap->iEncapsulatingExpandedEapId.Length() == 0) // AND method is not encapsulated
       
  1612                 {
       
  1613                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_EAPS" ) );
       
  1614                 
       
  1615                 TBuf8<3> buf;
       
  1616                 _LIT8(KFormat, "%d");
       
  1617                 // pick the last byte from the array
       
  1618                 buf.Format(KFormat, eap->iEapTypeString[KExpandedEapIdLength - 1]);
       
  1619                 // search for the correct offset for the eap type from the KEapAll literal
       
  1620                 TInt index = KEapAll().Find(buf);
       
  1621                 
       
  1622                 const TUint8 offset = 2; //length = f "-0" string
       
  1623                 // Add '+' to the correct offset, so that the eap is repsesented activated in the list
       
  1624                 if(index >= offset)
       
  1625                     {
       
  1626                     eapList[index-offset] = KEapPlus; 
       
  1627                     }
       
  1628                 
       
  1629                 }
       
  1630             // Set iEncapsulatingEapTypes
       
  1631                  for ( TInt j = 0; j < iEapTypeArray.Count(); j++ )
       
  1632                      {
       
  1633                      // Check if any method has this method as the encapsulating method
       
  1634                      if ( eap->iEapTypeString == iEapTypeArray[j]->iEncapsulatingExpandedEapId )
       
  1635                          {
       
  1636                          // Append this method to iEncapsulatedEAPType
       
  1637                          eap->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Append( iEapTypeArray[j]->iEAPSettings->iEAPExpandedType );
       
  1638                          eap->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue;
       
  1639                          }
       
  1640                      }
       
  1641                  
       
  1642             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings CEapType::NewL" ) );        
       
  1643             CEapType* eapType = NULL;
       
  1644 
       
  1645             
       
  1646             TRAPD( error, ( eapType = CEapType::NewL( ELan, serviceId, eap->iEAPSettings->iEAPExpandedType ) ) );
       
  1647 
       
  1648             if ( ( error == KErrNone ) && eapType )
       
  1649                 {
       
  1650                 CleanupStack::PushL( eapType );
       
  1651                 
       
  1652                 // Check if this type is tunneled
       
  1653                 if ( eap->iEncapsulatingExpandedEapId.Length() > 0 )
       
  1654                 	{
       
  1655                 	// It is tunneled. 
       
  1656                 	eapType->SetTunnelingType( eap->iEncapsulatingExpandedEapId);
       
  1657                 	
       
  1658                 	}
       
  1659                 
       
  1660                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings SetConfigurationL" ) );
       
  1661                 TRAP_IGNORE( eapType->SetConfigurationL( *eap->iEAPSettings ) );
       
  1662                 
       
  1663                 CleanupStack::PopAndDestroy( eapType );
       
  1664                 
       
  1665                 }
       
  1666             else
       
  1667                 {
       
  1668                 FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL CEapType::NewL err: %d"), error ) );
       
  1669                 }
       
  1670 
       
  1671 
       
  1672             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings done" ) );
       
  1673             }
       
  1674             
       
  1675             
       
  1676 	
       
  1677 	  		// Expanded EAP types in use. Write the eap list to the new columns.
       
  1678     		
       
  1679     		// generate appropriate entries in the new enabled and disabled list,
       
  1680     		// overwriting those values 
       
  1681     		
       
  1682     		// count the + and - signs to determine the size of enabled and 
       
  1683     		// disabled descriptors
       
  1684 
       
  1685     		TLex lex( eapList );
       
  1686     		TInt numPlus = 0;
       
  1687     		TInt numMinus = 0;
       
  1688     		TChar ch;
       
  1689     		while ( !lex.Eos() )
       
  1690     		    {
       
  1691     		    ch = lex.Get();
       
  1692     		    if ( ch == '+' ) ++numPlus;
       
  1693     		    else if ( ch == '-' ) ++numMinus;
       
  1694     		    }
       
  1695     		// load general EAP settings If
       
  1696     		CEapGeneralSettings* genSettings;
       
  1697     		genSettings = CEapGeneralSettings::NewL(ELan, serviceId);
       
  1698     		CleanupStack::PushL( genSettings );
       
  1699 
       
  1700     		// get lists of enabled/disabled EAPs for the IAP
       
  1701     		
       
  1702     		RArray<TEapExpandedType> enabledEapMethods;
       
  1703     		RArray<TEapExpandedType> disabledEapMethods;
       
  1704 
       
  1705     		enabledEapMethods.Reset();
       
  1706     		disabledEapMethods.Reset();
       
  1707    		
       
  1708     		
       
  1709     		// each entry consumes 8 bytes in binary format
       
  1710     		HBufC8* enabledEAPPlugin = HBufC8::NewL( 8 * numPlus );
       
  1711     		CleanupStack::PushL( enabledEAPPlugin );
       
  1712     		
       
  1713     		HBufC8* disabledEAPPlugin = HBufC8::NewL( 8 * numMinus );
       
  1714     		CleanupStack::PushL( disabledEAPPlugin );
       
  1715     		    
       
  1716     		lex.Assign( eapList );
       
  1717     		
       
  1718     		while ( !lex.Eos() )
       
  1719     		    {
       
  1720     		    // beginning of implementation UID
       
  1721     		    TInt16 implUid = 0;
       
  1722     		    
       
  1723     		    if ( lex.Val( implUid ) != KErrNone || !implUid )
       
  1724     		        {
       
  1725     		        // if the old string is corrupted, null out both lists
       
  1726     		        enabledEAPPlugin->Des().Zero();
       
  1727     		        disabledEAPPlugin->Des().Zero();
       
  1728     		        break;
       
  1729     		        }
       
  1730     		
       
  1731     		    // append it to the appropriate list ('+' enabled, '-' disabled)
       
  1732     		    _LIT8( KPadding, "\xFE\0\0\0\0\0\0" );
       
  1733     		    _LIT8( KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
       
  1734     		    const TInt KPlainMsChapV2ImplUid = 99;
       
  1735     		    
       
  1736     		    if ( implUid > 0 )
       
  1737     		        {
       
  1738     		        enabledEAPPlugin->Des().Append( 
       
  1739     		                            Abs( implUid ) == KPlainMsChapV2ImplUid? 
       
  1740     		                                        KMsChapV2Padding: KPadding );
       
  1741     		        enabledEAPPlugin->Des().Append( Abs( implUid ) );
       
  1742     		        TPtrC8 data(reinterpret_cast<TUint8*>(&implUid), KExpandedEapIdLength);
       
  1743     		        TEapExpandedType expandedType;
       
  1744 					      expandedType.SetValue(enabledEAPPlugin,KEapExpandedTypeLength);
       
  1745 					      enabledEapMethods.Append(expandedType);
       
  1746 					      }
       
  1747 	    
       
  1748     		    // swallow the delimiter (',')
       
  1749     		    lex.Get();
       
  1750     		    }
       
  1751     
       
  1752     		genSettings->SetEapMethods(enabledEapMethods, disabledEapMethods);  
       
  1753     		            
       
  1754                 	
       
  1755 	
       
  1756     		CleanupStack::PopAndDestroy( disabledEAPPlugin );
       
  1757     		CleanupStack::PopAndDestroy( enabledEAPPlugin );
       
  1758     		CleanupStack::PopAndDestroy( genSettings );
       
  1759     		
       
  1760     
       
  1761      
       
  1762             
       
  1763        iEapTypeArray.ResetAndDestroy();
       
  1764        wLanServiceTable->PutRecordChanges();
       
  1765   
       
  1766 
       
  1767         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL PutRecordChanges" ) ); 
       
  1768         CleanupStack::PopAndDestroy( wLanServiceTable );
       
  1769         
       
  1770         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL done" ) );
       
  1771 	    aCommsDb.CommitTransaction();
       
  1772 	    }
       
  1773 	else
       
  1774 	    {
       
  1775 	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL ignored not a WLAN AP" ) );
       
  1776 	    }
       
  1777 	    
       
  1778     }
       
  1779 
       
  1780 //------------------------------------------------------------------------------
       
  1781 // CWPAPNapdef::ConvertAsciiToHex
       
  1782 //------------------------------------------------------------------------------
       
  1783 //
       
  1784 void CWPAPNapdef::ConvertAsciiToHex( const TDesC8& aSource, HBufC8*& aDest )
       
  1785 	{
       
  1786 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex" ) );
       
  1787 	
       
  1788 	_LIT( hex, "0123456789ABCDEF" );
       
  1789 	TInt size = aSource.Size();
       
  1790 	TPtr8 ptr = aDest->Des();
       
  1791 	for ( TInt ii = 0; ii < size; ii++ )
       
  1792 		{
       
  1793 		TText8 ch = aSource[ii];
       
  1794 		ptr.Append( hex()[(ch/16)&0x0f] );
       
  1795 		ptr.Append( hex()[ch&0x0f] );
       
  1796 		}
       
  1797     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex Done" ) );
       
  1798 	}
       
  1799 
       
  1800 // -----------------------------------------------------------------------------
       
  1801 // CWPAPNapdef::StrCopy
       
  1802 // String copy with lenght check.
       
  1803 // -----------------------------------------------------------------------------
       
  1804 //
       
  1805 void CWPAPNapdef::StrCopy( TDes8& aTarget, const TDesC& aSource )
       
  1806     {
       
  1807     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy" ) );
       
  1808     
       
  1809 	TInt len = aTarget.MaxLength();
       
  1810     if( len < aSource.Length() ) 
       
  1811 	    {
       
  1812 		aTarget.Copy( aSource.Left( len ) );
       
  1813 		return;
       
  1814 	    }
       
  1815 	aTarget.Copy( aSource );
       
  1816 	
       
  1817 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy Done" ) );
       
  1818     }
       
  1819 
       
  1820 CEapTypeElement::~CEapTypeElement()
       
  1821     {
       
  1822     delete iEAPSettings;
       
  1823     delete iCertificate;
       
  1824     }
       
  1825 
       
  1826 // -----------------------------------------------------------------------------
       
  1827 // CWPAPNapdef::UpdateLingerL
       
  1828 // 
       
  1829 // -----------------------------------------------------------------------------
       
  1830 //
       
  1831 void CWPAPNapdef::UpdateLingerL(const TUint32 aIapId)
       
  1832 {
       
  1833 		if ( iLinger && ( !iLingerFlag ) )
       
  1834 		{
       
  1835     	AddLingerL( aIapId , iLingerValue );
       
  1836 		}
       
  1837 		
       
  1838 }
       
  1839 
       
  1840 // -----------------------------------------------------------------------------
       
  1841 // CWPAPNapdef::UdateligerValueL
       
  1842 // 
       
  1843 // -----------------------------------------------------------------------------
       
  1844 //
       
  1845 void CWPAPNapdef::UdateligerValueL(CWPParameter* aLinger)
       
  1846 {
       
  1847 		TInt err(KErrNone);
       
  1848 		const TDesC& value = aLinger->Value();
       
  1849 		if( !Notalpha(value))
       
  1850 		{
       
  1851 		TLex lex( value );
       
  1852 		TUint Linger = 0;
       
  1853 		TInt lingerint;
       
  1854 		err = lex.Val( Linger, EDecimal );
       
  1855 		if( err == KErrNone )
       
  1856 		{
       
  1857 		    lingerint = Linger;
       
  1858 			if( lingerint >= 0 )
       
  1859 		    {
       
  1860 		    	iLingerValue = lingerint;
       
  1861 		    	iLingerFlag = EFalse;
       
  1862 		    }
       
  1863 		}
       
  1864 		}
       
  1865 }
       
  1866 
       
  1867 // -----------------------------------------------------------------------------
       
  1868 // CWPAPNapdef::UdateligerValueL
       
  1869 // 
       
  1870 // -----------------------------------------------------------------------------
       
  1871 //
       
  1872 TBool CWPAPNapdef::Notalpha(const TDesC& aValue)
       
  1873 {
       
  1874 	TBool NotAlpha = EFalse;
       
  1875 	TChar character;
       
  1876 	for(TInt i = 0 ; i < aValue.Length(); i++)
       
  1877 	{
       
  1878 		character = aValue[i];
       
  1879 		NotAlpha = character.IsAlpha();
       
  1880 		if(NotAlpha)
       
  1881 		break;
       
  1882 	}
       
  1883 	
       
  1884 	return NotAlpha;
       
  1885 }
       
  1886 
       
  1887 
       
  1888 // ---------------------------------------------------------------------------
       
  1889 // Adds iapID and linger interval to CentralRepository
       
  1890 // ---------------------------------------------------------------------------
       
  1891 //
       
  1892 void CWPAPNapdef::AddLingerL( const TInt aIapId, const TInt aLingerInterval )
       
  1893     {
       
  1894     TInt    err( KErrNone );
       
  1895     
       
  1896     // Open repository
       
  1897     CRepository* repository = CRepository::NewLC( KCRUidPDPContextManager );
       
  1898     
       
  1899     // Find if an entry for "iapId" already exists in CentRep 
       
  1900     RArray< TUint32 > foundKeys;
       
  1901     foundKeys.Reset();
       
  1902     
       
  1903     err = repository->FindEqL( KIapColumn,       // partial key
       
  1904                                KColumnMask,      // key mask
       
  1905                                aIapId,           // value
       
  1906                                foundKeys );      // found keys
       
  1907     
       
  1908     if ( err == KErrNone || err == KErrNotFound )
       
  1909         {
       
  1910         if ( foundKeys.Count() == 0 )
       
  1911             {
       
  1912             // Add a new entry
       
  1913             TInt arrayCount( 0 );
       
  1914             
       
  1915             // Get number of iapId&linger entries in Centrep
       
  1916             err = repository->Get( KPdpContextManagerLingerArrayCount, 
       
  1917                                    arrayCount );
       
  1918         
       
  1919             if ( err == KErrNone )
       
  1920                 {
       
  1921                 arrayCount++;
       
  1922                 
       
  1923                 err = repository->Create( ( KIapColumn | arrayCount ), aIapId ); 
       
  1924                 
       
  1925                 if ( err == KErrNone )
       
  1926                     {
       
  1927                     err = repository->Create( ( KLingerColumn | arrayCount ), 
       
  1928                                                aLingerInterval );     
       
  1929                     }
       
  1930                 
       
  1931                 if ( err == KErrNone )
       
  1932                     {
       
  1933                     // Update number of iapId&linger entries in Centrep
       
  1934                     err = repository->Set( KPdpContextManagerLingerArrayCount, 
       
  1935                                            arrayCount );
       
  1936                     }
       
  1937                 }
       
  1938             }
       
  1939         else
       
  1940             {
       
  1941             // Update existing entry on current row
       
  1942             TInt32 row = foundKeys[ 0 ] & KRowMask;
       
  1943             
       
  1944             err = repository->Set( ( KLingerColumn | row ), aLingerInterval ); 
       
  1945             }         
       
  1946         }
       
  1947         
       
  1948     foundKeys.Close();
       
  1949     CleanupStack::PopAndDestroy( repository );
       
  1950     
       
  1951     User::LeaveIfError( err );
       
  1952     
       
  1953     }
       
  1954 
       
  1955 void CWPAPNapdef::ConvertEAPStringToIds( const TDesC& aEAPString, TDes8& aExpandedId, TEapExpandedType& aID)
       
  1956 	{
       
  1957     if ( aEAPString == KEAPSIM )
       
  1958 		{	
       
  1959 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapSim" ) );
       
  1960 		aExpandedId.Copy( KEapSimTypeId, KExpandedEapIdLength );
       
  1961 		aID = *EapExpandedTypeSim.GetType();
       
  1962 		}
       
  1963     else if( aEAPString == KEAPAKA )
       
  1964         {
       
  1965   		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapAka" ) );
       
  1966 		aExpandedId.Copy( KEapAkaTypeId, KExpandedEapIdLength );	
       
  1967 		aID = *EapExpandedTypeAka.GetType();	
       
  1968         }
       
  1969     else if( aEAPString == KEAPTLS )
       
  1970         {
       
  1971 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTls" ) );
       
  1972 		aExpandedId.Copy( KEapTlsTypeId, KExpandedEapIdLength );	
       
  1973 		aID = *EapExpandedTypeTls.GetType();	
       
  1974         }
       
  1975     else if( aEAPString == KEAPPEAP )
       
  1976         {
       
  1977 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapPeap" ) );
       
  1978 		aExpandedId.Copy( KEapPeapTypeId, KExpandedEapIdLength );	
       
  1979 		aID = *EapExpandedTypePeap.GetType();	
       
  1980         }
       
  1981     else if( aEAPString == KEAPTTLS )
       
  1982         {
       
  1983 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTtls" ) );
       
  1984 		aExpandedId.Copy( KEapTtlsTypeId, KExpandedEapIdLength );		
       
  1985 		aID = *EapExpandedTypeTtls.GetType();
       
  1986         }
       
  1987    else if( aEAPString == KEAPLEAP )
       
  1988         {
       
  1989 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapLeap" ) );
       
  1990 		aExpandedId.Copy( KEapLeapTypeId, KExpandedEapIdLength );
       
  1991 		aID = *EapExpandedTypeLeap.GetType();		
       
  1992         }                                    
       
  1993    else if( aEAPString == KEAPMSCHAPV2 )
       
  1994         {
       
  1995 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapMschapv2" ) );
       
  1996 		aExpandedId.Copy( KEapMschapv2TypeId, KExpandedEapIdLength );		
       
  1997 		aID = *EapExpandedTypeMsChapv2.GetType();
       
  1998         }     
       
  1999    else if( aEAPString == KEAPGTC )
       
  2000         {
       
  2001 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapGtc" ) );
       
  2002 		aExpandedId.Copy( KEapGtcTypeId, KExpandedEapIdLength );
       
  2003 		aID = *EapExpandedTypeGtc.GetType();
       
  2004         }
       
  2005    else if( aEAPString == KEAPFAST )
       
  2006         {
       
  2007 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapFast" ) );
       
  2008 		aExpandedId.Copy( KEapFastTypeId, KExpandedEapIdLength );
       
  2009 		aID = *EapExpandedTypeFast.GetType();
       
  2010         }
       
  2011 
       
  2012     else
       
  2013         {
       
  2014 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapNone" ) );
       
  2015 		aExpandedId.Copy( KEapNoneId, KExpandedEapIdLength );
       
  2016 		aID = *EapExpandedTypeNone.GetType();
       
  2017         }
       
  2018 
       
  2019 	}
       
  2020  
       
  2021 // ---------------------------------------------------------------------------
       
  2022 // Returns the NAP-ID
       
  2023 // ---------------------------------------------------------------------------
       
  2024 //
       
  2025 const TDesC& CWPAPNapdef::NapId()
       
  2026     {
       
  2027 	return iNapID->Value();	
       
  2028     }
       
  2029 
       
  2030 // ---------------------------------------------------------------------------
       
  2031 // Returns the bearer value
       
  2032 // ---------------------------------------------------------------------------
       
  2033 //    
       
  2034 TUint CWPAPNapdef::Bearer()
       
  2035 	{
       
  2036 	return iBearer;
       
  2037 	}
       
  2038     
       
  2039 // ---------------------------------------------------------------------------
       
  2040 // Returns the bearer value
       
  2041 // ---------------------------------------------------------------------------
       
  2042 //    
       
  2043 void CWPAPNapdef::SetCMManager( RCmManagerExt* aCm )
       
  2044 	{
       
  2045 	iCm = aCm;
       
  2046 	}
       
  2047     
       
  2048     
       
  2049     
       
  2050 //  End of File