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