omaprovisioning/provisioning/accesspointadapter/Src/CWPAPNapdef.cpp
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     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         if(scssid!=NULL)
       
   844         	{
       
   845         	scssid->iSSSID = &aParameter;
       
   846         	}
       
   847 			  
       
   848 
       
   849         }// else if
       
   850 
       
   851     else if( ( aParameter.Name().Compare( SUSSID ) ) == 0 )
       
   852         {
       
   853         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
       
   854 			  if(scssid!=NULL)
       
   855         	{
       
   856         	scssid->iSUSSID = &aParameter;
       
   857         	}
       
   858         }// else if
       
   859                         
       
   860     else if( ( aParameter.Name().Compare( NETMODE ) ) == 0 )
       
   861         {
       
   862         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode" ) );
       
   863         if ( value == KADHOC )
       
   864 			{
       
   865 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode adhoc" ) );
       
   866 			iNetMode = CMManager::EAdhoc;
       
   867 			}
       
   868         else // default is INFRA
       
   869             {
       
   870             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode infra" ) );
       
   871             iNetMode =CMManager::EInfra;
       
   872             }
       
   873         }
       
   874 
       
   875     else if( ( aParameter.Name().Compare( SECMODE ) ) == 0 )
       
   876         {
       
   877         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode" ) );
       
   878         if ( value == KWEPSEC )
       
   879 			{
       
   880 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWEPSEC" ) );
       
   881 			iSecMode = CMManager::EWlanSecModeWep;
       
   882 			}
       
   883         else if( value == K8021XSEC )
       
   884             {
       
   885             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode K8021XSEC" ) );
       
   886 			iSecMode = CMManager::EWlanSecMode802_1x;
       
   887             }
       
   888         else if( value == KWPASEC )
       
   889             {
       
   890             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPASEC" ) );
       
   891 
       
   892 			iSecMode = CMManager::EWlanSecModeWpa;
       
   893             }
       
   894         else if( value == KWPA2SEC )
       
   895             {
       
   896             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2SEC" ) );
       
   897 			iSecMode = CMManager::EWlanSecModeWpa2;
       
   898             }
       
   899         else if( value == KWPAPRESSEC )
       
   900             {
       
   901             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPAPRESSEC" ) );
       
   902 			iSecMode = CMManager::EWlanSecModeWpa;
       
   903             }
       
   904         else if( value == KWPA2PRESSEC )
       
   905             {
       
   906             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2PRESSEC" ) );
       
   907 			iSecMode = CMManager::EWlanSecModeWpa2;
       
   908             }          
       
   909         else
       
   910             {
       
   911             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode open" ) );
       
   912 			iSecMode = CMManager::EWlanSecModeOpen;
       
   913             }
       
   914         }
       
   915 
       
   916     else if( ( aParameter.Name().Compare( WPAPRESKEYASC ) ) == 0 )
       
   917         {
       
   918         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WPAPRESKEYASC" ) );
       
   919         if ( !iWpaPresKeyAsc )
       
   920             {
       
   921             iWpaPresKeyAsc = &aParameter;
       
   922             }
       
   923         }// else if
       
   924         // indicates the default wepkey index
       
   925     else if( ( aParameter.Name().Compare( DEFAULTWEPIND ) ) == 0 )
       
   926         {
       
   927         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepind" ) );
       
   928 
       
   929         TLex lex( value );
       
   930         lex.Val( iDefaultWepKeyIndex );
       
   931         if ( iDefaultWepKeyIndex >= 4 )
       
   932             {
       
   933             iDefaultWepKeyIndex = 0;
       
   934             }
       
   935         }// else if
       
   936         
       
   937     else if( ( aParameter.Name().Compare( WEPAUTHMODE ) ) == 0 )
       
   938         {
       
   939         if ( value == KWEPAUTHMODEOPEN )
       
   940 			{
       
   941 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode OPEN" ) );
       
   942 			iAuthentication = EAuthOpen;
       
   943 			}
       
   944 		else if ( value == KWEPAUTHMODESHARED )
       
   945 		    {
       
   946 		    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode SHARED" ) );
       
   947 			iAuthentication = EAuthShared;
       
   948 		    }
       
   949         }// else if
       
   950         
       
   951     else if( ( aParameter.Name().Compare( WEPKEYLENGTH ) ) == 0 )
       
   952         {
       
   953         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYLENGTH" ) );
       
   954         if ( !iWepKeyLength )
       
   955             {
       
   956             iWepKeyLength = &aParameter;
       
   957             }
       
   958         }// else if
       
   959     else if( ( aParameter.Name().Compare( WEPKEYINDEX ) ) == 0 )
       
   960         {
       
   961         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYINDEX" ) );
       
   962         TLex lex( value );
       
   963         lex.Val( iWepInd );
       
   964         }// else if 
       
   965     else if( ( aParameter.Name().Compare( WEPKEYDATA ) ) == 0 )
       
   966         {
       
   967         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYDATA" ) );
       
   968 
       
   969         if ( iWepInd <  4 )
       
   970             {
       
   971             const TUint8 K40Bits = 5;
       
   972             const TUint8 K104Bits = 13;
       
   973             const TUint8 K232Bits = 29;
       
   974 
       
   975             TBuf8<KMaxLengthOfKeyData> buf8;
       
   976             StrCopy( buf8, aParameter.Value() );
       
   977             
       
   978             if(buf8.Length() == K232Bits ||
       
   979                 buf8.Length() == K104Bits ||
       
   980                 buf8.Length() == K40Bits  )
       
   981                 {
       
   982                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL ASCI Wep Key" ) );
       
   983                 HBufC8* buf8Conv = HBufC8::NewLC( KMaxLengthOfKeyData );
       
   984                 ConvertAsciiToHex( buf8, buf8Conv );
       
   985                 iKeyData[iWepInd] = *buf8Conv;
       
   986                 iKeyFormat[iWepInd] = CWPAPNapdef::EAscii;
       
   987                 CleanupStack::PopAndDestroy( buf8Conv );
       
   988                 }
       
   989             else if( buf8.Length()==K232Bits*2 ||
       
   990                 buf8.Length()== K104Bits*2 ||
       
   991                 buf8.Length() == K40Bits*2)
       
   992                 {
       
   993                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL HEX Wep Key" ) );
       
   994                 iKeyData[iWepInd] = buf8;
       
   995                 iKeyFormat[iWepInd] = CWPAPNapdef::EHexadecimal;
       
   996                 }
       
   997             }
       
   998         
       
   999         }// else if	
       
  1000     
       
  1001     // Handle EAP parameter
       
  1002     HandleEAPParametersCCL( aParameter );        
       
  1003     
       
  1004     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL done" ) );
       
  1005 	}
       
  1006 
       
  1007 // -----------------------------------------------------------------------------
       
  1008 // CWPAPNapdef::HandleEAPParametersL
       
  1009 // -----------------------------------------------------------------------------
       
  1010 //
       
  1011 void CWPAPNapdef::HandleEAPParametersCCL( CWPParameter& aParameter )
       
  1012     {
       
  1013 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL" ) );
       
  1014    	
       
  1015    	CEapTypeElement* eap = NULL;
       
  1016    	if ( iEapTypeArray.Count() )
       
  1017    	    {
       
  1018    	    eap = iEapTypeArray[iEapTypeArray.Count()-1];
       
  1019    	    }
       
  1020    	if(!eap)
       
  1021    	    {
       
  1022    	    return;
       
  1023    	    }    
       
  1024    	
       
  1025 	TPtrC value( aParameter.Value() );
       
  1026 	
       
  1027     if( ( aParameter.Name().Compare( EAPTYPE ) ) == 0 )
       
  1028         {
       
  1029         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTYPE" ) );
       
  1030               
       
  1031         ConvertEAPStringToIds( value, eap->iEapTypeString, reinterpret_cast<TUint &> ( eap->iEAPSettings->iEAPType )  );
       
  1032         
       
  1033         }
       
  1034     else if( ( aParameter.Name().Compare( EAPUSERNAME ) ) == 0 )
       
  1035         {
       
  1036         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSERNAME" ) );
       
  1037         if ( eap->iEAPSettings->iUsername.Length() == 0 )
       
  1038             {
       
  1039             eap->iEAPSettings->iUsername = value;
       
  1040             eap->iEAPSettings->iUsernamePresent = ETrue;
       
  1041             }
       
  1042         }// else if 
       
  1043     else if( ( aParameter.Name().Compare( EAPPASSWORD ) ) == 0 )
       
  1044         {
       
  1045         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPASSWORD" ) );
       
  1046         if ( eap->iEAPSettings->iPassword.Length() == 0 )
       
  1047             {
       
  1048             eap->iEAPSettings->iPassword = value;
       
  1049             eap->iEAPSettings->iPasswordPresent = ETrue;
       
  1050             }
       
  1051         }// else if 
       
  1052     else if( ( aParameter.Name().Compare( EAPREALM ) ) == 0 )
       
  1053         {
       
  1054         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPREALM" ) );
       
  1055 
       
  1056         if ( eap->iEAPSettings->iRealm.Length() == 0 )
       
  1057             {
       
  1058             eap->iEAPSettings->iRealm = value;
       
  1059             eap->iEAPSettings->iRealmPresent = ETrue;
       
  1060             }
       
  1061         }// else if 
       
  1062     else if( ( aParameter.Name().Compare( EAPUSEPSEUD ) ) == 0 )
       
  1063         {
       
  1064         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSEPSEUD" ) );
       
  1065         TInt pseudonyms;
       
  1066         TLex lex( value );
       
  1067         lex.Val( pseudonyms );
       
  1068         
       
  1069         eap->iEAPSettings->iUsePseudonymsPresent = ETrue;
       
  1070         if ( pseudonyms == 1 )
       
  1071             {        
       
  1072             eap->iEAPSettings->iUsePseudonyms = ETrue;
       
  1073             }
       
  1074         else
       
  1075             {
       
  1076             eap->iEAPSettings->iUsePseudonyms = EFalse;            
       
  1077             }
       
  1078         }// else if 
       
  1079     else if( ( aParameter.Name().Compare( EAPMAXAUTHS ) ) == 0 )
       
  1080         {
       
  1081         // not supported
       
  1082         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPMAXAUTHS" ) );
       
  1083         }// else if 
       
  1084     else if( ( aParameter.Name().Compare( EAPENCAPS ) ) == 0 )
       
  1085         {
       
  1086         
       
  1087         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPENCAPS" ) );
       
  1088         TUint dummy;
       
  1089         ConvertEAPStringToIds( value, eap->iEncapsulatingExpandedEapId, dummy );
       
  1090                      
       
  1091         }// else if    
       
  1092     else if( ( aParameter.Name().Compare( EAPVERSERREALM ) ) == 0 )
       
  1093         {
       
  1094         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPVERSERREALM" ) );
       
  1095         
       
  1096         TInt serverRealm;
       
  1097         TLex lex( value );
       
  1098         lex.Val( serverRealm );
       
  1099         
       
  1100         eap->iEAPSettings->iVerifyServerRealmPresent = ETrue;
       
  1101         
       
  1102         if ( serverRealm == 1 )
       
  1103             {        
       
  1104             eap->iEAPSettings->iVerifyServerRealm = ETrue;
       
  1105             }
       
  1106         else
       
  1107             {
       
  1108             eap->iEAPSettings->iVerifyServerRealm = EFalse;            
       
  1109             }
       
  1110         }// else if    
       
  1111     else if( ( aParameter.Name().Compare( EAPCLIENTHAUTH ) ) == 0 )
       
  1112         {
       
  1113         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCLIENTHAUTH" ) );
       
  1114         
       
  1115         TInt clientAuthentication;
       
  1116         TLex lex( value );
       
  1117         lex.Val( clientAuthentication );
       
  1118         
       
  1119         eap->iEAPSettings->iRequireClientAuthenticationPresent = ETrue;
       
  1120         
       
  1121         if ( clientAuthentication == 1 )
       
  1122             {        
       
  1123             eap->iEAPSettings->iRequireClientAuthentication = ETrue;
       
  1124             }
       
  1125         else
       
  1126             {
       
  1127             eap->iEAPSettings->iRequireClientAuthentication = EFalse;            
       
  1128             }
       
  1129         }// else if    
       
  1130     else if( ( aParameter.Name().Compare( EAPSESVALTIME ) ) == 0 )
       
  1131         {
       
  1132         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSESVALTIME" ) );
       
  1133         
       
  1134         TInt sessionValidityTime;
       
  1135         TLex lex( value );
       
  1136         lex.Val( sessionValidityTime );
       
  1137         eap->iEAPSettings->iSessionValidityTime = sessionValidityTime;
       
  1138         eap->iEAPSettings->iSessionValidityTimePresent = ETrue;
       
  1139 
       
  1140         }// else if    
       
  1141     else if( ( aParameter.Name().Compare( EAPCIPSUIT ) ) == 0 )
       
  1142         {
       
  1143         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCIPSUIT" ) );
       
  1144         
       
  1145         TInt cipherSuites;
       
  1146         TLex lex( value );
       
  1147         lex.Val( cipherSuites );
       
  1148         eap->iEAPSettings->iCipherSuites.Append( cipherSuites );
       
  1149         eap->iEAPSettings->iCipherSuitesPresent = ETrue;
       
  1150         
       
  1151         }// else if
       
  1152     else if( ( aParameter.Name().Compare( EAPPEAPV0 ) ) == 0 )
       
  1153         {
       
  1154         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV0" ) );
       
  1155         
       
  1156         TInt peap;
       
  1157         TLex lex( value );
       
  1158         lex.Val( peap );
       
  1159         
       
  1160         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1161         if ( peap == 1 )
       
  1162             {        
       
  1163             eap->iEAPSettings->iPEAPv0Allowed = ETrue;
       
  1164             }
       
  1165         else
       
  1166             {
       
  1167             eap->iEAPSettings->iPEAPv0Allowed = EFalse;            
       
  1168             }
       
  1169         }// else if     
       
  1170     else if( ( aParameter.Name().Compare( EAPPEAPV1 ) ) == 0 )
       
  1171         {
       
  1172         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV1" ) );
       
  1173         TInt peap;
       
  1174         TLex lex( value );
       
  1175         lex.Val( peap );
       
  1176         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1177         if ( peap == 1 )
       
  1178             {        
       
  1179             eap->iEAPSettings->iPEAPv1Allowed = ETrue;
       
  1180             }
       
  1181         else
       
  1182             {
       
  1183             eap->iEAPSettings->iPEAPv1Allowed = EFalse;            
       
  1184             }
       
  1185         }// else if
       
  1186     else if( ( aParameter.Name().Compare( EAPPEAPV2 ) ) == 0 )
       
  1187         {
       
  1188         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV2" ) );
       
  1189         TInt peap;
       
  1190         TLex lex( value );
       
  1191         lex.Val( peap );
       
  1192         eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1193         if ( peap == 1 )
       
  1194             {        
       
  1195             eap->iEAPSettings->iPEAPv2Allowed = ETrue;
       
  1196             }
       
  1197         else
       
  1198             {
       
  1199             eap->iEAPSettings->iPEAPv2Allowed = EFalse;            
       
  1200             }
       
  1201         }// else if  
       
  1202         
       
  1203     else if( ( aParameter.Name().Compare( EAPISSNAME ) ) == 0 )
       
  1204         {
       
  1205         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPISSNAME" ) );
       
  1206         
       
  1207         eap->iCertificate->iSubjectName = value;
       
  1208         eap->iCertificate->iSubjectNamePresent = ETrue;
       
  1209         }// else if        
       
  1210         
       
  1211     else if( ( aParameter.Name().Compare( EAPSUBNAME ) ) == 0 )
       
  1212         {
       
  1213         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBNAME" ) );
       
  1214         
       
  1215         eap->iCertificate->iIssuerName = value;
       
  1216         eap->iCertificate->iIssuerNamePresent = ETrue;
       
  1217        
       
  1218         }// else if        
       
  1219         
       
  1220     else if( ( aParameter.Name().Compare( EAPCERTTYPE ) ) == 0 )
       
  1221         {
       
  1222         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCERTTYPE" ) );
       
  1223         if ( value == EAPCERTCA )
       
  1224 			{
       
  1225 			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EEapSim" ) );
       
  1226             
       
  1227             eap->iCertificate->iCertType = CertificateEntry::ECA;
       
  1228 			}
       
  1229 		else
       
  1230 		    {
       
  1231 		    eap->iCertificate->iCertType = CertificateEntry::EUser;
       
  1232 		    }
       
  1233 		// Certificates must be present since this field was added
       
  1234 		eap->iEAPSettings->iCertificatesPresent = ETrue; 
       
  1235         
       
  1236         }// else if        
       
  1237     else if( ( aParameter.Name().Compare( EAPSERNUM ) ) == 0 )
       
  1238         {
       
  1239         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSERNUM" ) );
       
  1240         
       
  1241         eap->iCertificate->iSerialNumber = value;
       
  1242         eap->iCertificate->iSerialNumberPresent = ETrue;
       
  1243         }// else if
       
  1244         
       
  1245     else if( ( aParameter.Name().Compare( EAPSUBKEYID ) ) == 0 )
       
  1246         {
       
  1247         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBKEYID" ) );
       
  1248            
       
  1249         _LIT(KHexIdLC, "0x");
       
  1250        	_LIT(KHexIdUC, "0X");
       
  1251        	TBuf<2> HexIdBuf;
       
  1252        	TInt keyLen = aParameter.Value().Length();
       
  1253        	
       
  1254        	// setting the given key to the key buffer
       
  1255        	TBuf<KMaxSubKeyLenght> origKey;
       
  1256        	origKey.SetLength(keyLen);
       
  1257        	origKey = aParameter.Value();
       
  1258        	TBuf<KMaxSubKeyLenght> key;
       
  1259        	TLex tmpByte;
       
  1260        	TInt err(KErrNone);
       
  1261        	TUint16 byte;
       
  1262        	
       
  1263        	// Remove possible spaces from the beginning
       
  1264        	origKey.TrimLeft();
       
  1265        	
       
  1266        	// if the key is over two chars long, then we have to check
       
  1267        	// whether there is 0x or 0X in the beginning
       
  1268        	if (origKey.Length() >= 2)
       
  1269             {
       
  1270         	// Copy the two left most characters in to the buffer
       
  1271         	HexIdBuf.Copy(origKey.Left(2));
       
  1272         	
       
  1273         	// If the first characters are 0x or 0X, then they should be ignored
       
  1274         	if (HexIdBuf.Compare(KHexIdLC) == 0
       
  1275         			|| HexIdBuf.Compare(KHexIdUC) == 0)
       
  1276         		{
       
  1277         		// delete two characters
       
  1278         		origKey.Delete(0, 2);
       
  1279         		}
       
  1280             }
       
  1281         
       
  1282        	// looping the subject key through, removing whitespaces
       
  1283        	for (TInt i = 0; i < keyLen; i++)
       
  1284        		{
       
  1285        		// removing white spaces from the left side of the key
       
  1286        		origKey.TrimLeft();
       
  1287        		// check that there are characters left
       
  1288        		if (origKey.Length() >= 2)
       
  1289        			{
       
  1290        			// pick the two left most bytes from the key
       
  1291        			tmpByte = origKey.Left(2);
       
  1292        			// convert byte into binary format
       
  1293        			err = tmpByte.Val(byte, EHex);
       
  1294        			
       
  1295        			// delete two characters from the left side of the character array in the buffer
       
  1296        			origKey.Delete(0, 2);
       
  1297        			
       
  1298        			// check whether conversion to decimal went ok
       
  1299        			if (err != KErrNone)
       
  1300        				{
       
  1301        				// if there are problems, then leave the loop
       
  1302        				break;
       
  1303        				}
       
  1304        			
       
  1305        			// store the appended byte into the key variable
       
  1306        			key.Append(byte);
       
  1307        			}
       
  1308        			
       
  1309        		else if (origKey.Length() == 1)
       
  1310        			{
       
  1311        			// pick the left most bytes from the key
       
  1312        			tmpByte = origKey.Left(1);
       
  1313        			// convert byte into binary format
       
  1314        			err = tmpByte.Val(byte, EHex);
       
  1315        			
       
  1316        			// delete two characters from the left side of the character array in the buffer
       
  1317        			origKey.Delete(0, 1);
       
  1318        			
       
  1319        			// check whether conversion to decimal went ok
       
  1320        			if (err != KErrNone)
       
  1321        				{
       
  1322        				// if there are problems, then leave the loop
       
  1323        				break;
       
  1324        				}
       
  1325        			
       
  1326        			// store the appended byte into the key variable
       
  1327        			key.Append(byte);
       
  1328        			}
       
  1329        		else
       
  1330        			{
       
  1331        			break;
       
  1332        			}
       
  1333        		}
       
  1334        	// store key value only if no errors occurred
       
  1335        	if (err == KErrNone) 
       
  1336        		{
       
  1337        		eap->iCertificate->iSubjectKeyID.Copy(key);
       
  1338        		eap->iCertificate->iSubjectKeyIDPresent = ETrue;
       
  1339        		eap->iEAPSettings->iCertificatesPresent = ETrue; 
       
  1340        		}
       
  1341        	}
       
  1342        	
       
  1343         
       
  1344     else if( ( aParameter.Name().Compare( EAPTHUMBPRINT ) ) == 0 )
       
  1345         {
       
  1346         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTHUMBPRINT" ) );
       
  1347         eap->iCertificate->iThumbprintPresent = ETrue;
       
  1348         eap->iCertificate->iThumbprint = value;
       
  1349         }// else if                  
       
  1350     }
       
  1351 
       
  1352 
       
  1353 // -----------------------------------------------------------------------------
       
  1354 // CWPAPNapdef::CWPAPNapdef
       
  1355 // C++ default constructor can NOT contain any code, that
       
  1356 // might leave.
       
  1357 // -----------------------------------------------------------------------------
       
  1358 //
       
  1359 CWPAPNapdef::CWPAPNapdef( TBool aFollowingLink,
       
  1360                           const TDesC& aDefaultName, 
       
  1361                           CWPCharacteristic& aLogicalCharacteristic )
       
  1362                         : CWPAPItemBase( aDefaultName ),
       
  1363                           iCharacteristic( aLogicalCharacteristic ),
       
  1364                           iFollowingLink( aFollowingLink )
       
  1365 	{
       
  1366 	}
       
  1367 
       
  1368 // -----------------------------------------------------------------------------
       
  1369 // CWPAPNapdef::ConstructL
       
  1370 // Symbian 2nd phase constructor can leave.
       
  1371 // -----------------------------------------------------------------------------
       
  1372 //
       
  1373 void CWPAPNapdef::ConstructL()
       
  1374 	{
       
  1375 	iLingerValue = NULL;
       
  1376 	iLingerFlag = ETrue;
       
  1377 	iInternetIndicator = -1;
       
  1378 	//checks if Wlan feature is supported
       
  1379   FeatureManager::InitializeLibL();
       
  1380   iWlanSupported = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
  1381   FeatureManager::UnInitializeLib();
       
  1382 	}
       
  1383 
       
  1384 // -----------------------------------------------------------------------------
       
  1385 // CWPAPNapdef::SaveWlanDataL
       
  1386 // -----------------------------------------------------------------------------
       
  1387 //
       
  1388 void CWPAPNapdef::SaveWlanDataL( TUint32 aIapId, CCommsDatabase& aCommsDb )
       
  1389     {
       
  1390     FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL APid: (%d)"),  aIapId) );
       
  1391     
       
  1392     if ( iBearer == KUidWlanBearerType )
       
  1393 	    {
       
  1394         CCommsDbTableView* wLanServiceTable;
       
  1395         
       
  1396         // CMManager
       
  1397         // Search the Iap Service Id using the received IapId
       
  1398         RCmConnectionMethodExt cm = iCm->ConnectionMethodL( aIapId );
       
  1399         TUint32 serviceId = cm.GetIntAttributeL( CMManager::ECmIapServiceId );
       
  1400      	
       
  1401         // The BeginTransaction might fail if someone else has locked CommsDat
       
  1402         TInt dberr = aCommsDb.BeginTransaction();
       
  1403         if( dberr == KErrLocked )
       
  1404             {
       
  1405             // Try BeginTransaction again to get lock
       
  1406             TInt retry = KBeginTransRetryCount;            
       
  1407             while ( retry > 0 && dberr == KErrLocked )
       
  1408                 {                   
       
  1409                 User::After(KBeginTransRetryDelay);
       
  1410                 dberr = aCommsDb.BeginTransaction();
       
  1411                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: Database locked. BeginTransaction retry." ) );
       
  1412                 retry--;
       
  1413                 }
       
  1414             if(dberr != KErrNone)
       
  1415                 {                            
       
  1416                 // Could not get lock to CommsDat at all
       
  1417                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: BeginTransaction failed completely." ) );
       
  1418                 User::Leave( dberr ); 
       
  1419                 }           
       
  1420             }                             
       
  1421         
       
  1422         TInt indexToSec = 0;
       
  1423         wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( 
       
  1424                         TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), serviceId );
       
  1425         TInt errorCode = wLanServiceTable->GotoFirstRecord();
       
  1426 
       
  1427         if ( errorCode == KErrNone )
       
  1428             {
       
  1429             indexToSec = serviceId;
       
  1430             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL updaterecord" ) );
       
  1431             wLanServiceTable->UpdateRecord();
       
  1432             }
       
  1433         else
       
  1434             {
       
  1435             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL insertrecord" ) );
       
  1436             TUint32 dummyUid( 0 );
       
  1437             User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
       
  1438 
       
  1439             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_SERVICE_ID" ) );
       
  1440             // Save link to LAN service
       
  1441             wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId );
       
  1442             indexToSec = aIapId;
       
  1443             }
       
  1444         
       
  1445         // Setting the security mode manually, because CMManager does not do that
       
  1446         wLanServiceTable->WriteUintL( TPtrC( WLAN_SECURITY_MODE ), iSecMode );
       
  1447 
       
  1448     	if( iSecSSID.Count() )
       
  1449 			{
       
  1450 	        CCommsDbTableView* wLanSecserviceTable;
       
  1451 			wLanSecserviceTable = aCommsDb.OpenTableLC( TPtrC( WLAN_SECONDARY_SSID ) ); 
       
  1452 			//CleanupStack::Pop(wLanSecserviceTable); // wLanSecserviceTable
       
  1453 		 	TBuf<4> blank;
       
  1454 		 	blank.Append(KNullDesC);
       
  1455 		    
       
  1456 		    TBool sssid = EFalse;
       
  1457 	        TBool sussid = EFalse;
       
  1458 
       
  1459 	        for(TInt i = 0; i < iSecSSID.Count(); i++ )
       
  1460 	        	{
       
  1461 	        	TUint32 id ;
       
  1462 	        	
       
  1463 		        
       
  1464 		        TInt retval = wLanSecserviceTable->InsertRecord(id);
       
  1465 		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), indexToSec );
       
  1466 		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_ID), id );
       
  1467 
       
  1468 		 	    if( iSecSSID[i]->iSSSID != NULL)
       
  1469 		 	    sssid = ETrue;
       
  1470 		 	    if(iSecSSID[i]->iSUSSID != NULL)
       
  1471 		 	    sussid = ETrue;
       
  1472 		 	    
       
  1473 		 	    if((sssid && iSecSSID[i]->iSSSID->Value() != blank) || (sussid && iSecSSID[i]->iSUSSID->Value() != blank ))
       
  1474 		 	    {
       
  1475 		 		if( sssid )
       
  1476 		 		wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_SCANNED_SSID), iSecSSID[i]->iSSSID->Value());
       
  1477 			
       
  1478 				if(sussid)
       
  1479 				wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_USED_SSID), iSecSSID[i]->iSUSSID->Value());
       
  1480 		        
       
  1481 		 	    }
       
  1482 		 	    wLanSecserviceTable->PutRecordChanges();
       
  1483 		 	    sssid = EFalse;
       
  1484 	            sussid = EFalse;
       
  1485 	        	}
       
  1486 	        	CleanupStack::PopAndDestroy( wLanSecserviceTable );
       
  1487 			}
       
  1488 			
       
  1489 			iSecSSID.ResetAndDestroy();
       
  1490 			iSecSSID.Close();
       
  1491         if ( iPriSSID )
       
  1492             {
       
  1493             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_SSID" ) );
       
  1494             // Save NU_WLAN_SSID
       
  1495         	wLanServiceTable->WriteTextL( TPtrC(NU_WLAN_SSID), iPriSSID->Value() );
       
  1496             }
       
  1497         if ( iPriUSSID )
       
  1498             {        
       
  1499             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_USED_SSID" ) );
       
  1500             // Save WLAN_USED_SSID	
       
  1501     	      wLanServiceTable->WriteTextL( TPtrC(WLAN_USED_SSID), iPriUSSID->Value() );
       
  1502             }
       
  1503         if ( iPriHSSID )
       
  1504             {        
       
  1505     	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_SCAN_SSID" ) );
       
  1506             // Save WLAN_SCAN_SSID
       
  1507     	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), ETrue );
       
  1508             }
       
  1509         else
       
  1510             {
       
  1511     	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), EFalse );            	
       
  1512             }
       
  1513 
       
  1514        	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX" ) );
       
  1515         // Save index of key in use
       
  1516         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), 
       
  1517                                       (TUint32&) iDefaultWepKeyIndex );
       
  1518         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX: (%d)"),  iDefaultWepKeyIndex) );
       
  1519 
       
  1520         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE" ) );
       
  1521         // Open / Shared (0/1)
       
  1522         // Save index of key in use
       
  1523         wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), 
       
  1524                                      ( TUint32& ) iAuthentication );
       
  1525         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE: (%d)"),  iAuthentication) );
       
  1526         
       
  1527         
       
  1528         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY1" ) );
       
  1529         // Save first WEP key
       
  1530         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), iKeyData[0] );
       
  1531         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), 
       
  1532                                  ( TUint32& ) iKeyFormat[0] );
       
  1533         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[0] ) );
       
  1534         
       
  1535         
       
  1536         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY2" ) );
       
  1537         // Save second WEP key
       
  1538         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), iKeyData[1] );
       
  1539         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), 
       
  1540                                  ( TUint32& ) iKeyFormat[1] );
       
  1541         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[1] ) );
       
  1542             
       
  1543         
       
  1544         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY3" ) );
       
  1545         // Save third WEP key
       
  1546         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), iKeyData[2] );
       
  1547         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), 
       
  1548                                  ( TUint32& ) iKeyFormat[2] );
       
  1549         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[2] ) );
       
  1550             
       
  1551             
       
  1552         
       
  1553         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY4" ) );
       
  1554         // Save fourth WEP key
       
  1555         wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), iKeyData[3] );
       
  1556         wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), 
       
  1557                                  ( TUint32& ) iKeyFormat[3] );
       
  1558         FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[3] ) );
       
  1559             
       
  1560         
       
  1561         if ( iWpaPresKeyAsc )
       
  1562             {     
       
  1563             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL convert WPAKEY to ascii" ) );
       
  1564             // convert unicode to 8-bit ascii
       
  1565             TBuf8<KMaxWpaPskLength> wpaKey;
       
  1566             StrCopy( wpaKey, iWpaPresKeyAsc->Value() );
       
  1567             
       
  1568             // Enable WPA Pre Shared key mode
       
  1569             wLanServiceTable->WriteBoolL( TPtrC( WLAN_ENABLE_WPA_PSK ), ETrue );
       
  1570             
       
  1571             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_PRE_SHARED_KEY" ) );
       
  1572             // Save PreShared Key
       
  1573             wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), 
       
  1574                                          wpaKey );
       
  1575             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_KEY_LENGTH" ) ); 
       
  1576             // Save PreShared Key Length
       
  1577             wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), 
       
  1578                                          wpaKey.Length() );                                         
       
  1579             }
       
  1580 
       
  1581         TBuf<KMaxLengthOfEapList> eapList;
       
  1582         eapList.Copy(KEapAll);
       
  1583 
       
  1584         for (TInt i=0;i<iEapTypeArray.Count();i++)
       
  1585             {
       
  1586             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings" ) );
       
  1587             CEapTypeElement* eap = iEapTypeArray[i];
       
  1588             
       
  1589             if ( eap->iEAPSettings->iCertificatesPresent )
       
  1590             	{
       
  1591             	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL Certificate was present." ) );
       
  1592             	eap->iEAPSettings->iCertificates.AppendL( *eap->iCertificate );	
       
  1593             	}                  
       
  1594 
       
  1595             // Save EAP list
       
  1596             if ( eap->iEapTypeString.Length() > 0  
       
  1597             	 && eap->iEncapsulatingExpandedEapId.Length() == 0) // AND method is not encapsulated
       
  1598                 {
       
  1599                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_EAPS" ) );
       
  1600                 
       
  1601                 TBuf8<3> buf;
       
  1602                 _LIT8(KFormat, "%d");
       
  1603                 // pick the last byte from the array
       
  1604                 buf.Format(KFormat, eap->iEapTypeString[KExpandedEapIdLength - 1]);
       
  1605                 // search for the correct offset for the eap type from the KEapAll literal
       
  1606                 TInt index = KEapAll().Find(buf);
       
  1607                 
       
  1608                 const TUint8 offset = 2; //length = f "-0" string
       
  1609                 // Add '+' to the correct offset, so that the eap is repsesented activated in the list
       
  1610                 if(index >= offset)
       
  1611                     {
       
  1612                     eapList[index-offset] = KEapPlus; 
       
  1613                     }
       
  1614                 
       
  1615                 }
       
  1616             
       
  1617 			// Set iEncapsulatingEapTypes
       
  1618 			for ( TInt j = 0; j < iEapTypeArray.Count(); j++ )
       
  1619 				{
       
  1620 				// Check if any method has this method as the encapsulating method
       
  1621 				if ( eap->iEapTypeString == iEapTypeArray[j]->iEncapsulatingExpandedEapId )
       
  1622 					{
       
  1623 					// Append this method to iEncapsulatedEAPType
       
  1624 					eap->iEAPSettings->iEncapsulatedEAPTypes.Append( iEapTypeArray[j]->iEAPSettings->iEAPType );
       
  1625 					eap->iEAPSettings->iEncapsulatedEAPTypesPresent = ETrue;
       
  1626 					}
       
  1627 				}			
       
  1628 			
       
  1629             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings CEapType::NewL" ) );        
       
  1630             CEapType* eapType = NULL;
       
  1631 
       
  1632             TRAPD( error, ( eapType = CEapType::NewL( eap->iEapTypeString, ELan, serviceId ) ) );
       
  1633 
       
  1634             if ( ( error == KErrNone ) && eapType )
       
  1635                 {
       
  1636                 CleanupStack::PushL( eapType );
       
  1637                 
       
  1638                 // Check if this type is tunneled
       
  1639                 if ( eap->iEncapsulatingExpandedEapId.Length() > 0 )
       
  1640                 	{
       
  1641                 	// It is tunneled. Take the last byte of the expanded id.
       
  1642                 	eapType->SetTunnelingType( eap->iEncapsulatingExpandedEapId[KExpandedEapIdLength - 1] );
       
  1643                 	
       
  1644                 	}
       
  1645                 
       
  1646                 FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings SetConfigurationL" ) );
       
  1647                 TRAP_IGNORE( eapType->SetConfigurationL( *eap->iEAPSettings ) );
       
  1648                 
       
  1649                 CleanupStack::PopAndDestroy( eapType );
       
  1650                 
       
  1651                 }
       
  1652             else
       
  1653                 {
       
  1654                 FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL CEapType::NewL err: %d"), error ) );
       
  1655                 }
       
  1656 
       
  1657 
       
  1658             FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings done" ) );
       
  1659             }
       
  1660             
       
  1661             
       
  1662 	
       
  1663 	  		// Expanded EAP types in use. Write the eap list to the new columns.
       
  1664     		
       
  1665     		// generate appropriate entries in the new enabled and disabled list,
       
  1666     		// overwriting those values 
       
  1667     		
       
  1668     		// count the + and - signs to determine the size of enabled and 
       
  1669     		// disabled descriptors
       
  1670 
       
  1671     		TLex lex( eapList );
       
  1672     		TInt numPlus = 0;
       
  1673     		TInt numMinus = 0;
       
  1674     		TChar ch;
       
  1675     		while ( !lex.Eos() )
       
  1676     		    {
       
  1677     		    ch = lex.Get();
       
  1678     		    if ( ch == '+' ) ++numPlus;
       
  1679     		    else if ( ch == '-' ) ++numMinus;
       
  1680     		    }
       
  1681     		    
       
  1682     		// each entry consumes 8 bytes in binary format
       
  1683     		HBufC8* enabledEAPPlugin = HBufC8::NewL( 8 * numPlus );
       
  1684     		CleanupStack::PushL( enabledEAPPlugin );
       
  1685     		
       
  1686     		HBufC8* disabledEAPPlugin = HBufC8::NewL( 8 * numMinus );
       
  1687     		CleanupStack::PushL( disabledEAPPlugin );
       
  1688     		    
       
  1689     		lex.Assign( eapList );
       
  1690     		
       
  1691     		while ( !lex.Eos() )
       
  1692     		    {
       
  1693     		    // beginning of implementation UID
       
  1694     		    TInt16 implUid = 0;
       
  1695     		    
       
  1696     		    if ( lex.Val( implUid ) != KErrNone || !implUid )
       
  1697     		        {
       
  1698     		        // if the old string is corrupted, null out both lists
       
  1699     		        enabledEAPPlugin->Des().Zero();
       
  1700     		        disabledEAPPlugin->Des().Zero();
       
  1701     		        break;
       
  1702     		        }
       
  1703     		
       
  1704     		    // append it to the appropriate list ('+' enabled, '-' disabled)
       
  1705     		    _LIT8( KPadding, "\xFE\0\0\0\0\0\0" );
       
  1706     		    _LIT8( KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
       
  1707     		    const TInt KPlainMsChapV2ImplUid = 99;
       
  1708     		    
       
  1709     		    if ( implUid > 0 )
       
  1710     		        {
       
  1711     		        enabledEAPPlugin->Des().Append( 
       
  1712     		                            Abs( implUid ) == KPlainMsChapV2ImplUid? 
       
  1713     		                                        KMsChapV2Padding: KPadding );
       
  1714     		        enabledEAPPlugin->Des().Append( Abs( implUid ) );
       
  1715     		        }
       
  1716     		    else if (implUid < 0 )
       
  1717     		        {
       
  1718     		        disabledEAPPlugin->Des().Append( 
       
  1719     		                            Abs( implUid ) == KPlainMsChapV2ImplUid? 
       
  1720     		                                        KMsChapV2Padding: KPadding );
       
  1721     		        disabledEAPPlugin->Des().Append( Abs( implUid ) );
       
  1722     		        }
       
  1723     		    
       
  1724     		    // swallow the delimiter (',')
       
  1725     		    lex.Get();
       
  1726     		    }
       
  1727                 	
       
  1728 	
       
  1729 	
       
  1730 	  		wLanServiceTable->WriteTextL( TPtrC( WLAN_ENABLED_EAPS ), 
       
  1731     		                              enabledEAPPlugin? 
       
  1732     		                                    (const TDesC8&)*enabledEAPPlugin: 
       
  1733     		                                    (const TDesC8&)KNullDesC8 );
       
  1734     		
       
  1735     		wLanServiceTable->WriteTextL( TPtrC( WLAN_DISABLED_EAPS ), 
       
  1736     		                              disabledEAPPlugin? 
       
  1737     		                                    (const TDesC8&)*disabledEAPPlugin: 
       
  1738     		                                    (const TDesC8&)KNullDesC8 );
       
  1739     		CleanupStack::PopAndDestroy( disabledEAPPlugin );
       
  1740     		CleanupStack::PopAndDestroy( enabledEAPPlugin );
       
  1741     
       
  1742      
       
  1743             
       
  1744        iEapTypeArray.ResetAndDestroy();
       
  1745        wLanServiceTable->PutRecordChanges();
       
  1746   
       
  1747 
       
  1748         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL PutRecordChanges" ) ); 
       
  1749         CleanupStack::PopAndDestroy( wLanServiceTable );
       
  1750         
       
  1751         FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL done" ) );
       
  1752 	    aCommsDb.CommitTransaction();
       
  1753 	    }
       
  1754 	else
       
  1755 	    {
       
  1756 	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL ignored not a WLAN AP" ) );
       
  1757 	    }
       
  1758 	    
       
  1759     }
       
  1760 
       
  1761 //------------------------------------------------------------------------------
       
  1762 // CWPAPNapdef::ConvertAsciiToHex
       
  1763 //------------------------------------------------------------------------------
       
  1764 //
       
  1765 void CWPAPNapdef::ConvertAsciiToHex( const TDesC8& aSource, HBufC8*& aDest )
       
  1766 	{
       
  1767 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex" ) );
       
  1768 	
       
  1769 	_LIT( hex, "0123456789ABCDEF" );
       
  1770 	TInt size = aSource.Size();
       
  1771 	TPtr8 ptr = aDest->Des();
       
  1772 	for ( TInt ii = 0; ii < size; ii++ )
       
  1773 		{
       
  1774 		TText8 ch = aSource[ii];
       
  1775 		ptr.Append( hex()[(ch/16)&0x0f] );
       
  1776 		ptr.Append( hex()[ch&0x0f] );
       
  1777 		}
       
  1778     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex Done" ) );
       
  1779 	}
       
  1780 
       
  1781 // -----------------------------------------------------------------------------
       
  1782 // CWPAPNapdef::StrCopy
       
  1783 // String copy with lenght check.
       
  1784 // -----------------------------------------------------------------------------
       
  1785 //
       
  1786 void CWPAPNapdef::StrCopy( TDes8& aTarget, const TDesC& aSource )
       
  1787     {
       
  1788     FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy" ) );
       
  1789     
       
  1790 	TInt len = aTarget.MaxLength();
       
  1791     if( len < aSource.Length() ) 
       
  1792 	    {
       
  1793 		aTarget.Copy( aSource.Left( len ) );
       
  1794 		return;
       
  1795 	    }
       
  1796 	aTarget.Copy( aSource );
       
  1797 	
       
  1798 	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy Done" ) );
       
  1799     }
       
  1800 
       
  1801 CEapTypeElement::~CEapTypeElement()
       
  1802     {
       
  1803     delete iEAPSettings;
       
  1804     delete iCertificate;
       
  1805     }
       
  1806 
       
  1807 // -----------------------------------------------------------------------------
       
  1808 // CWPAPNapdef::UpdateLingerL
       
  1809 // 
       
  1810 // -----------------------------------------------------------------------------
       
  1811 //
       
  1812 void CWPAPNapdef::UpdateLingerL(const TUint32 aIapId)
       
  1813 {
       
  1814 		if ( iLinger && ( !iLingerFlag ) )
       
  1815 		{
       
  1816     	AddLingerL( aIapId , iLingerValue );
       
  1817 		}
       
  1818 		
       
  1819 }
       
  1820 
       
  1821 // -----------------------------------------------------------------------------
       
  1822 // CWPAPNapdef::UdateligerValueL
       
  1823 // 
       
  1824 // -----------------------------------------------------------------------------
       
  1825 //
       
  1826 void CWPAPNapdef::UdateligerValueL(CWPParameter* aLinger)
       
  1827 {
       
  1828 		TInt err(KErrNone);
       
  1829 		const TDesC& value = aLinger->Value();
       
  1830 		if( !Notalpha(value))
       
  1831 		{
       
  1832 		TLex lex( value );
       
  1833 		TUint Linger = 0;
       
  1834 		TInt lingerint;
       
  1835 		err = lex.Val( Linger, EDecimal );
       
  1836 		if( err == KErrNone )
       
  1837 		{
       
  1838 		    lingerint = Linger;
       
  1839 			if( lingerint >= 0 )
       
  1840 		    {
       
  1841 		    	iLingerValue = lingerint;
       
  1842 		    	iLingerFlag = EFalse;
       
  1843 		    }
       
  1844 		}
       
  1845 		}
       
  1846 }
       
  1847 
       
  1848 // -----------------------------------------------------------------------------
       
  1849 // CWPAPNapdef::UdateligerValueL
       
  1850 // 
       
  1851 // -----------------------------------------------------------------------------
       
  1852 //
       
  1853 TBool CWPAPNapdef::Notalpha(const TDesC& aValue)
       
  1854 {
       
  1855 	TBool NotAlpha = EFalse;
       
  1856 	TChar character;
       
  1857 	for(TInt i = 0 ; i < aValue.Length(); i++)
       
  1858 	{
       
  1859 		character = aValue[i];
       
  1860 		NotAlpha = character.IsAlpha();
       
  1861 		if(NotAlpha)
       
  1862 		break;
       
  1863 	}
       
  1864 	
       
  1865 	return NotAlpha;
       
  1866 }
       
  1867 
       
  1868 
       
  1869 // ---------------------------------------------------------------------------
       
  1870 // Adds iapID and linger interval to CentralRepository
       
  1871 // ---------------------------------------------------------------------------
       
  1872 //
       
  1873 void CWPAPNapdef::AddLingerL( const TInt aIapId, const TInt aLingerInterval )
       
  1874     {
       
  1875     TInt    err( KErrNone );
       
  1876     
       
  1877     // Open repository
       
  1878     CRepository* repository = CRepository::NewLC( KCRUidPDPContextManager );
       
  1879     
       
  1880     // Find if an entry for "iapId" already exists in CentRep 
       
  1881     RArray< TUint32 > foundKeys;
       
  1882     foundKeys.Reset();
       
  1883     
       
  1884     err = repository->FindEqL( KIapColumn,       // partial key
       
  1885                                KColumnMask,      // key mask
       
  1886                                aIapId,           // value
       
  1887                                foundKeys );      // found keys
       
  1888     
       
  1889     if ( err == KErrNone || err == KErrNotFound )
       
  1890         {
       
  1891         if ( foundKeys.Count() == 0 )
       
  1892             {
       
  1893             // Add a new entry
       
  1894             TInt arrayCount( 0 );
       
  1895             
       
  1896             // Get number of iapId&linger entries in Centrep
       
  1897             err = repository->Get( KPdpContextManagerLingerArrayCount, 
       
  1898                                    arrayCount );
       
  1899         
       
  1900             if ( err == KErrNone )
       
  1901                 {
       
  1902                 arrayCount++;
       
  1903                 
       
  1904                 err = repository->Create( ( KIapColumn | arrayCount ), aIapId ); 
       
  1905                 
       
  1906                 if ( err == KErrNone )
       
  1907                     {
       
  1908                     err = repository->Create( ( KLingerColumn | arrayCount ), 
       
  1909                                                aLingerInterval );     
       
  1910                     }
       
  1911                 
       
  1912                 if ( err == KErrNone )
       
  1913                     {
       
  1914                     // Update number of iapId&linger entries in Centrep
       
  1915                     err = repository->Set( KPdpContextManagerLingerArrayCount, 
       
  1916                                            arrayCount );
       
  1917                     }
       
  1918                 }
       
  1919             }
       
  1920         else
       
  1921             {
       
  1922             // Update existing entry on current row
       
  1923             TInt32 row = foundKeys[ 0 ] & KRowMask;
       
  1924             
       
  1925             err = repository->Set( ( KLingerColumn | row ), aLingerInterval ); 
       
  1926             }         
       
  1927         }
       
  1928         
       
  1929     foundKeys.Close();
       
  1930     CleanupStack::PopAndDestroy( repository );
       
  1931     
       
  1932     User::LeaveIfError( err );
       
  1933     
       
  1934     }
       
  1935 
       
  1936 void CWPAPNapdef::ConvertEAPStringToIds( const TDesC& aEAPString, TDes8& aExpandedId, TUint& aId)
       
  1937 	{
       
  1938     if ( aEAPString == KEAPSIM )
       
  1939 		{	
       
  1940 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapSim" ) );
       
  1941 		aExpandedId.Copy( KEapSimTypeId, KExpandedEapIdLength );		
       
  1942 		aId = EAPSettings::EEapSim;
       
  1943 		}
       
  1944     else if( aEAPString == KEAPAKA )
       
  1945         {
       
  1946   		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapAka" ) );
       
  1947 		aExpandedId.Copy( KEapAkaTypeId, KExpandedEapIdLength );	
       
  1948 		aId = EAPSettings::EEapAka;	
       
  1949         }
       
  1950     else if( aEAPString == KEAPTLS )
       
  1951         {
       
  1952 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTls" ) );
       
  1953 		aExpandedId.Copy( KEapTlsTypeId, KExpandedEapIdLength );	
       
  1954 		aId = EAPSettings::EEapTls;	
       
  1955         }
       
  1956     else if( aEAPString == KEAPPEAP )
       
  1957         {
       
  1958 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapPeap" ) );
       
  1959 		aExpandedId.Copy( KEapPeapTypeId, KExpandedEapIdLength );	
       
  1960 		aId = EAPSettings::EEapPeap;	
       
  1961         }
       
  1962     else if( aEAPString == KEAPTTLS )
       
  1963         {
       
  1964 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTtls" ) );
       
  1965 		aExpandedId.Copy( KEapTtlsTypeId, KExpandedEapIdLength );		
       
  1966 		aId = EAPSettings::EEapTtls;
       
  1967         }
       
  1968    else if( aEAPString == KEAPLEAP )
       
  1969         {
       
  1970 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapLeap" ) );
       
  1971 		aExpandedId.Copy( KEapLeapTypeId, KExpandedEapIdLength );
       
  1972 		aId = EAPSettings::EEapLeap;		
       
  1973         }                                    
       
  1974    else if( aEAPString == KEAPMSCHAPV2 )
       
  1975         {
       
  1976 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapMschapv2" ) );
       
  1977 		aExpandedId.Copy( KEapMschapv2TypeId, KExpandedEapIdLength );		
       
  1978 		aId = EAPSettings::EEapMschapv2;
       
  1979         }     
       
  1980    else if( aEAPString == KEAPGTC )
       
  1981         {
       
  1982 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapGtc" ) );
       
  1983 		aExpandedId.Copy( KEapGtcTypeId, KExpandedEapIdLength );
       
  1984 		aId = EAPSettings::EEapGtc;
       
  1985         }
       
  1986    else if( aEAPString == KEAPFAST )
       
  1987         {
       
  1988 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapFast" ) );
       
  1989 		aExpandedId.Copy( KEapFastTypeId, KExpandedEapIdLength );
       
  1990 		aId = EAPSettings::EEapFast;
       
  1991         }
       
  1992 
       
  1993     else
       
  1994         {
       
  1995 		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapNone" ) );
       
  1996 		aExpandedId.Copy( KEapNoneId, KExpandedEapIdLength );
       
  1997 		aId = EAPSettings::EEapNone;
       
  1998         }
       
  1999 
       
  2000 	}
       
  2001  
       
  2002 // ---------------------------------------------------------------------------
       
  2003 // Returns the NAP-ID
       
  2004 // ---------------------------------------------------------------------------
       
  2005 //
       
  2006 const TDesC& CWPAPNapdef::NapId()
       
  2007     {
       
  2008 	return iNapID->Value();	
       
  2009     }
       
  2010 
       
  2011 // ---------------------------------------------------------------------------
       
  2012 // Returns the bearer value
       
  2013 // ---------------------------------------------------------------------------
       
  2014 //    
       
  2015 TUint CWPAPNapdef::Bearer()
       
  2016 	{
       
  2017 	return iBearer;
       
  2018 	}
       
  2019     
       
  2020 // ---------------------------------------------------------------------------
       
  2021 // Returns the bearer value
       
  2022 // ---------------------------------------------------------------------------
       
  2023 //    
       
  2024 void CWPAPNapdef::SetCMManager( RCmManagerExt* aCm )
       
  2025 	{
       
  2026 	iCm = aCm;
       
  2027 	}
       
  2028     
       
  2029     
       
  2030     
       
  2031 //  End of File