omadm/omadmextensions/adapters/nsmldinternet/src/NSmlWLanAdapter.cpp
changeset 1 4490afcb47b1
child 2 a5fecba4b1e4
equal deleted inserted replaced
0:3ce708148e4d 1:4490afcb47b1
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   Wlan Adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <commsdat_partner.h>
       
    22 #endif
       
    23 #include "NSmlWLanAdapter.h"
       
    24 #include "NSmlWlanSettings.h"
       
    25 #include "nsmldebug.h"
       
    26 #include <commdb.h>
       
    27 #include <utf.h>
       
    28 #include <cdbstore.h>
       
    29 #include <cdbcols.h>
       
    30 #include <EapType.h>
       
    31 #include <nsmldmuri.h>
       
    32 
       
    33 
       
    34 #ifndef __WINS__
       
    35 // This lowers the unnecessary compiler warning (armv5) to remark.
       
    36 // "Warning:  #174-D: expression has no effect..." is caused by 
       
    37 // DBG_ARGS8 macro in no-debug builds.
       
    38 #pragma diag_remark 174
       
    39 #endif
       
    40 
       
    41 //-----------------------------------------------------------------------------
       
    42 // CNSmlWLanAdapter* CNSmlWLanAdapter::NewL( )
       
    43 //-----------------------------------------------------------------------------
       
    44 CNSmlWLanAdapter* CNSmlWLanAdapter::NewL( MSmlDmCallback* aDmCallback,CCommsDatabase& aDatabase )
       
    45     {
       
    46     _DBG_FILE("CNSmlWLanAdapter::NewL(): begin");
       
    47 
       
    48     CNSmlWLanAdapter* self = NewLC( aDmCallback, aDatabase );
       
    49     CleanupStack::Pop( self );
       
    50 
       
    51     _DBG_FILE("CNSmlWLanAdapter::NewL(): end");
       
    52     return self;
       
    53     }
       
    54 
       
    55 //-----------------------------------------------------------------------------
       
    56 // CNSmlWLanAdapter* CNSmlWLanAdapter::NewLC( )
       
    57 //-----------------------------------------------------------------------------
       
    58 CNSmlWLanAdapter* CNSmlWLanAdapter::NewLC( MSmlDmCallback* aDmCallback, CCommsDatabase& aDatabase )
       
    59     {
       
    60     _DBG_FILE("CNSmlWLanAdapter::NewLC(): begin");
       
    61 
       
    62     CNSmlWLanAdapter* self = new(ELeave) CNSmlWLanAdapter(aDmCallback);
       
    63     CleanupStack::PushL( self );
       
    64 
       
    65     self->iCallBack = aDmCallback;
       
    66     self->ConstructL( aDatabase );
       
    67 
       
    68     _DBG_FILE("CNSmlWLanAdapter::NewLC(): end");
       
    69     return self;
       
    70     }
       
    71 
       
    72 //-----------------------------------------------------------------------------
       
    73 // void CNSmlWLanAdapter::ConstructL( )
       
    74 // Second phase constructor
       
    75 //-----------------------------------------------------------------------------
       
    76 void CNSmlWLanAdapter::ConstructL( CCommsDatabase& aDatabase )
       
    77     {
       
    78     _DBG_FILE("CNSmlWLanAdapter::ConstructL(): begin");
       
    79 
       
    80     iWlanSettings = CWlanSettings::NewL( aDatabase );
       
    81     iBuffer = new (ELeave) CArrayFixFlat <TNSmlWepKeyBufferElement> (KNSmlWepKeyGranularity);
       
    82     iSettings = new (ELeave) TWlanSettings;
       
    83     iEAPSettings = new (ELeave) EAPSettings;
       
    84 
       
    85     _DBG_FILE("CNSmlWLanAdapter::ConstructL(): end");
       
    86     }
       
    87 
       
    88 //-----------------------------------------------------------------------------
       
    89 // CNSmlWLanAdapter::CNSmlWLanAdapter( )
       
    90 // Constructor
       
    91 //-----------------------------------------------------------------------------
       
    92 CNSmlWLanAdapter::CNSmlWLanAdapter( TAny* aEcomArguments )
       
    93     : CSmlDmAdapter(aEcomArguments)
       
    94     {
       
    95     _DBG_FILE("CNSmlWLanAdapter::CNSmlWLanAdapter(): begin");
       
    96     _DBG_FILE("CNSmlWLanAdapter::CNSmlWLanAdapter(): end");
       
    97     }
       
    98 
       
    99 //-----------------------------------------------------------------------------
       
   100 // CNSmlWLanAdapter::~CNSmlWLanAdapter( )
       
   101 // Destructor
       
   102 //-----------------------------------------------------------------------------
       
   103 CNSmlWLanAdapter::~CNSmlWLanAdapter( )
       
   104     {
       
   105     _DBG_FILE("CNSmlWLanAdapter::~CNSmlWLanAdapter(): begin");
       
   106 
       
   107 	if ( iBuffer )
       
   108 		{
       
   109 		
       
   110 	    for( TInt index=0; index<iBuffer->Count(); index++ )
       
   111 	        {
       
   112 	        delete iBuffer->At(index).iUri;
       
   113 	        delete iBuffer->At(index).iData;
       
   114 
       
   115 	        iBuffer->Delete(index);
       
   116 	        }
       
   117 
       
   118 	    iBuffer->Reset();
       
   119 	    delete iBuffer;
       
   120 	    
       
   121 		}
       
   122     delete iWlanSettings;
       
   123     delete iSettings;
       
   124 
       
   125     TRAP_IGNORE( DeleteEAPStructL() );
       
   126     
       
   127     for ( TInt i = 0 ; i < iEAPBuffer.Count() ; i++ )
       
   128     	{
       
   129     	iEAPBuffer[i]->iStatusRefArray.Close();
       
   130     	iEAPBuffer[i]->iEAPSettings->iEncapsulatedEAPTypes.Close();
       
   131     	iEAPBuffer[i]->iEAPSettings->iCipherSuites.Close();    	
       
   132     	delete iEAPBuffer[i]->iEAPSettings;
       
   133     	iEAPBuffer[i]->iEAPSettings = NULL;
       
   134     	}
       
   135     iEAPBuffer.ResetAndDestroy(); 
       
   136     
       
   137     TInt count = iSecondaryBuffer.Count();
       
   138     for( TInt index=0; index<count; index++ )
       
   139         {
       
   140         delete iSecondaryBuffer[index];
       
   141         }
       
   142 
       
   143     iSecondaryBuffer.Reset();
       
   144 
       
   145 
       
   146     _DBG_FILE("CNSmlWLanAdapter::~CNSmlWLanAdapter(): end");
       
   147     }
       
   148 
       
   149 
       
   150 //-----------------------------------------------------------------------------
       
   151 // CNSmlWLanAdapter* CNSmlWLanAdapter::DDFVersionL( CBufBase& aDDFVersion )
       
   152 //-----------------------------------------------------------------------------
       
   153 void CNSmlWLanAdapter::DDFVersionL( CBufBase& aDDFVersion )
       
   154     {
       
   155     _DBG_FILE("CNSmlWLanAdapter::DDFVersionL(): begin");
       
   156 
       
   157     aDDFVersion.InsertL( 0, KNSmlWLanAdapterDDFversion );
       
   158 
       
   159     _DBG_FILE("CNSmlWLanAdapter::DDFVersionL(): end");
       
   160     }
       
   161 
       
   162 //-----------------------------------------------------------------------------
       
   163 // CNSmlWLanAdapter* CNSmlWLanAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   164 //-----------------------------------------------------------------------------
       
   165 void CNSmlWLanAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   166     {
       
   167     _DBG_FILE("CNSmlWLanAdapter::DDFStructureL(): begin");
       
   168 
       
   169     TSmlDmAccessTypes *aclTypes = new (ELeave) TSmlDmAccessTypes();
       
   170     CleanupStack::PushL(aclTypes);
       
   171 //
       
   172 // Set Get as acceptable operations
       
   173 //
       
   174     aclTypes->SetGet();
       
   175     aclTypes->SetAdd(); // 041208 Added
       
   176     aclTypes->SetDelete( );
       
   177     aclTypes->SetReplace( );
       
   178 
       
   179     TSmlDmAccessTypes accessTypesAll;
       
   180     accessTypesAll.SetGet( );
       
   181     accessTypesAll.SetDelete( );
       
   182     accessTypesAll.SetAdd( );
       
   183     accessTypesAll.SetReplace( );
       
   184 
       
   185     TSmlDmAccessTypes accessTypesNoDelete;
       
   186     accessTypesNoDelete.SetGet( );
       
   187     accessTypesNoDelete.SetAdd( );
       
   188     accessTypesNoDelete.SetReplace( );
       
   189 
       
   190     TSmlDmAccessTypes accessTypesGetAdd;
       
   191     accessTypesGetAdd.SetGet( );
       
   192     accessTypesGetAdd.SetAdd(); 
       
   193     
       
   194     TSmlDmAccessTypes accessTypesGetAddDel;
       
   195     accessTypesGetAddDel.SetGet();     
       
   196     accessTypesGetAddDel.SetAdd();
       
   197     accessTypesGetAddDel.SetDelete();
       
   198     //WLAN
       
   199     MSmlDmDDFObject& rootNode = aDDF.AddChildObjectL( KNSmlWLanNodeName );
       
   200     FillNodeInfoL( rootNode,
       
   201     		   accessTypesGetAdd,
       
   202                MSmlDmDDFObject::EZeroOrOne,
       
   203                MSmlDmDDFObject::EDynamic,
       
   204                MSmlDmDDFObject::ENode,
       
   205                KNSmlEmpty );
       
   206 
       
   207     //WLAN/<x>
       
   208     MSmlDmDDFObject& wlanNode = rootNode.AddChildObjectGroupL( );
       
   209     FillNodeInfoL( wlanNode,
       
   210     		   accessTypesGetAddDel,
       
   211                MSmlDmDDFObject::EOne,
       
   212                MSmlDmDDFObject::EDynamic,
       
   213                MSmlDmDDFObject::ENode,
       
   214                KNSmlEmpty );
       
   215 
       
   216     //WLAN/<x>/SSID
       
   217     MSmlDmDDFObject& ssid = wlanNode.AddChildObjectL( KNSmlWLanSsid );
       
   218     FillNodeInfoL( ssid,
       
   219                accessTypesNoDelete,
       
   220                MSmlDmDDFObject::EZeroOrOne,
       
   221                MSmlDmDDFObject::EDynamic,
       
   222                MSmlDmDDFObject::EChr,
       
   223                KNSmlEmpty );
       
   224 
       
   225     //WLAN/<x>/UsedSSID
       
   226     MSmlDmDDFObject& usedSsid = wlanNode.AddChildObjectL( KNSmlWLanUsedSsid );
       
   227     FillNodeInfoL( usedSsid,
       
   228                accessTypesNoDelete,
       
   229                MSmlDmDDFObject::EZeroOrOne,
       
   230                MSmlDmDDFObject::EDynamic,
       
   231                MSmlDmDDFObject::EChr,
       
   232                KNSmlEmpty );
       
   233                
       
   234     //WLAN/<x>/SSIDHidden
       
   235     MSmlDmDDFObject& ssidHidden = wlanNode.AddChildObjectL( KNSmlWLanSsidHidden );
       
   236     FillNodeInfoL( ssidHidden,
       
   237                accessTypesNoDelete,
       
   238                MSmlDmDDFObject::EZeroOrOne,
       
   239                MSmlDmDDFObject::EDynamic,
       
   240                MSmlDmDDFObject::EBool,
       
   241                KNSmlEmpty );
       
   242 
       
   243     //WLAN/<x>/NetworkMode
       
   244     MSmlDmDDFObject& networkMode = wlanNode.AddChildObjectL( KNSmlWLanNetworkMode );
       
   245     FillNodeInfoL( networkMode,
       
   246                accessTypesNoDelete,
       
   247                MSmlDmDDFObject::EZeroOrOne,
       
   248                MSmlDmDDFObject::EDynamic,
       
   249                MSmlDmDDFObject::EChr,
       
   250                KNSmlEmpty );               
       
   251 
       
   252     //WLAN/<x>/SecurityMode
       
   253     MSmlDmDDFObject& securityMode = wlanNode.AddChildObjectL( KNSmlWLanSecurityMode );
       
   254     FillNodeInfoL( securityMode,
       
   255                accessTypesNoDelete,
       
   256                MSmlDmDDFObject::EZeroOrOne,
       
   257                MSmlDmDDFObject::EDynamic,
       
   258                MSmlDmDDFObject::EChr,
       
   259                KNSmlEmpty );               
       
   260 
       
   261     //WLAN/<x>/UseWPAPSK
       
   262     MSmlDmDDFObject& useWPAPSK = wlanNode.AddChildObjectL( KNSmlWLanUseWPAPSK );
       
   263     FillNodeInfoL( useWPAPSK,
       
   264                accessTypesNoDelete,
       
   265                MSmlDmDDFObject::EZeroOrOne,
       
   266                MSmlDmDDFObject::EDynamic,
       
   267                MSmlDmDDFObject::EBool,
       
   268                KNSmlEmpty );
       
   269 
       
   270     //WLAN/<x>/WPAPreSharedKey
       
   271     MSmlDmDDFObject& wpaPreSharedKey = wlanNode.AddChildObjectL( KNSmlWLanWpaPreSharedKey );
       
   272     FillNodeInfoL( wpaPreSharedKey,
       
   273                accessTypesNoDelete,
       
   274                MSmlDmDDFObject::EZeroOrOne,
       
   275                MSmlDmDDFObject::EDynamic,
       
   276                MSmlDmDDFObject::EBin,
       
   277                KNSmlEmpty );               
       
   278 
       
   279     //WLAN/<x>/WLANEAPList
       
   280     MSmlDmDDFObject& wlanEapList = wlanNode.AddChildObjectL( KNSmlWLanEapList );
       
   281     FillNodeInfoL( wlanEapList,
       
   282                accessTypesNoDelete,
       
   283                MSmlDmDDFObject::EZeroOrOne,
       
   284                MSmlDmDDFObject::EDynamic,
       
   285                MSmlDmDDFObject::EChr,
       
   286                KNSmlEmpty );                       
       
   287 
       
   288     //WLAN/<x>/WEPKeyIndex
       
   289     MSmlDmDDFObject& wepKeyIndex = wlanNode.AddChildObjectL( KNSmlWLanWepIndex );
       
   290     FillNodeInfoL( wepKeyIndex,
       
   291                accessTypesNoDelete,
       
   292                MSmlDmDDFObject::EZeroOrOne,
       
   293                MSmlDmDDFObject::EDynamic,
       
   294                MSmlDmDDFObject::EInt,
       
   295                KNSmlEmpty );                       
       
   296                
       
   297     //WLAN/<x>/WEPAuthMode
       
   298     MSmlDmDDFObject& wlanWepAuthMode = wlanNode.AddChildObjectL( KNSmlWLanAuthMode );
       
   299     FillNodeInfoL( wlanWepAuthMode,
       
   300                accessTypesNoDelete,
       
   301                MSmlDmDDFObject::EZeroOrOne,
       
   302                MSmlDmDDFObject::EDynamic,
       
   303                MSmlDmDDFObject::EInt,
       
   304                KNSmlEmpty );                       
       
   305 
       
   306     //WLAN/<x>/WEPKey/
       
   307     MSmlDmDDFObject& wepKeyRoot = wlanNode.AddChildObjectL( KNSmlWLanWepKey );
       
   308     FillNodeInfoL( wepKeyRoot,
       
   309                accessTypesNoDelete,
       
   310                MSmlDmDDFObject::EZeroOrOne,
       
   311                MSmlDmDDFObject::EDynamic,
       
   312                MSmlDmDDFObject::ENode,
       
   313                KNSmlEmpty );               
       
   314 
       
   315     //WLAN/<x>/WEPKey/<x>
       
   316     MSmlDmDDFObject& wepKey = wepKeyRoot.AddChildObjectGroupL( );
       
   317     FillNodeInfoL( wepKey,
       
   318     		   accessTypesGetAdd,
       
   319                MSmlDmDDFObject::EOneOrN,
       
   320                MSmlDmDDFObject::EDynamic,
       
   321                MSmlDmDDFObject::ENode,
       
   322                KNSmlEmpty );               
       
   323 
       
   324     //WLAN/<x>/WEPKey/<x>/WEPKeyID
       
   325     MSmlDmDDFObject& wepKeyId = wepKey.AddChildObjectL( KNSmlWLanWepKeyId );
       
   326     FillNodeInfoL( wepKeyId,
       
   327                accessTypesNoDelete,
       
   328                MSmlDmDDFObject::EOne,
       
   329                MSmlDmDDFObject::EDynamic,
       
   330                MSmlDmDDFObject::EInt,
       
   331                KNSmlEmpty );                           
       
   332 
       
   333     //WLAN/<x>/WEPKey/<x>/Data
       
   334     MSmlDmDDFObject& data = wepKey.AddChildObjectL( KNSmlWLanWepKeyData );
       
   335     FillNodeInfoL( data,
       
   336                accessTypesNoDelete,
       
   337                MSmlDmDDFObject::EOne,
       
   338                MSmlDmDDFObject::EDynamic,
       
   339                MSmlDmDDFObject::EBin,
       
   340                KNSmlEmpty );         
       
   341 
       
   342 
       
   343     //WLAN/<x>/SecondarySSID/
       
   344     MSmlDmDDFObject& secondarySSidRoot = wlanNode.AddChildObjectL( KNSmlWLanSecSsid );
       
   345     FillNodeInfoL( secondarySSidRoot,
       
   346                accessTypesGetAdd,
       
   347                MSmlDmDDFObject::EZeroOrOne,
       
   348                MSmlDmDDFObject::EDynamic,
       
   349                MSmlDmDDFObject::ENode,
       
   350                KNSmlEmpty );               
       
   351 
       
   352     //WLAN/<x>/SecondarySSID/<x>
       
   353     MSmlDmDDFObject& secondarySSid = secondarySSidRoot.AddChildObjectGroupL( );
       
   354     FillNodeInfoL( secondarySSid,
       
   355                accessTypesGetAddDel,
       
   356                MSmlDmDDFObject::EOneOrN,
       
   357                MSmlDmDDFObject::EDynamic,
       
   358                MSmlDmDDFObject::ENode,
       
   359                KNSmlEmpty );               
       
   360 
       
   361     //WLAN/<x>/SecondarySSID/<x>/SSID
       
   362     MSmlDmDDFObject& secSsidId = secondarySSid.AddChildObjectL( KNSmlWLanSsid );
       
   363     FillNodeInfoL( secSsidId,
       
   364                accessTypesNoDelete,
       
   365                MSmlDmDDFObject::EOne,
       
   366                MSmlDmDDFObject::EDynamic,
       
   367                MSmlDmDDFObject::EChr,
       
   368                KNSmlEmpty );                           
       
   369 
       
   370     //WLAN/<x>/SecondarySSID/<x>/UsedSSID
       
   371     MSmlDmDDFObject& secUsedSsidId = secondarySSid.AddChildObjectL( KNSmlWLanUsedSsid );
       
   372     FillNodeInfoL( secUsedSsidId,
       
   373                accessTypesNoDelete,
       
   374                MSmlDmDDFObject::EZeroOrOne,
       
   375                MSmlDmDDFObject::EDynamic,
       
   376                MSmlDmDDFObject::EChr,
       
   377                KNSmlEmpty );                           
       
   378 
       
   379     //WLAN/<x>/EAP/
       
   380     MSmlDmDDFObject& eapRoot = wlanNode.AddChildObjectL( KNSmlWLanEap );
       
   381     FillNodeInfoL( eapRoot,
       
   382                accessTypesGetAdd,
       
   383                MSmlDmDDFObject::EZeroOrOne,
       
   384                MSmlDmDDFObject::EDynamic,
       
   385                MSmlDmDDFObject::ENode,
       
   386                KNSmlEmpty );               
       
   387 
       
   388     //WLAN/<x>/EAP/<x>
       
   389     MSmlDmDDFObject& eap = eapRoot.AddChildObjectGroupL( );
       
   390     FillNodeInfoL( eap,
       
   391                accessTypesGetAdd,
       
   392                MSmlDmDDFObject::EOneOrN,
       
   393                MSmlDmDDFObject::EDynamic,
       
   394                MSmlDmDDFObject::ENode,
       
   395                KNSmlEmpty );               
       
   396 
       
   397     //WLAN/<x>/EAP/<x>/EAPType
       
   398     MSmlDmDDFObject& eapType = eap.AddChildObjectL( KNSmlWLanEapType );
       
   399     FillNodeInfoL( eapType,
       
   400                accessTypesNoDelete,
       
   401                MSmlDmDDFObject::EOne,
       
   402                MSmlDmDDFObject::EDynamic,
       
   403                MSmlDmDDFObject::EChr,
       
   404                KNSmlEmpty );                           
       
   405 
       
   406     //WLAN/<x>/EAP/<x>/Username
       
   407     MSmlDmDDFObject& eapUsername = eap.AddChildObjectL( KNSmlWLanUsername );
       
   408     FillNodeInfoL( eapUsername,
       
   409                accessTypesNoDelete,
       
   410                MSmlDmDDFObject::EZeroOrOne,
       
   411                MSmlDmDDFObject::EDynamic,
       
   412                MSmlDmDDFObject::EChr,
       
   413                KNSmlEmpty );                           
       
   414 
       
   415     //WLAN/<x>/EAP/<x>/Password
       
   416     MSmlDmDDFObject& eapPassword = eap.AddChildObjectL( KNSmlWLanPassword );
       
   417     FillNodeInfoL( eapPassword,
       
   418                accessTypesNoDelete,
       
   419                MSmlDmDDFObject::EZeroOrOne,
       
   420                MSmlDmDDFObject::EDynamic,
       
   421                MSmlDmDDFObject::EChr,
       
   422                KNSmlEmpty );                           
       
   423 
       
   424     //WLAN/<x>/EAP/<x>/Realm
       
   425     MSmlDmDDFObject& eapRealm = eap.AddChildObjectL( KNSmlWLanRealm );
       
   426     FillNodeInfoL( eapRealm,
       
   427                accessTypesNoDelete,
       
   428                MSmlDmDDFObject::EZeroOrOne,
       
   429                MSmlDmDDFObject::EDynamic,
       
   430                MSmlDmDDFObject::EChr,
       
   431                KNSmlEmpty );                           
       
   432 
       
   433     //WLAN/<x>/EAP/<x>/UsePseudonym
       
   434     MSmlDmDDFObject& eapPseudo = eap.AddChildObjectL( KNSmlWLanUsePseudonym );
       
   435     FillNodeInfoL( eapPseudo,
       
   436                accessTypesNoDelete,
       
   437                MSmlDmDDFObject::EZeroOrOne,
       
   438                MSmlDmDDFObject::EDynamic,
       
   439                MSmlDmDDFObject::EBool,
       
   440                KNSmlEmpty );                           
       
   441 
       
   442     //WLAN/<x>/EAP/<x>/Encapsulation
       
   443     // Encapsulation is not supported using this parameter. It is done
       
   444     // with */EAP/EAPIdxxx-yyy/* where xxx is the encapsulated and yyy the encapsulating method.
       
   445     /*MSmlDmDDFObject& eapEncapsulation = eap.AddChildObjectL( KNSmlWLanEncapsulation );
       
   446     FillNodeInfoL( eapEncapsulation,
       
   447                accessTypesNoDelete,
       
   448                MSmlDmDDFObject::EZeroOrOne,
       
   449                MSmlDmDDFObject::EDynamic,
       
   450                MSmlDmDDFObject::EChr,
       
   451                KNSmlEmpty );                           */
       
   452 
       
   453     //WLAN/<x>/EAP/<x>/VerifyCertRealm
       
   454     MSmlDmDDFObject& eapVerifyCertRealm = eap.AddChildObjectL( KNSmlWLanVerifyCertRealm );
       
   455     FillNodeInfoL( eapVerifyCertRealm,
       
   456                accessTypesNoDelete,
       
   457                MSmlDmDDFObject::EZeroOrOne,
       
   458                MSmlDmDDFObject::EDynamic,
       
   459                MSmlDmDDFObject::EBool,
       
   460                KNSmlEmpty );                           
       
   461 
       
   462     //WLAN/<x>/EAP/<x>/RequireClientAuthentication
       
   463     MSmlDmDDFObject& eapRequireClientAuthentication = eap.AddChildObjectL( KNSmlWLanRequireClientAuthentication );
       
   464     FillNodeInfoL( eapRequireClientAuthentication,
       
   465                accessTypesNoDelete,
       
   466                MSmlDmDDFObject::EZeroOrOne,
       
   467                MSmlDmDDFObject::EDynamic,
       
   468                MSmlDmDDFObject::EBool,
       
   469                KNSmlEmpty );                           
       
   470 
       
   471     //WLAN/<x>/EAP/<x>/SessionValidityTime
       
   472     MSmlDmDDFObject& eapSessionValidityTime = eap.AddChildObjectL( KNSmlWLanSessionValidityTime );
       
   473     FillNodeInfoL( eapSessionValidityTime,
       
   474                accessTypesNoDelete,
       
   475                MSmlDmDDFObject::EZeroOrOne,
       
   476                MSmlDmDDFObject::EDynamic,
       
   477                MSmlDmDDFObject::EChr,
       
   478                KNSmlEmpty );                           
       
   479 
       
   480     //WLAN/<x>/EAP/<x>/CipherSuite
       
   481     MSmlDmDDFObject& eapCipherSuite = eap.AddChildObjectL( KNSmlWLanCipherSuite );
       
   482     FillNodeInfoL( eapCipherSuite,
       
   483                accessTypesNoDelete,
       
   484                MSmlDmDDFObject::EZeroOrOne,
       
   485                MSmlDmDDFObject::EDynamic,
       
   486                MSmlDmDDFObject::EChr,
       
   487                KNSmlEmpty );                           
       
   488 
       
   489     //WLAN/<x>/EAP/<x>/AllowPEAPv0
       
   490     MSmlDmDDFObject& eapAllowPEAPv0 = eap.AddChildObjectL( KNSmlWLanAllowPEAPv0 );
       
   491     FillNodeInfoL( eapAllowPEAPv0,
       
   492                accessTypesNoDelete,
       
   493                MSmlDmDDFObject::EZeroOrOne,
       
   494                MSmlDmDDFObject::EDynamic,
       
   495                MSmlDmDDFObject::EBool,
       
   496                KNSmlEmpty );                           
       
   497 
       
   498     //WLAN/<x>/EAP/<x>/AllowPEAPv1
       
   499     MSmlDmDDFObject& eapAllowPEAPv1 = eap.AddChildObjectL( KNSmlWLanAllowPEAPv1 );
       
   500     FillNodeInfoL( eapAllowPEAPv1,
       
   501                accessTypesNoDelete,
       
   502                MSmlDmDDFObject::EZeroOrOne,
       
   503                MSmlDmDDFObject::EDynamic,
       
   504                MSmlDmDDFObject::EBool,
       
   505                KNSmlEmpty );                           
       
   506 
       
   507     //WLAN/<x>/EAP/<x>/AllowPEAPv2
       
   508     MSmlDmDDFObject& eapAllowPEAPv2 = eap.AddChildObjectL( KNSmlWLanAllowPEAPv2 );
       
   509     FillNodeInfoL( eapAllowPEAPv2,
       
   510                accessTypesNoDelete,
       
   511                MSmlDmDDFObject::EZeroOrOne,
       
   512                MSmlDmDDFObject::EDynamic,
       
   513                MSmlDmDDFObject::EBool,
       
   514                KNSmlEmpty );  
       
   515                
       
   516 #ifdef FF_WLAN_EXTENSIONS 
       
   517 
       
   518     //WLAN/<x>/EAP/<x>/AuthProvModeAllowed
       
   519     MSmlDmDDFObject& authProvMode = eap.AddChildObjectL( KNSmlWLanAuthProvMode );
       
   520     FillNodeInfoL( authProvMode,
       
   521                accessTypesNoDelete,
       
   522                MSmlDmDDFObject::EZeroOrOne,
       
   523                MSmlDmDDFObject::EDynamic,
       
   524                MSmlDmDDFObject::EBool,
       
   525                KNSmlEmpty ); 
       
   526                              
       
   527     //WLAN/<x>/EAP/<x>/UnauthProvModeAllowed
       
   528     MSmlDmDDFObject& unauthProvMode = eap.AddChildObjectL( KNSmlWLanUnauthProvMode );
       
   529     FillNodeInfoL( unauthProvMode,
       
   530                accessTypesNoDelete,
       
   531                MSmlDmDDFObject::EZeroOrOne,
       
   532                MSmlDmDDFObject::EDynamic,
       
   533                MSmlDmDDFObject::EBool,
       
   534                KNSmlEmpty ); 
       
   535                                  
       
   536     //WLAN/<x>/EAP/<x>/PACGroupReference
       
   537     MSmlDmDDFObject& pacGroupRef = eap.AddChildObjectL( KNSmlWLanPACGroupRef );
       
   538     FillNodeInfoL( pacGroupRef,
       
   539                accessTypesNoDelete,
       
   540                MSmlDmDDFObject::EZeroOrOne,
       
   541                MSmlDmDDFObject::EDynamic,
       
   542                MSmlDmDDFObject::EChr,
       
   543                KNSmlEmpty );             
       
   544                
       
   545 	//WLAN/<x>/EAP/<x>/WarnADHPNoPAC
       
   546     MSmlDmDDFObject& warnADHPNoPAC = eap.AddChildObjectL( KNSmlWLanWarnADHPNoPAC );
       
   547     FillNodeInfoL( warnADHPNoPAC,
       
   548                accessTypesNoDelete,
       
   549                MSmlDmDDFObject::EZeroOrOne,
       
   550                MSmlDmDDFObject::EDynamic,
       
   551                MSmlDmDDFObject::EBool,
       
   552                KNSmlEmpty ); 
       
   553                
       
   554  	//WLAN/<x>/EAP/<x>/WarnADHPNoMatchingPAC
       
   555     MSmlDmDDFObject& warnADHPNoMatchingPAC = eap.AddChildObjectL( KNSmlWLanWarnADHPNoMatchPAC );
       
   556     FillNodeInfoL( warnADHPNoMatchingPAC,
       
   557                accessTypesNoDelete,
       
   558                MSmlDmDDFObject::EZeroOrOne,
       
   559                MSmlDmDDFObject::EDynamic,
       
   560                MSmlDmDDFObject::EBool,
       
   561                KNSmlEmpty ); 
       
   562               
       
   563     //WLAN/<x>/EAP/<x>/WarnNotDefaultServer
       
   564     MSmlDmDDFObject& warnNoDefServ = eap.AddChildObjectL( KNSmlWLanWarnNotDefaultSrv );
       
   565     FillNodeInfoL( warnNoDefServ,
       
   566                accessTypesNoDelete,
       
   567                MSmlDmDDFObject::EZeroOrOne,
       
   568                MSmlDmDDFObject::EDynamic,
       
   569                MSmlDmDDFObject::EBool,
       
   570                KNSmlEmpty ); 
       
   571                
       
   572 #endif           
       
   573                                                  
       
   574 
       
   575     //WLAN/<x>/EAP/<x>/Certificate
       
   576     MSmlDmDDFObject& eapCertificateRoot = eap.AddChildObjectL( KNSmlWLanCertificate );
       
   577     FillNodeInfoL( eapCertificateRoot,
       
   578                accessTypesGetAdd,
       
   579                MSmlDmDDFObject::EZeroOrOne,
       
   580                MSmlDmDDFObject::EDynamic,
       
   581                MSmlDmDDFObject::ENode,
       
   582                KNSmlEmpty );                           
       
   583 
       
   584     //WLAN/<x>/EAP/<x>/Certificate/<x>
       
   585     MSmlDmDDFObject& eapCertificate = eapCertificateRoot.AddChildObjectGroupL( );
       
   586     FillNodeInfoL( eapCertificate,
       
   587                accessTypesGetAdd,
       
   588                MSmlDmDDFObject::EOneOrMore,
       
   589                MSmlDmDDFObject::EDynamic,
       
   590                MSmlDmDDFObject::ENode,
       
   591                KNSmlEmpty );               
       
   592 
       
   593     //WLAN/<x>/EAP/<x>/Certificate/<x>/IssuerName
       
   594     MSmlDmDDFObject& eapIssuerName = eapCertificate.AddChildObjectL( KNSmlWLanIssuerName );
       
   595     FillNodeInfoL( eapIssuerName,
       
   596                accessTypesNoDelete,
       
   597                MSmlDmDDFObject::EZeroOrOne,
       
   598                MSmlDmDDFObject::EDynamic,
       
   599                MSmlDmDDFObject::EChr,
       
   600                KNSmlEmpty );                           
       
   601 
       
   602     //WLAN/<x>/EAP/<x>/Certificate/<x>/SubjectName
       
   603     MSmlDmDDFObject& eapSubjectName = eapCertificate.AddChildObjectL( KNSmlWLanSubjectName );
       
   604     FillNodeInfoL( eapSubjectName,
       
   605                accessTypesNoDelete,
       
   606                MSmlDmDDFObject::EZeroOrOne,
       
   607                MSmlDmDDFObject::EDynamic,
       
   608                MSmlDmDDFObject::EChr,
       
   609                KNSmlEmpty );                           
       
   610 
       
   611     //WLAN/<x>/EAP/<x>/Certificate/<x>/CertType
       
   612     MSmlDmDDFObject& eapCertType = eapCertificate.AddChildObjectL( KNSmlWLanCertType );
       
   613     FillNodeInfoL( eapCertType,
       
   614                accessTypesNoDelete,
       
   615                MSmlDmDDFObject::EOne,
       
   616                MSmlDmDDFObject::EDynamic,
       
   617                MSmlDmDDFObject::EChr,
       
   618                KNSmlEmpty );                           
       
   619 
       
   620     //WLAN/<x>/EAP/<x>/Certificate/<x>/SerialNumber
       
   621     MSmlDmDDFObject& eapSerialNumber = eapCertificate.AddChildObjectL( KNSmlWLanSerialNumber );
       
   622     FillNodeInfoL( eapSerialNumber,
       
   623                accessTypesNoDelete,
       
   624                MSmlDmDDFObject::EZeroOrOne,
       
   625                MSmlDmDDFObject::EDynamic,
       
   626                MSmlDmDDFObject::EChr,
       
   627                KNSmlEmpty );                           
       
   628 
       
   629     //WLAN/<x>/EAP/<x>/Certificate/<x>/SubjectKeyId
       
   630     MSmlDmDDFObject& eapSubjectKeyId = eapCertificate.AddChildObjectL( KNSmlWLanSubjectKeyId );
       
   631     FillNodeInfoL( eapSubjectKeyId,
       
   632                accessTypesNoDelete,
       
   633                MSmlDmDDFObject::EOne,
       
   634                MSmlDmDDFObject::EDynamic,
       
   635                MSmlDmDDFObject::EChr,
       
   636                KNSmlEmpty );                           
       
   637 
       
   638     //WLAN/<x>/EAP/<x>/Certificate/<x>/Fingerprint
       
   639     MSmlDmDDFObject& eapFingerprint = eapCertificate.AddChildObjectL( KNSmlWLanFingerprint );
       
   640     FillNodeInfoL( eapFingerprint,
       
   641                accessTypesNoDelete,
       
   642                MSmlDmDDFObject::EZeroOrOne,
       
   643                MSmlDmDDFObject::EDynamic,
       
   644                MSmlDmDDFObject::EChr,
       
   645                KNSmlEmpty );                           
       
   646 
       
   647 	CleanupStack::PopAndDestroy(); //aclTypes
       
   648 
       
   649     _DBG_FILE("CNSmlWLanAdapter::DDFStructureL(): end");
       
   650     }
       
   651 
       
   652 //-----------------------------------------------------------------------------
       
   653 // CNSmlWLanAdapter* CNSmlWLanAdapter::AddLeafObjectL( const TDesC& aURI,const 
       
   654 // TDesC& aParentLUID, const TDesC8& aObject, const TDesC& aType, 
       
   655 // const TInt aStatusRef )
       
   656 //-----------------------------------------------------------------------------
       
   657 void CNSmlWLanAdapter::AddLeafObjectL( const TDesC8& aURI,
       
   658                                        const TDesC8& aParentLUID, 
       
   659                                        const TDesC8& aObject, 
       
   660                                        const TDesC8& /*aType*/, 
       
   661                                        const TInt aStatusRef )
       
   662     {
       
   663     DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL - <%S> <%S> <%S>"), &aURI, &aParentLUID, &aObject );
       
   664 
       
   665     TInt uriSegs = NumOfUriSegs( aURI );
       
   666     TInt luid = GetIdFromLuid( aParentLUID );
       
   667     TInt err(KErrNone);
       
   668     TPtrC8 lastUriSeg = GetLastUriSeg( aURI );
       
   669     
       
   670     TInt eapIndex(0);
       
   671     
       
   672     TInt eapId = GetEAPIdFromUri( aURI );
       
   673     if (eapId == KErrNotFound)
       
   674         {
       
   675         _DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): Non-EAP setting.");
       
   676         err = iWlanSettings->GetWlanSettings( luid, *iSettings );    
       
   677         }
       
   678     else
       
   679        	{
       
   680        	_DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): EAP setting.");       	
       
   681 		TInt encapsEapId = GetEncapsEAPIdFromUri( aURI );
       
   682         if ( encapsEapId == KErrNotFound )
       
   683         	{
       
   684         	_DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): Does not have encapsulation id xx-xx.");
       
   685         	encapsEapId = EAPSettings::EEapNone;
       
   686         	}
       
   687         TInt i(0);
       
   688     	// This is EAP addition. Check if the buffer for this EAP already exists
       
   689     	for ( i = 0 ; i < iEAPBuffer.Count() ; i++ )
       
   690     		{
       
   691     		if ( eapId == iEAPBuffer[i]->iEAPSettings->iEAPType
       
   692     			&& encapsEapId == iEAPBuffer[i]->iEncapsulatingEAPId )
       
   693     			{
       
   694     			// The correct buffer was found.     			
       
   695     			_DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): Found existing buffer.");
       
   696 				eapIndex = i;
       
   697 				break;                    			
       
   698     			}
       
   699     		}
       
   700     	if ( i == iEAPBuffer.Count() )
       
   701     		{
       
   702     		DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL(): No buffer found. Create new: <%d>-<%d>"), eapId, encapsEapId );
       
   703 			// Buffer was not found. Create new.
       
   704 			TInt WLANServiceId = GetServiceIdFromUriL ( aURI );
       
   705     
       
   706 	        if ( WLANServiceId == KErrNotFound )
       
   707 	        	{
       
   708 	        	_DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): Could not find WLAN service ID from URI.");
       
   709 	        	iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   710 	        	return;
       
   711 	        	}
       
   712 	        
       
   713 	        TNSmlEAPBufferElement* buffer = new (ELeave) TNSmlEAPBufferElement;	        
       
   714 	        CleanupStack::PushL( buffer );
       
   715 	        
       
   716 	        buffer->iEAPSettings = new (ELeave) EAPSettings;	        
       
   717 	        CleanupStack::PushL( buffer->iEAPSettings );
       
   718 	        
       
   719 	        buffer->iEAPSettings->iEAPType = static_cast<EAPSettings::TEapType> ( eapId );
       
   720 	        buffer->iWLANServiceId = WLANServiceId;
       
   721 	        buffer->iEncapsulatingEAPId = static_cast<EAPSettings::TEapType>( encapsEapId );
       
   722 	        iEAPBuffer.AppendL(buffer);
       
   723 	        
       
   724 	        CleanupStack::Pop( buffer->iEAPSettings );
       
   725 	        CleanupStack::Pop( buffer );
       
   726 	        
       
   727 	        eapIndex = iEAPBuffer.Count() - 1;			
       
   728    			}
       
   729        	}
       
   730     if( err != KErrNone )
       
   731         {
       
   732         DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"), err );
       
   733         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   734         return;
       
   735         }
       
   736 
       
   737     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*/*") ) != KErrNotFound && uriSegs==9 )
       
   738         {
       
   739         TInt wepKeyId = GetWepKeyIdFromLuid( aParentLUID );
       
   740 
       
   741         if( wepKeyId != KErrNotFound )
       
   742             {
       
   743             if( lastUriSeg.Match( KNSmlWLanWepKeyData ) != KErrNotFound  )
       
   744                 {
       
   745                 switch( wepKeyId )
       
   746                     {
       
   747                 case 1:
       
   748                     iSettings->WepKey1 = aObject;
       
   749                     break;
       
   750                 case 2:
       
   751                     iSettings->WepKey2 = aObject;
       
   752                     break;
       
   753                 case 3:
       
   754                     iSettings->WepKey3 = aObject;
       
   755                     break;
       
   756                 case 4:
       
   757                     iSettings->WepKey4 = aObject;
       
   758                     break;
       
   759                 default:
       
   760                     iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   761                     return;
       
   762                     }
       
   763                 }
       
   764             else if( lastUriSeg.Match( KNSmlWLanWepKeyId ) != KErrNotFound )
       
   765                 {
       
   766                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
   767                 return;
       
   768                 }
       
   769             else
       
   770                 {
       
   771                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   772                 return;
       
   773                 }
       
   774             }
       
   775 
       
   776         else
       
   777             {
       
   778             TInt index = -1;
       
   779 
       
   780             for( TInt i=0; i<iBuffer->Count(); i++ )
       
   781                 {
       
   782                 if( aURI.Find( iBuffer->At(i).iUri->Des() ) != KErrNotFound )
       
   783                     {
       
   784                     index = i;
       
   785                     break;
       
   786                     }
       
   787                 }
       
   788             if( index < 0 )
       
   789                 {
       
   790                 wepKeyId = GetWepKeyIdFromUri( aURI );
       
   791 
       
   792                 TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
       
   793                 addLUID.AppendNum( wepKeyId );
       
   794                 addLUID.AppendNumFixedWidth( luid, EDecimal, 3 );
       
   795 
       
   796                 DBG_ARGS8(_S8("WLanAdapter::AddleafObject - mapping uri: <%S> to luid: <%S>"), &aURI, &addLUID );
       
   797                 DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID );
       
   798                 iCallBack->SetMappingL(aURI, addLUID);
       
   799                 if( lastUriSeg.Match( KNSmlWLanWepKeyData ) != KErrNotFound  )
       
   800                 {
       
   801                 switch( wepKeyId )
       
   802                     {
       
   803                 case 1:
       
   804                     iSettings->WepKey1 = aObject;
       
   805                     break;
       
   806                 case 2:
       
   807                     iSettings->WepKey2 = aObject;
       
   808                     break;
       
   809                 case 3:
       
   810                     iSettings->WepKey3 = aObject;
       
   811                     break;
       
   812                 case 4:
       
   813                     iSettings->WepKey4 = aObject;
       
   814                     break;
       
   815                 default:
       
   816                     iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   817                     return;
       
   818                     }
       
   819                 }
       
   820             else if( lastUriSeg.Match( KNSmlWLanWepKeyId ) != KErrNotFound )
       
   821                 {
       
   822                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
   823                 return;
       
   824                 }
       
   825             else
       
   826                 {
       
   827                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   828                 return;
       
   829                 }
       
   830                 }
       
   831             else
       
   832                 {
       
   833                 //Add WepKeyId and execute buffer
       
   834                 if( lastUriSeg.Match( KNSmlWLanWepKeyId ) != KErrNotFound )
       
   835                     {
       
   836                     iBuffer->At(index).iWepKeyId = DesToInt( aObject );
       
   837                     iBuffer->At(index).iIdStatusRef = aStatusRef;
       
   838                                        
       
   839 //                  ExecuteBufferL( ); (JPLA-6M29NR caused error in WEPkey Data if buffer is executed here)
       
   840                     return;
       
   841                     }
       
   842 
       
   843                 else if( lastUriSeg.Match( KNSmlWLanWepKeyData ) != KErrNotFound )
       
   844                     {
       
   845                     iBuffer->At(index).iData = aObject.AllocLC();
       
   846                     iBuffer->At(index).iDataSet = ETrue;
       
   847                     CleanupStack::Pop( ); //iBuffer->At(index).iData
       
   848                     iBuffer->At(index).iDataStatusRef = aStatusRef;
       
   849                     return;
       
   850                     }
       
   851                 else
       
   852                     {
       
   853                     iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   854                     return;
       
   855                     }
       
   856                 }
       
   857             }
       
   858         }
       
   859 
       
   860     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/*") ) != KErrNotFound && uriSegs==7 )
       
   861         {
       
   862         if( lastUriSeg.Compare(KNSmlWLanSsid) == 0 )
       
   863             {
       
   864             TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8( iSettings->SSID, aObject );
       
   865             DBG_ARGS(_S16("WLanAdapter::ssid convert: <%D>"), returnValue );
       
   866             if (returnValue != KErrNone)
       
   867             	{
       
   868             	// setting the default value to the network name
       
   869             	iSettings->SSID = TPtrC(KNSmlWLanDefaultSSID);
       
   870             	DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL SSID - ErrorCode <%D>"), returnValue );
       
   871                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   872                 return;
       
   873             	}
       
   874             }
       
   875 
       
   876         else if( lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0 )
       
   877             {
       
   878             TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8( iSettings->UsedSSID, aObject );
       
   879             DBG_ARGS(_S16("WLanAdapter::usedSsid convert: <%D>"), returnValue );
       
   880             }
       
   881 
       
   882         else if( lastUriSeg.Compare(KNSmlWLanSsidHidden) == 0 )
       
   883             {
       
   884             if( aObject.MatchF( _L8("True")) != KErrNotFound )
       
   885                 {
       
   886                 iSettings->ScanSSID = 1;
       
   887                 }
       
   888             else
       
   889                 {
       
   890                 iSettings->ScanSSID = 0;
       
   891                 }
       
   892             }
       
   893 
       
   894         else if( lastUriSeg.Compare(KNSmlWLanNetworkMode) == 0 )
       
   895             {
       
   896             if( aObject.MatchF( _L8("ADHOC") ) != KErrNotFound )
       
   897                 {
       
   898                 iSettings->ConnectionMode = EAdhoc;
       
   899                 }
       
   900 
       
   901             else if( aObject.MatchF( _L8("Infrastructure") ) != KErrNotFound )
       
   902                 {
       
   903                 iSettings->ConnectionMode = EInfrastructure;
       
   904                 }
       
   905             else
       
   906                 {
       
   907                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
       
   908                 return;
       
   909                 }
       
   910             }
       
   911     
       
   912         else if( lastUriSeg.Compare(KNSmlWLanSecurityMode) == 0 )
       
   913             {
       
   914             if( aObject.MatchF( _L8("NONE") ) != KErrNotFound )
       
   915                 {
       
   916                 iSettings->SecurityMode = EAllowUnsecure;
       
   917                 }
       
   918             else if( aObject.MatchF( _L8("WEP") ) != KErrNotFound )
       
   919                 {
       
   920                 iSettings->SecurityMode = EWep;
       
   921                 }
       
   922             else if( aObject.MatchF( _L8("8021X") ) != KErrNotFound )
       
   923                 {
       
   924                 iSettings->SecurityMode = EWlan8021x;
       
   925                 }
       
   926             else if( aObject.MatchF( _L8("WPA") ) != KErrNotFound )
       
   927                 {
       
   928                 iSettings->SecurityMode = EWpa;
       
   929                 }
       
   930             else if( aObject.MatchF( _L8("WPA2") ) != KErrNotFound )
       
   931                 {
       
   932                 iSettings->SecurityMode = EWpa2;
       
   933                 }
       
   934             else
       
   935                 {
       
   936                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
       
   937                 return;
       
   938                 }
       
   939             }
       
   940 
       
   941         else if( lastUriSeg.Compare( KNSmlWLanUseWPAPSK ) == 0 )
       
   942             {
       
   943             if( aObject.MatchF( _L8("True")) != KErrNotFound )
       
   944                 {
       
   945                 iSettings->UseWPAPSK = 1;
       
   946                 }
       
   947             else
       
   948                 {
       
   949                 iSettings->UseWPAPSK = 0;
       
   950                 }
       
   951             }
       
   952 
       
   953         else if( lastUriSeg.Compare(KNSmlWLanWpaPreSharedKey) == 0 )
       
   954             {
       
   955             if(aObject.Length() > KMaxPSKLength)
       
   956             {
       
   957             	iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject );
       
   958             	return;
       
   959             }
       
   960             /*else if(aObject.Length() < KMinPSKLength)
       
   961             {
       
   962               	iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
       
   963             	return;
       
   964             }*/
       
   965             else
       
   966             {
       
   967                 iSettings->WPAPreSharedKey = aObject;     
       
   968             }
       
   969             }   
       
   970 
       
   971 	    else if( lastUriSeg.Compare( KNSmlWLanEapList ) == 0 )
       
   972     	    {
       
   973             TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8( iSettings->EapList, aObject );
       
   974             DBG_ARGS(_S16("WLanAdapter::EapList convert: <%D>"), returnValue );            
       
   975         	}
       
   976 
       
   977     	else if( lastUriSeg.Compare( KNSmlWLanAuthMode ) == 0 )
       
   978         	{
       
   979         	if( aObject.MatchF( _L8("1")) != KErrNotFound )
       
   980                 {
       
   981                 iSettings->AuthMode = EShared;
       
   982                 }
       
   983             else
       
   984                 {
       
   985                 iSettings->AuthMode = EOpen;
       
   986                 }            
       
   987         	}
       
   988 
       
   989         else if( lastUriSeg.Compare(KNSmlWLanWepIndex) == 0 )
       
   990             {
       
   991             TInt32 actualIndex = DesToInt( aObject );
       
   992             if( actualIndex < 4 && actualIndex >= 0  )
       
   993             {
       
   994             	iSettings->WepIndex = actualIndex ;
       
   995             }
       
   996             else
       
   997             {
       
   998             	if ( actualIndex > 3)
       
   999             	{
       
  1000 				iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject );
       
  1001             	}
       
  1002             	else
       
  1003             	{
       
  1004 				iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1005             	}
       
  1006             	return;
       
  1007             }
       
  1008             }
       
  1009 
       
  1010         else
       
  1011             {
       
  1012             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1013             return;
       
  1014             }
       
  1015         }
       
  1016 
       
  1017     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*/*") ) != KErrNotFound && uriSegs == 9 )
       
  1018         {
       
  1019         TSecondarySSID ssid;
       
  1020         ssid.Id = 0;
       
  1021         TUint32 id = GetSecSSIDFromUriL(aURI);
       
  1022         RArray<TSecondarySSID> secondaryList;
       
  1023         CleanupClosePushL( secondaryList );
       
  1024         iWlanSettings->GetSecondarySSIDListL(luid, secondaryList);
       
  1025         TInt count = secondaryList.Count();
       
  1026         for (TInt i=0;i<count;i++)
       
  1027             {
       
  1028             if (id == secondaryList[i].Id)
       
  1029                 {
       
  1030                 ssid = secondaryList[i];
       
  1031                 break;
       
  1032                 }
       
  1033             }
       
  1034         CleanupStack::PopAndDestroy(&secondaryList);
       
  1035         if (ssid.Id == 0)
       
  1036             {
       
  1037             
       
  1038             _DBG_FILE("CNSmlWLanAdapter::Coming to check buffer ");
       
  1039             
       
  1040             //Check if its buffered here - Divya
       
  1041             TInt index = -1;
       
  1042 
       
  1043             for( TInt i=0; i<iSecondaryBuffer.Count(); i++ )
       
  1044                 {
       
  1045                 if( aURI.Find( iSecondaryBuffer[i]->iUri->Des() ) != KErrNotFound )
       
  1046                     {
       
  1047                     index = i;
       
  1048                     _DBG_FILE("CNSmlWLanAdapter::one indexis matched :-)");
       
  1049                     break;
       
  1050                     }
       
  1051                 }
       
  1052             if( index < 0 )
       
  1053                 {
       
  1054                 _DBG_FILE("CNSmlWLanAdapter::one indexis matched :-)");
       
  1055                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1056                 return;
       
  1057                 }
       
  1058             else
       
  1059                 {
       
  1060                 DBG_ARGS8(_S8("CWlanadaptes::Execute Buffer - copying in buffer instead of giving 404 uri: object id  : <%S>"), &aObject);
       
  1061                 
       
  1062                     if( lastUriSeg.Compare(KNSmlWLanSsid) == 0 )
       
  1063                     {
       
  1064                     if ( aObject.Length() <= KMaxTextLength )
       
  1065                     	{
       
  1066                     	iSecondaryBuffer[index]->ScannedId.Copy(aObject);
       
  1067                     	}
       
  1068                     else
       
  1069                     	{
       
  1070                     	_DBG_FILE("CNSmlWLanAdapter::AddLeafObject - SecondarySSID too long");
       
  1071                         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1072                         return;
       
  1073                     	}
       
  1074                     		
       
  1075                     }
       
  1076                     else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0 )
       
  1077                     {
       
  1078                     iSecondaryBuffer[index]->UsedId.Copy(aObject);
       
  1079                     }
       
  1080                 
       
  1081                 }
       
  1082                 
       
  1083             
       
  1084             }
       
  1085         
       
  1086         else
       
  1087             {
       
  1088             
       
  1089         if( lastUriSeg.Compare(KNSmlWLanSsid) == 0 )
       
  1090             {
       
  1091             ssid.ScannedId.Copy(aObject);
       
  1092             }
       
  1093         else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0 )
       
  1094             {
       
  1095             ssid.UsedId.Copy(aObject);
       
  1096             }
       
  1097         TInt retval = iWlanSettings->WriteSecondarySSIDL(luid, ssid, EFalse);
       
  1098         if (retval == KErrNone)
       
  1099             {
       
  1100             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1101             }
       
  1102         else
       
  1103             {
       
  1104             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1105             }
       
  1106             }
       
  1107         }
       
  1108     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/*") ) != KErrNotFound && uriSegs == 9 )
       
  1109         {
       
  1110         DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL - EAP index: <%d>"), eapIndex );
       
  1111         
       
  1112         if( lastUriSeg.Compare(KNSmlWLanEapType) == 0 )
       
  1113             {
       
  1114             // Get EAP ID from URI instead of the value because the server gives the value
       
  1115             // incorrectly as the textual representation of the EAP method instead of the IANA number.            
       
  1116             iEAPBuffer[eapIndex]->iEAPSettings->iEAPType = static_cast<EAPSettings::TEapType>(GetEAPIdFromUri(aURI));
       
  1117             }
       
  1118         else if (lastUriSeg.Compare(KNSmlWLanUsername) == 0)
       
  1119             {
       
  1120             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( iEAPBuffer[eapIndex]->iEAPSettings->iUsername, aObject );
       
  1121             if (retval == KErrNone)
       
  1122             	{
       
  1123                 iEAPBuffer[eapIndex]->iEAPSettings->iUsernamePresent = ETrue;
       
  1124             	}
       
  1125             else
       
  1126             	{
       
  1127             	iEAPBuffer[eapIndex]->iEAPSettings->iUsername.Zero();
       
  1128                 DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL EAP username - ErrorCode <%D>"), retval );
       
  1129                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1130                 return;
       
  1131             	}
       
  1132 
       
  1133             }
       
  1134         else if (lastUriSeg.Compare(KNSmlWLanPassword) == 0)
       
  1135             {
       
  1136             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( iEAPBuffer[eapIndex]->iEAPSettings->iPassword, aObject );
       
  1137             if (retval == KErrNone)
       
  1138             	{
       
  1139                 iEAPBuffer[eapIndex]->iEAPSettings->iPasswordPresent = ETrue;
       
  1140             	}
       
  1141             else
       
  1142             	{
       
  1143             	iEAPBuffer[eapIndex]->iEAPSettings->iPassword.Zero();
       
  1144                 DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL EAP password - ErrorCode <%D>"), retval );
       
  1145                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1146                 return;
       
  1147             	}
       
  1148             }
       
  1149         else if (lastUriSeg.Compare(KNSmlWLanRealm) == 0)
       
  1150             {
       
  1151             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( iEAPBuffer[eapIndex]->iEAPSettings->iRealm, aObject );
       
  1152             if (retval == KErrNone)
       
  1153                 iEAPBuffer[eapIndex]->iEAPSettings->iRealmPresent = ETrue;
       
  1154             
       
  1155             }
       
  1156         else if (lastUriSeg.Compare(KNSmlWLanUsePseudonym) == 0)
       
  1157             {
       
  1158             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1159                 iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonyms = ETrue; 
       
  1160             else
       
  1161                 iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonyms = EFalse;
       
  1162             
       
  1163             
       
  1164             iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonymsPresent = ETrue; 
       
  1165             }
       
  1166         else if (lastUriSeg.Compare(KNSmlWLanEncapsulation) == 0)
       
  1167             {           
       
  1168             TBuf8<KExpandedEAPIdLength> dummy;
       
  1169             ConvertEAPStringToIds( aObject, dummy, iEAPBuffer[eapIndex]->iEncapsulatingEAPId );
       
  1170             }
       
  1171         else if (lastUriSeg.Compare(KNSmlWLanVerifyCertRealm) == 0)
       
  1172             {
       
  1173             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1174                 iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealm = ETrue; 
       
  1175             else
       
  1176                 iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealm = EFalse;
       
  1177             
       
  1178             
       
  1179             iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealmPresent = ETrue; 
       
  1180             
       
  1181             }
       
  1182         else if (lastUriSeg.Compare(KNSmlWLanRequireClientAuthentication) == 0)
       
  1183             {
       
  1184             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1185                 iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthentication = ETrue; 
       
  1186             else
       
  1187                 iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthentication = EFalse;
       
  1188             
       
  1189             
       
  1190             iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthenticationPresent = ETrue; 
       
  1191             
       
  1192             }
       
  1193         else if (lastUriSeg.Compare(KNSmlWLanSessionValidityTime) == 0)
       
  1194             {
       
  1195             TLex8 lex(aObject);
       
  1196             TUint newVal;
       
  1197             TInt sesValErr = lex.Val(newVal);
       
  1198             // Check whether the conversion went ok
       
  1199             if ( sesValErr == KErrNone ) 
       
  1200             	{
       
  1201             	iEAPBuffer[eapIndex]->iEAPSettings->iSessionValidityTime = newVal;
       
  1202             	iEAPBuffer[eapIndex]->iEAPSettings->iSessionValidityTimePresent = ETrue;
       
  1203             	}
       
  1204             else 
       
  1205             	{
       
  1206             	// there were errors, let's leave the function and update status
       
  1207                 DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL SessionValidityTime - ErrorCode <%D>"), sesValErr );
       
  1208                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
       
  1209                 return;
       
  1210             	}
       
  1211             }
       
  1212         else if (lastUriSeg.Compare(KNSmlWLanCipherSuite) == 0)
       
  1213             {
       
  1214             FillCipherSuitesL( aObject , eapIndex );
       
  1215             }
       
  1216         else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv0) == 0)
       
  1217             {
       
  1218             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1219                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv0Allowed = ETrue; 
       
  1220             else
       
  1221                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv0Allowed = EFalse;
       
  1222             
       
  1223             iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1224             }
       
  1225         else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv1) == 0)
       
  1226             {
       
  1227             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1228                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv1Allowed = ETrue; 
       
  1229             else
       
  1230                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv1Allowed = EFalse;
       
  1231 
       
  1232             iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1233             
       
  1234             }
       
  1235         else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv2) == 0)
       
  1236             {
       
  1237             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1238                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv2Allowed = ETrue; 
       
  1239             else
       
  1240                 iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv2Allowed = EFalse;
       
  1241             
       
  1242             iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
       
  1243             }
       
  1244             
       
  1245 #ifdef FF_WLAN_EXTENSIONS 
       
  1246 		else if (lastUriSeg.Compare(KNSmlWLanAuthProvMode) == 0)
       
  1247             {
       
  1248             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1249                 iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowed = ETrue; 
       
  1250             else
       
  1251                 iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowed = EFalse;
       
  1252             
       
  1253             iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowedPresent = ETrue;
       
  1254             }
       
  1255             
       
  1256             
       
  1257       	else if (lastUriSeg.Compare(KNSmlWLanUnauthProvMode) == 0)
       
  1258             {
       
  1259             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1260                 iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowed = ETrue; 
       
  1261             else
       
  1262                 iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowed = EFalse;
       
  1263             
       
  1264             iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowedPresent = ETrue;
       
  1265             }
       
  1266             
       
  1267                         
       
  1268      	else if (lastUriSeg.Compare(KNSmlWLanPACGroupRef) == 0)
       
  1269             {
       
  1270             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( iEAPBuffer[eapIndex]->iEAPSettings->iPACGroupReference, aObject );
       
  1271             if (retval == KErrNone)
       
  1272                 iEAPBuffer[eapIndex]->iEAPSettings->iPACGroupReferencePresent = ETrue;
       
  1273             
       
  1274             }
       
  1275                         
       
  1276     	else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoPAC) == 0)
       
  1277             {
       
  1278             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1279                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPAC = ETrue; 
       
  1280             else
       
  1281                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPAC = EFalse;
       
  1282             
       
  1283             iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPACPresent = ETrue;
       
  1284             }
       
  1285             
       
  1286             
       
  1287     	else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoMatchPAC) == 0)
       
  1288             {
       
  1289             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1290                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPAC = ETrue; 
       
  1291             else
       
  1292                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPAC = EFalse;
       
  1293             
       
  1294             iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPACPresent = ETrue;
       
  1295             }
       
  1296             
       
  1297             
       
  1298   		else if (lastUriSeg.Compare(KNSmlWLanWarnNotDefaultSrv) == 0)
       
  1299             {
       
  1300             if ( (aObject == KTrue) || (aObject == KTtrue) )
       
  1301                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServer = ETrue; 
       
  1302             else
       
  1303                 iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServer = EFalse;
       
  1304             
       
  1305             iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServerPresent = ETrue;
       
  1306             }
       
  1307             
       
  1308 
       
  1309 #endif            
       
  1310         
       
  1311         // Save the status reference
       
  1312 		iEAPBuffer[eapIndex]->iStatusRefArray.AppendL(aStatusRef);        
       
  1313 		return;
       
  1314         }
       
  1315     else if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*/*") ) != KErrNotFound && uriSegs == 11)
       
  1316         {
       
  1317 		TPtrC8 ptr = NSmlDmURI::ParentURI( aURI );
       
  1318 
       
  1319 		// Get the LUID from ptr2
       
  1320        	HBufC8* certLuid = iCallBack->GetLuidAllocL( ptr );
       
  1321 		
       
  1322 		TInt certIndex = GetIdFromLuid( *certLuid );
       
  1323         
       
  1324         delete certLuid;		
       
  1325         
       
  1326         DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL - cert index: <%d>, cert count: <%d>"), 
       
  1327         	certIndex, iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count());
       
  1328       	
       
  1329       	if ( iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count() - 1 < certIndex )
       
  1330       		{
       
  1331       		_DBG_FILE("CNSmlWLanAdapter::AddLeafObject - Certificate buffer does not exist. Create it.");
       
  1332       		// The certificate buffer does not exist. Create a new one
       
  1333 	  		CertificateEntry entry;
       
  1334 			iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.AppendL(entry);
       
  1335 			iEAPBuffer[eapIndex]->iEAPSettings->iCertificatesPresent = ETrue;
       
  1336 	        	        
       
  1337 	       	certIndex = iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count() - 1;
       
  1338 	       	
       
  1339 	        TBuf8<2> newLuid;
       
  1340 			newLuid.Num( certIndex );
       
  1341 			
       
  1342 	        DBG_ARGS8(_S8("WLanAdapter::AddLeafObjectL - mapping uri: <%S> to luid: <%S>"), &aURI, &newLuid );
       
  1343 	        iCallBack->SetMappingL( aURI, newLuid);	              		      		
       
  1344       		}
       
  1345       
       
  1346         if (lastUriSeg.Compare(KNSmlWLanIssuerName) == 0)
       
  1347             {
       
  1348             TInt retval = 
       
  1349                 CnvUtfConverter::ConvertToUnicodeFromUtf8( 
       
  1350                 	iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iIssuerName, aObject );
       
  1351             if (retval == KErrNone)
       
  1352                 iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iIssuerNamePresent = ETrue;
       
  1353             }
       
  1354         else if (lastUriSeg.Compare(KNSmlWLanSubjectName) == 0)
       
  1355             {
       
  1356             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
       
  1357             	iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSubjectName, aObject );
       
  1358             if (retval == KErrNone)
       
  1359                 iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSubjectNamePresent = ETrue;
       
  1360             }
       
  1361         else if (lastUriSeg.Compare(KNSmlWLanCertType) == 0)
       
  1362             {
       
  1363             iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iCertType = (CertificateEntry::TCertType)DesToInt(aObject);
       
  1364             }
       
  1365         else if (lastUriSeg.Compare(KNSmlWLanSerialNumber) == 0)
       
  1366             {
       
  1367             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
       
  1368             	iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSerialNumber, aObject );
       
  1369             if (retval == KErrNone)
       
  1370                 iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSerialNumberPresent = ETrue;
       
  1371             
       
  1372             }
       
  1373         else if (lastUriSeg.Compare(KNSmlWLanSubjectKeyId) == 0)
       
  1374             {
       
  1375             
       
  1376             // Define literals to search the subject key for possible 0X/0x beginning
       
  1377             _LIT(KHexIdLC, "0x");
       
  1378            	_LIT(KHexIdUC, "0X");
       
  1379            	TBuf<2> hexIdBuf;
       
  1380            	// The lenght of the key given as input
       
  1381            	TInt keyLen = aObject.Length();
       
  1382            	
       
  1383            	// setting the given key to the key buffer
       
  1384            	TBuf8<KNsmlSubjectKeyIdLength> origKey = aObject;
       
  1385            	origKey.SetLength(keyLen);
       
  1386            	TBuf<KNsmlSubjectKeyIdLength> key;
       
  1387            	TLex8 tmpByte;
       
  1388            	TUint16 byte;
       
  1389            	
       
  1390            	// Remove possible spaces from the beginning
       
  1391            	origKey.TrimLeft();
       
  1392            	
       
  1393            	// the key should be atleast two chars long
       
  1394            	if (origKey.Length() >= 2)
       
  1395                 {
       
  1396             	// Copy the two left most characters in to the buffer
       
  1397             	hexIdBuf.Copy(origKey.Left(2));
       
  1398             	
       
  1399             	// If the first characters are 0x or 0X, then thet should be ignored
       
  1400             	if (hexIdBuf.Compare(KHexIdLC) == 0
       
  1401             			|| hexIdBuf.Compare(KHexIdUC) == 0)
       
  1402             		{
       
  1403             		// delete two characters
       
  1404             		origKey.Delete(0, 2);
       
  1405             		}
       
  1406                 }
       
  1407             
       
  1408 
       
  1409            	// looping the subject key through, removing whitespaces
       
  1410            	for (TInt i = 0; i < keyLen; i++)
       
  1411            		{
       
  1412            		// removing white spaces from the left side of the key
       
  1413            		origKey.TrimLeft();
       
  1414            		// check that there are characters left
       
  1415            		if (origKey.Length() >= 2)
       
  1416            			{
       
  1417            			// pick the two left most bytes from the key
       
  1418            			tmpByte = origKey.Left(2);
       
  1419            			// convert byte into binary format
       
  1420            			err = tmpByte.Val(byte, EHex);
       
  1421            			
       
  1422            			// check whether conversion to decimal went ok
       
  1423            			if (err != KErrNone)
       
  1424            				{
       
  1425            				// if there are problems, then leave the loop
       
  1426            				break;
       
  1427            				}
       
  1428            			
       
  1429            			// store the appended byte into the key variable
       
  1430            			key.Append(byte);
       
  1431            			// delete two characters from the left side of the character array in the buffer
       
  1432            			origKey.Delete(0, 2);
       
  1433            			}
       
  1434            		else if (	origKey.Length() == 1 )
       
  1435            			{
       
  1436            			// pick the left most byte from the key
       
  1437            			tmpByte = origKey.Left(1);
       
  1438            			// convert byte into binary format
       
  1439            			err = tmpByte.Val(byte, EHex);
       
  1440            			
       
  1441            			// check whether conversion to decimal went ok
       
  1442            			if (err != KErrNone)
       
  1443            				{
       
  1444            				// if there are problems, then leave the loop
       
  1445            				break;
       
  1446            				}
       
  1447            			
       
  1448            			// store the appended byte into the key variable
       
  1449            			key.Append(byte);
       
  1450            			// delete two characters from the left side of the character array in the buffer
       
  1451            			origKey.Delete(0, 1);
       
  1452            			}
       
  1453            		else {
       
  1454            			// leave the loop, no characters are left
       
  1455            			break;
       
  1456            			}
       
  1457            		}
       
  1458            	// store key value only if no errors occurred
       
  1459            	if (err == KErrNone) 
       
  1460            		{
       
  1461            		iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSubjectKeyID.Copy(key);
       
  1462            		iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iSubjectKeyIDPresent = ETrue;
       
  1463            		}
       
  1464              else 
       
  1465             	{
       
  1466             	// there were errors, let's leave the function and update status
       
  1467                 DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"), err );
       
  1468                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1469                 return;
       
  1470             	}
       
  1471             }
       
  1472         else if (lastUriSeg.Compare(KNSmlWLanFingerprint) == 0)
       
  1473             {
       
  1474             TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( 
       
  1475             	iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iThumbprint, aObject );
       
  1476             if (retval == KErrNone)
       
  1477                 iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex].iThumbprintPresent = ETrue;
       
  1478             }
       
  1479         // Save the status reference
       
  1480 		iEAPBuffer[eapIndex]->iStatusRefArray.AppendL(aStatusRef);        
       
  1481 		
       
  1482         return;
       
  1483         }
       
  1484         
       
  1485     if (eapId == KErrNotFound)
       
  1486         {
       
  1487         err = iWlanSettings->WriteWlanSettings( *iSettings );
       
  1488         }
       
  1489     
       
  1490     if( err != KErrNone )
       
  1491         {
       
  1492         DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"), err );
       
  1493         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1494         return;
       
  1495         }
       
  1496 
       
  1497     iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1498 
       
  1499     _DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): end");
       
  1500     }
       
  1501 
       
  1502 //-----------------------------------------------------------------------------
       
  1503 // CNSmlWLanAdapter* CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC& aURI, 
       
  1504 //    const TDesC& aLUID, const TDesC8& aObject, const TDesC& aType, 
       
  1505 //    const TInt aStatusRef )
       
  1506 //-----------------------------------------------------------------------------
       
  1507 void CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
       
  1508                                           const TDesC8& aLUID, 
       
  1509                                           const TDesC8& aObject, 
       
  1510                                           const TDesC8& aType, 
       
  1511                                           const TInt aStatusRef )
       
  1512     {
       
  1513     _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): begin");
       
  1514     DBG_ARGS8(_S8("WLanAdapter::UpdateLeafObjectL - <%S> <%S> <%S>"), &aURI, &aLUID, &aObject );
       
  1515 
       
  1516     AddLeafObjectL( aURI, aLUID, aObject, aType, aStatusRef );
       
  1517 
       
  1518     _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): end");
       
  1519     }
       
  1520 
       
  1521 //------------------------------------------------------------------------------
       
  1522 // CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
       
  1523 // const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType )
       
  1524 //------------------------------------------------------------------------------
       
  1525 
       
  1526 void CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC8& /*aURI*/, 
       
  1527                                           const TDesC8& /*aLUID*/,
       
  1528                                           RWriteStream*& /*aStream*/, 
       
  1529                                           const TDesC8& /*aType*/,
       
  1530                                           TInt aStatusRef )
       
  1531     {
       
  1532     _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): begin");
       
  1533     iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::EError);
       
  1534     _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): end");
       
  1535     }
       
  1536 
       
  1537 //-----------------------------------------------------------------------------
       
  1538 // CNSmlWLanAdapter* CNSmlWLanAdapter::DeleteObjectL( const TDesC8& aURI, 
       
  1539 // const TDesC8& aLUID, const TInt aStatusRef )
       
  1540 //-----------------------------------------------------------------------------
       
  1541 void CNSmlWLanAdapter::DeleteObjectL( const TDesC8& aURI, 
       
  1542                                       const TDesC8& aLUID, 
       
  1543                                       const TInt aStatusRef )
       
  1544     {
       
  1545     _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): begin");
       
  1546     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
       
  1547 
       
  1548     if( aLUID.Length() == 0 )
       
  1549         {
       
  1550         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1551 
       
  1552         _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): end");
       
  1553         return;
       
  1554         }
       
  1555 
       
  1556 	TInt luid = GetIdFromLuid( aLUID );
       
  1557 
       
  1558 
       
  1559     if( ( NumOfUriSegs( aURI ) < 6 )
       
  1560      	|| (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 6 ) )
       
  1561         {
       
  1562         TInt ret = iWlanSettings->DeleteWlanSettings( luid );
       
  1563 
       
  1564         if( ret == KErrNone )
       
  1565         	{
       
  1566         	status = CSmlDmAdapter::EOk;
       
  1567         	}                          
       
  1568         else
       
  1569             {
       
  1570             status = CSmlDmAdapter::EError;
       
  1571             }
       
  1572             
       
  1573         }
       
  1574     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey") ) != KErrNotFound && NumOfUriSegs( aURI ) == 7 )
       
  1575         {
       
  1576         // Individual WLAN settings cannot be deleted and this case should never happen.
       
  1577         // These are deleted through WLAN parent nodes.
       
  1578         status = CSmlDmAdapter::EError;
       
  1579         }
       
  1580         
       
  1581     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))!= KErrNotFound && NumOfUriSegs( aURI ) == 8  )
       
  1582     {
       
  1583       _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): matching SecondarySSID/*");
       
  1584     	//Check if the secondary SSID is present , if so delete that 
       
  1585     	 TUint32 secid = GetSecSSIDFromUriL(aURI);
       
  1586     	 TInt retvalue( KErrNone );
       
  1587          _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() before call to DeleteOneSecondarySSIDL ");
       
  1588         TRAPD(ssidError, retvalue = iWlanSettings->DeleteOneSecondarySSIDL(luid,secid));
       
  1589          _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() After call to DeleteOneSecondarySSIDL ");
       
  1590          DBG_ARGS8(_S8("TRAP ERROR  ssidError : Id = %d and retvalue eror = %d"), ssidError, retvalue);
       
  1591                   
       
  1592 		 if(ssidError == KErrNone )
       
  1593 		 {
       
  1594 		   _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() SSID trap KERRONONE");
       
  1595 		 	if(retvalue == KErrNone)            
       
  1596 		 	{
       
  1597 		 		_DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() retvalue also  KERRONONE, so its deleted");
       
  1598 		 		status = CSmlDmAdapter::EOk;
       
  1599 		 	}
       
  1600 		 	
       
  1601 			 else  if (retvalue == KErrNotFound)
       
  1602 			 {
       
  1603 			 	status = CSmlDmAdapter::ENotFound;
       
  1604 			 	_DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() retvalue KErrNotFound :-(");
       
  1605 			 }
       
  1606 			
       
  1607 			else
       
  1608 			{
       
  1609 				_DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() retvalue some error :-(");
       
  1610 				status = CSmlDmAdapter::EError;
       
  1611 			}
       
  1612 				
       
  1613 			
       
  1614 		 }
       
  1615 		 else
       
  1616 		 {
       
  1617 		 _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() trap error :-( ");
       
  1618 		 	status = CSmlDmAdapter::EError;
       
  1619 		 }  
       
  1620 				 
       
  1621     }
       
  1622     
       
  1623     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 7 )
       
  1624         {
       
  1625         // Individual WLAN settings cannot be deleted and this case should never happen.
       
  1626         // These are deleted through WLAN parent nodes.
       
  1627         status = CSmlDmAdapter::EError;
       
  1628         }
       
  1629 
       
  1630     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 8 )
       
  1631         {
       
  1632         // Individual WEP keys cannot be deleted and this case should never happen.
       
  1633         // These are deleted through WLAN parent nodes.
       
  1634         status = CSmlDmAdapter::EError;
       
  1635         }
       
  1636 
       
  1637     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*/Data") ) != KErrNotFound && NumOfUriSegs( aURI ) == 9 )
       
  1638         {
       
  1639     	// Individual WEP keys cannot be deleted and this case should never happen.
       
  1640     	// These are deleted through WLAN parent nodes.	
       
  1641        	status = CSmlDmAdapter::EError;        
       
  1642         }
       
  1643 
       
  1644     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 8 )
       
  1645         {
       
  1646     	// Individual EAP settings cannot be deleted and this case should never happen.
       
  1647     	// These are deleted through WLAN parent nodes.	
       
  1648        	status = CSmlDmAdapter::EError;        
       
  1649         }
       
  1650     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 9 )
       
  1651         {
       
  1652         // Individual EAP settings cannot be deleted and this case should never happen.
       
  1653         // These are deleted through WLAN parent nodes.
       
  1654         status = CSmlDmAdapter::EError;
       
  1655         }
       
  1656     else if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 10)
       
  1657         {
       
  1658         // Individual certificates are not allowed to be deleted and this case should never happen
       
  1659         // These are deleted through WLAN parent nodes.
       
  1660         status = CSmlDmAdapter::EError;
       
  1661                
       
  1662         }
       
  1663     else if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*/*") ) != KErrNotFound && NumOfUriSegs( aURI ) == 11)
       
  1664         {
       
  1665         // Individual certificate fields are not allowed to be deleted and this case should never happen.
       
  1666         // These are deleted through WLAN parent nodes.
       
  1667         status = CSmlDmAdapter::EError;
       
  1668 		}
       
  1669 
       
  1670     iCallBack->SetStatusL( aStatusRef, status );
       
  1671 
       
  1672     _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): end");
       
  1673     }
       
  1674 
       
  1675 //-----------------------------------------------------------------------------
       
  1676 // CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& aURI, 
       
  1677 //                     const TDesC8& aLUID, const TDesC8& aType, 
       
  1678 //                     const TInt aResultsRef, const TInt aStatusRef )
       
  1679 // not used.
       
  1680 //-----------------------------------------------------------------------------
       
  1681 
       
  1682 void CNSmlWLanAdapter::FetchLeafObjectSizeL( const TDesC8& /*aURI*/, 
       
  1683                                                  const TDesC8& /*aLUID*/,
       
  1684                                                  const TDesC8& /*aType*/, 
       
  1685                                                  TInt /*aResultsRef*/,
       
  1686                                                  TInt /*aStatusRef*/ )
       
  1687     {
       
  1688     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectSizeL(): begin");
       
  1689     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectSizeL(): end");
       
  1690     return;
       
  1691 }                                                
       
  1692 
       
  1693 
       
  1694 //-----------------------------------------------------------------------------
       
  1695 // CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& aURI, 
       
  1696 //                     const TDesC8& aLUID, const TDesC8& aType, 
       
  1697 //                     const TInt aResultsRef, const TInt aStatusRef )
       
  1698 //-----------------------------------------------------------------------------
       
  1699 void CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& /*aURI*/, 
       
  1700                                         const TDesC8& /*aLUID*/, 
       
  1701                                         const TDesC8& /*aType*/, 
       
  1702                                         const TInt /*aResultsRef*/, 
       
  1703                                         const TInt /*aStatusRef*/ )
       
  1704     {
       
  1705     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): begin");
       
  1706     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): end");
       
  1707 
       
  1708     }
       
  1709     
       
  1710 //-----------------------------------------------------------------------------
       
  1711 // CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC& aURI, 
       
  1712 //                     const TDesC& aLUID, const TDesC& aType, 
       
  1713 //                     const TInt aResultsRef, const TInt aStatusRef )
       
  1714 //-----------------------------------------------------------------------------
       
  1715 CSmlDmAdapter::TError CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& aURI, 
       
  1716                                         const TDesC8& aLUID, 
       
  1717                                         const TDesC8& aType, 
       
  1718                                         CBufBase& aObject )
       
  1719     {
       
  1720     
       
  1721     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): begin");
       
  1722     DBG_ARGS8(_S8("WLanAdapter::FetchLeafObjectL - <%S> <%S> <%S>"), &aURI, &aLUID, &aType);
       
  1723 
       
  1724     if(aLUID.Length()==0)
       
  1725         {
       
  1726 
       
  1727         _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): ENotFound");
       
  1728         return CSmlDmAdapter::ENotFound;
       
  1729         }
       
  1730 
       
  1731     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
       
  1732 
       
  1733 	// This luid is the service table id (Found from EAP node and parents)
       
  1734 	TInt luid;
       
  1735 	if ( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound )
       
  1736 		{
       
  1737 		luid = GetServiceIdFromUriL( aURI );
       
  1738 		}
       
  1739 	else
       
  1740 		{
       
  1741 		// The luid supplied is ok
       
  1742 		luid = GetIdFromLuid( aLUID );
       
  1743 		}
       
  1744     
       
  1745     TPtrC8 lastUriSeg = GetLastUriSeg( aURI );
       
  1746 
       
  1747     TInt err = iWlanSettings->GetWlanSettings( luid, *iSettings );
       
  1748 
       
  1749     if( err == KErrNotFound )
       
  1750     {
       
  1751 
       
  1752         _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): ENotFound");       
       
  1753         return CSmlDmAdapter::ENotFound;
       
  1754     }
       
  1755 
       
  1756     if( lastUriSeg.Compare( KNSmlWLanSsid ) == 0 )
       
  1757         {
       
  1758 
       
  1759         if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*")) != KErrNotFound)
       
  1760             {
       
  1761             RArray<TSecondarySSID> secondarySSIDs;
       
  1762             CleanupClosePushL( secondarySSIDs );
       
  1763             iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
       
  1764             TSecondarySSID ssid;
       
  1765             ssid.Id = 0;
       
  1766             TUint32 id = GetSecSSIDFromUriL(aURI);
       
  1767             TInt count = secondarySSIDs.Count();
       
  1768             for (TInt i=0;i<count;i++)
       
  1769                 {
       
  1770                 if (id == secondarySSIDs[i].Id)
       
  1771                     {
       
  1772                     ssid = secondarySSIDs[i];
       
  1773                     break;
       
  1774                     }
       
  1775                 }            
       
  1776             CleanupStack::PopAndDestroy(&secondarySSIDs);
       
  1777             if (ssid.Id == 0)
       
  1778                 {
       
  1779                 status = CSmlDmAdapter::ENotFound;
       
  1780                 }
       
  1781             else
       
  1782                 {
       
  1783                 HBufC* data = ssid.ScannedId.AllocLC();
       
  1784                 HBufC8* data8 = HBufC8::NewLC(data->Size());
       
  1785                 TPtr8 dataPtr8 = data8->Des();
       
  1786                 //FFS
       
  1787                 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
       
  1788 
       
  1789                 aObject.InsertL( 0, dataPtr8 );
       
  1790                 status = CSmlDmAdapter::EOk;
       
  1791 
       
  1792                 CleanupStack::PopAndDestroy( 2 ); //data, data8
       
  1793                 }
       
  1794             }
       
  1795         else
       
  1796             {
       
  1797 
       
  1798         HBufC* data = iSettings->SSID.AllocLC();
       
  1799         HBufC8* data8 = HBufC8::NewLC(data->Size());
       
  1800         TPtr8 dataPtr8 = data8->Des();
       
  1801         //FFS
       
  1802         CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
       
  1803 
       
  1804         aObject.InsertL( 0, dataPtr8 );
       
  1805         status = CSmlDmAdapter::EOk;
       
  1806 
       
  1807         CleanupStack::PopAndDestroy( 2 ); //data, data8
       
  1808 
       
  1809             }
       
  1810 
       
  1811         }
       
  1812 
       
  1813     else if( lastUriSeg.Compare( KNSmlWLanUsedSsid ) == 0 )
       
  1814         {
       
  1815 
       
  1816         if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*")) != KErrNotFound)
       
  1817             {
       
  1818             RArray<TSecondarySSID> secondarySSIDs;
       
  1819             CleanupClosePushL( secondarySSIDs );
       
  1820             iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
       
  1821             TSecondarySSID ssid;
       
  1822             ssid.Id = 0;
       
  1823             TUint32 id = GetSecSSIDFromUriL(aURI);
       
  1824             TInt count = secondarySSIDs.Count();
       
  1825             for (TInt i=0;i<count;i++)
       
  1826                 {
       
  1827                 if (id == secondarySSIDs[i].Id)
       
  1828                     {
       
  1829                     ssid = secondarySSIDs[i];
       
  1830                     break;
       
  1831                     }
       
  1832                 }
       
  1833             CleanupStack::PopAndDestroy(&secondarySSIDs);            
       
  1834             if (ssid.Id == 0)
       
  1835                 {
       
  1836                 status = CSmlDmAdapter::ENotFound;
       
  1837                 }
       
  1838             else
       
  1839                 {
       
  1840                 HBufC* data = ssid.UsedId.AllocLC();
       
  1841                 HBufC8* data8 = HBufC8::NewLC(data->Size());
       
  1842                 TPtr8 dataPtr8 = data8->Des();
       
  1843                 //FFS
       
  1844                 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
       
  1845 
       
  1846                 aObject.InsertL( 0, dataPtr8 );
       
  1847                 status = CSmlDmAdapter::EOk;
       
  1848 
       
  1849                 CleanupStack::PopAndDestroy( 2 ); //data, data8
       
  1850                 }
       
  1851             }
       
  1852         else
       
  1853             {
       
  1854             
       
  1855         HBufC* data = iSettings->UsedSSID.AllocLC();
       
  1856         HBufC8* data8 = HBufC8::NewLC(data->Size());
       
  1857         TPtr8 dataPtr8 = data8->Des();
       
  1858         //FFS
       
  1859         CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
       
  1860 
       
  1861         aObject.InsertL( 0, dataPtr8 );
       
  1862         status = CSmlDmAdapter::EOk;
       
  1863 
       
  1864         CleanupStack::PopAndDestroy( 2 ); //data, data8
       
  1865         
       
  1866             }
       
  1867 
       
  1868         }
       
  1869         
       
  1870     else if( lastUriSeg.Compare( KNSmlWLanSsidHidden ) == 0 )
       
  1871         {
       
  1872         if ( iSettings->ScanSSID == 1 )
       
  1873             {
       
  1874             aObject.InsertL( 0, _L8("True" ) );
       
  1875             }
       
  1876         else
       
  1877             {
       
  1878             aObject.InsertL( 0, _L8("False" ) );
       
  1879             }
       
  1880         status = CSmlDmAdapter::EOk;
       
  1881         }
       
  1882 
       
  1883 
       
  1884     else if( lastUriSeg.Compare( KNSmlWLanNetworkMode ) == 0 )
       
  1885         {
       
  1886         status = CSmlDmAdapter::EOk;
       
  1887 
       
  1888         switch( iSettings->ConnectionMode )
       
  1889             {
       
  1890         case 0:
       
  1891             aObject.InsertL( 0, KNSmlWLanAdHoc8 );
       
  1892             break;
       
  1893         case 1:
       
  1894             aObject.InsertL( 0, KNSmlWLanInfrastructure8 );
       
  1895             break;
       
  1896         default:
       
  1897             status = CSmlDmAdapter::ENotFound;
       
  1898             break;
       
  1899             }
       
  1900         }
       
  1901     else if( lastUriSeg.Compare( KNSmlWLanSecurityMode ) == 0 )
       
  1902         {
       
  1903         status = CSmlDmAdapter::EOk;
       
  1904 
       
  1905         switch( iSettings->SecurityMode )
       
  1906             {
       
  1907         case EAllowUnsecure:
       
  1908             aObject.InsertL( 0, KNSmlWLanAllowUnsecure8 );
       
  1909             break;
       
  1910         case EWep:
       
  1911             aObject.InsertL( 0, KNSmlWLanWep8 );
       
  1912             break;
       
  1913         case EWlan8021x:
       
  1914             aObject.InsertL( 0, KNSmlWLan8021x8 );
       
  1915             break;
       
  1916         case EWpa:
       
  1917             aObject.InsertL( 0, KNSmlWLanWpa8 );
       
  1918             break;
       
  1919         case EWpa2:
       
  1920             aObject.InsertL( 0, KNSmlWLanWpa28 );
       
  1921             break;
       
  1922         default:
       
  1923             status = CSmlDmAdapter::ENotFound;
       
  1924             break;
       
  1925             }
       
  1926         }
       
  1927         
       
  1928     else if( lastUriSeg.Compare( KNSmlWLanWpaPreSharedKey ) == 0 )
       
  1929         {
       
  1930 		aObject.InsertL( 0, iSettings->WPAPreSharedKey );
       
  1931         status = CSmlDmAdapter::EOk;
       
  1932         }
       
  1933 
       
  1934     else if( lastUriSeg.Compare( KNSmlWLanUseWPAPSK ) == 0 )
       
  1935         {
       
  1936         if ( iSettings->UseWPAPSK == 1 )
       
  1937             {
       
  1938             aObject.InsertL( 0, _L8("True" ) );
       
  1939             }
       
  1940         else
       
  1941             {
       
  1942             aObject.InsertL( 0, _L8("False" ) );
       
  1943             }       
       
  1944         status = CSmlDmAdapter::EOk;
       
  1945         }
       
  1946 
       
  1947     else if( lastUriSeg.Compare( KNSmlWLanWepIndex ) == 0 )
       
  1948         {
       
  1949         HBufC8* data = IntToDes8LC( iSettings->WepIndex );
       
  1950         aObject.InsertL( 0, data->Des() );
       
  1951         
       
  1952         CleanupStack::PopAndDestroy( data ); //data
       
  1953         status = CSmlDmAdapter::EOk;
       
  1954         }
       
  1955 
       
  1956     else if( lastUriSeg.Compare( KNSmlWLanEapList ) == 0 )
       
  1957         {     
       
  1958         HBufC* data = iSettings->EapList.AllocLC();
       
  1959         HBufC8* data8 = HBufC8::NewLC(data->Size());
       
  1960         TPtr8 dataPtr8 = data8->Des();
       
  1961         //FFS
       
  1962         CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
       
  1963 
       
  1964         aObject.InsertL( 0, dataPtr8 );
       
  1965         status = CSmlDmAdapter::EOk;
       
  1966 
       
  1967         CleanupStack::PopAndDestroy( 2 ); //data, data8
       
  1968       
       
  1969         }
       
  1970 
       
  1971     else if( lastUriSeg.Compare( KNSmlWLanAuthMode ) == 0 )
       
  1972         {
       
  1973         HBufC8* data = IntToDes8LC( iSettings->AuthMode );
       
  1974         aObject.InsertL( 0, data->Des() );
       
  1975         
       
  1976         CleanupStack::PopAndDestroy( data ); //data
       
  1977         status = CSmlDmAdapter::EOk;
       
  1978         }
       
  1979 
       
  1980     else if( lastUriSeg.Compare( KNSmlWLanWepKeyData ) == 0 )
       
  1981         {
       
  1982         TInt wepKeyIndex = GetWepKeyIdFromLuid( aLUID );
       
  1983         if(wepKeyIndex == KErrNotFound)
       
  1984         {
       
  1985         	wepKeyIndex = GetWepKeyIdFromUri( aURI );
       
  1986         	TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
       
  1987             addLUID.AppendNum( wepKeyIndex );
       
  1988             addLUID.AppendNumFixedWidth( luid, EDecimal, 3 );
       
  1989             DBG_ARGS8(_S8("WLanAdapter::Fetchleaf object, set mapping uri: <%S> to luid: <%S>"), &aURI, &addLUID );
       
  1990             DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID );
       
  1991            iCallBack->SetMappingL(aURI, addLUID);
       
  1992                 
       
  1993         }
       
  1994         status = CSmlDmAdapter::EOk;
       
  1995         switch( wepKeyIndex )
       
  1996             {
       
  1997         case 1:
       
  1998             aObject.InsertL( 0, iSettings->WepKey1 );
       
  1999             break;
       
  2000         case 2:
       
  2001             aObject.InsertL( 0, iSettings->WepKey2 );
       
  2002             break;
       
  2003         case 3:
       
  2004             aObject.InsertL( 0, iSettings->WepKey3 );
       
  2005             break;
       
  2006         case 4:
       
  2007             aObject.InsertL( 0, iSettings->WepKey4 );
       
  2008             break;
       
  2009         default:
       
  2010             status = CSmlDmAdapter::EError;
       
  2011             }
       
  2012         }
       
  2013     else if( lastUriSeg.Compare( KNSmlWLanWepKeyId ) == 0 )
       
  2014         {
       
  2015         TInt wepKeyIndex = GetWepKeyIdFromLuid( aLUID );
       
  2016         if(wepKeyIndex == KErrNotFound)
       
  2017         {
       
  2018         	wepKeyIndex = GetWepKeyIdFromUri( aURI );
       
  2019         	TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
       
  2020             addLUID.AppendNum( wepKeyIndex );
       
  2021             addLUID.AppendNumFixedWidth( luid, EDecimal, 3 );
       
  2022             DBG_ARGS8(_S8("WLanAdapter::Fetchleaf object, set mapping uri: <%S> to luid: <%S>"), &aURI, &addLUID );
       
  2023             DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID );
       
  2024            iCallBack->SetMappingL(aURI, addLUID);
       
  2025         }
       
  2026         if( wepKeyIndex > 0 )
       
  2027             {
       
  2028             HBufC8* data = IntToDes8LC( wepKeyIndex );
       
  2029             aObject.InsertL( 0, data->Des() );
       
  2030             CleanupStack::PopAndDestroy( data ); //data
       
  2031             status = CSmlDmAdapter::EOk;
       
  2032             }
       
  2033         else
       
  2034             {
       
  2035             status = CSmlDmAdapter::EError;
       
  2036             }
       
  2037         }
       
  2038 
       
  2039     else if (aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound)
       
  2040         {
       
  2041         TInt eapId = GetEAPIdFromUri(aURI);
       
  2042 
       
  2043         // Check if the id contains encapsulating type as well
       
  2044         TInt encapsEapId = GetEncapsEAPIdFromUri( aURI );
       
  2045         if ( encapsEapId == KErrNotFound )
       
  2046         	{
       
  2047         	encapsEapId = EAPSettings::EEapNone;
       
  2048         	}
       
  2049         
       
  2050         ResetEAPStructL();
       
  2051                               
       
  2052         TInt err = iWlanSettings->GetEAPSettings( luid, eapId, encapsEapId, *iEAPSettings );
       
  2053         if (err != KErrNone || iEAPSettings == NULL)
       
  2054             {
       
  2055             status = CSmlDmAdapter::EError; 
       
  2056             }
       
  2057         else if (lastUriSeg.Compare( KNSmlWLanEapType ) == 0 )
       
  2058             {
       
  2059             aObject.InsertL(0, *IntToDes8LC((TInt)iEAPSettings->iEAPType));
       
  2060             CleanupStack::PopAndDestroy(); // IntToDes8LC
       
  2061             status = CSmlDmAdapter::EOk;
       
  2062             }
       
  2063         else if (lastUriSeg.Compare( KNSmlWLanUsername ) == 0 )
       
  2064             {
       
  2065             if (iEAPSettings->iUsernamePresent)
       
  2066                 {
       
  2067                 DesToBufferL(aObject, iEAPSettings->iUsername);
       
  2068                 }
       
  2069             status = CSmlDmAdapter::EOk;
       
  2070             }
       
  2071         else if (lastUriSeg.Compare( KNSmlWLanPassword ) == 0 )
       
  2072             {
       
  2073             if (iEAPSettings->iPasswordPresent)
       
  2074                 {
       
  2075                 DesToBufferL(aObject, iEAPSettings->iPassword);
       
  2076                 }
       
  2077             status = CSmlDmAdapter::EOk;
       
  2078             }
       
  2079         else if (lastUriSeg.Compare( KNSmlWLanRealm ) == 0 )
       
  2080             {
       
  2081             if (iEAPSettings->iRealmPresent)
       
  2082                 {
       
  2083                 DesToBufferL(aObject, iEAPSettings->iRealm);
       
  2084                 }
       
  2085             status = CSmlDmAdapter::EOk;
       
  2086             }
       
  2087         else if (lastUriSeg.Compare( KNSmlWLanUsePseudonym ) == 0 )
       
  2088             {
       
  2089             if (iEAPSettings->iUsePseudonymsPresent && iEAPSettings->iUsePseudonyms)
       
  2090                 {
       
  2091                 aObject.InsertL(0, KTrue);
       
  2092                 }
       
  2093             else
       
  2094                 {
       
  2095                 aObject.InsertL(0, KFalse);
       
  2096                 }
       
  2097             status = CSmlDmAdapter::EOk;
       
  2098             }
       
  2099         else if (lastUriSeg.Compare( KNSmlWLanEncapsulation ) == 0 )
       
  2100             {
       
  2101             if ( encapsEapId == EAPSettings::EEapPeap )
       
  2102             	{
       
  2103             	aObject.InsertL( 0, KEAPPEAP);            	
       
  2104             	}
       
  2105             else if ( encapsEapId == EAPSettings::EEapTtls )
       
  2106             	{
       
  2107             	aObject.InsertL( 0, KEAPTTLS);
       
  2108             	}
       
  2109             status = CSmlDmAdapter::EOk;
       
  2110             }
       
  2111         else if (lastUriSeg.Compare( KNSmlWLanVerifyCertRealm ) == 0 )
       
  2112             {
       
  2113             if (iEAPSettings->iVerifyServerRealmPresent && iEAPSettings->iVerifyServerRealm)
       
  2114                 {
       
  2115                 aObject.InsertL(0, KTrue);
       
  2116                 }
       
  2117             else
       
  2118                 {
       
  2119                 aObject.InsertL(0, KFalse);
       
  2120                 }
       
  2121             status = CSmlDmAdapter::EOk;
       
  2122             }
       
  2123         else if (lastUriSeg.Compare( KNSmlWLanRequireClientAuthentication ) == 0 )
       
  2124             {
       
  2125             if (iEAPSettings->iRequireClientAuthenticationPresent && iEAPSettings->iRequireClientAuthentication)
       
  2126                 {
       
  2127                 aObject.InsertL(0, KTrue);
       
  2128                 }
       
  2129             else
       
  2130                 {
       
  2131                 aObject.InsertL(0, KFalse);
       
  2132                 }
       
  2133             status = CSmlDmAdapter::EOk;
       
  2134             }
       
  2135         else if (lastUriSeg.Compare( KNSmlWLanSessionValidityTime ) == 0 )
       
  2136             {
       
  2137             if (iEAPSettings->iSessionValidityTimePresent)
       
  2138                 {
       
  2139                 aObject.InsertL(0, *IntToDes8LC((TInt)iEAPSettings->iSessionValidityTime));
       
  2140                 CleanupStack::PopAndDestroy(); // IntToDes8LC
       
  2141                 }
       
  2142             status = CSmlDmAdapter::EOk;
       
  2143             }
       
  2144         else if (lastUriSeg.Compare( KNSmlWLanCipherSuite ) == 0 )
       
  2145             {
       
  2146             FillCipherSuiteBufferL(aObject);
       
  2147             status = CSmlDmAdapter::EOk; 
       
  2148             }
       
  2149         else if (lastUriSeg.Compare( KNSmlWLanAllowPEAPv0 ) == 0 )
       
  2150             {
       
  2151             if (iEAPSettings->iPEAPVersionsPresent && iEAPSettings->iPEAPv0Allowed)
       
  2152                 {
       
  2153                 aObject.InsertL(0, KTrue);
       
  2154                 }
       
  2155             else
       
  2156                 {
       
  2157                 aObject.InsertL(0, KFalse);
       
  2158                 }
       
  2159             status = CSmlDmAdapter::EOk;
       
  2160             }
       
  2161         else if (lastUriSeg.Compare( KNSmlWLanAllowPEAPv1 ) == 0 )
       
  2162             {
       
  2163             if (iEAPSettings->iPEAPVersionsPresent && iEAPSettings->iPEAPv1Allowed)
       
  2164                 {
       
  2165                 aObject.InsertL(0, KTrue);
       
  2166                 }
       
  2167             else
       
  2168                 {
       
  2169                 aObject.InsertL(0, KFalse);
       
  2170                 }
       
  2171             status = CSmlDmAdapter::EOk;
       
  2172             }
       
  2173         else if (lastUriSeg.Compare( KNSmlWLanAllowPEAPv2 ) == 0 )
       
  2174             {
       
  2175             if (iEAPSettings->iPEAPVersionsPresent && iEAPSettings->iPEAPv2Allowed)
       
  2176                 {
       
  2177                 aObject.InsertL(0, KTrue);
       
  2178                 }
       
  2179             else
       
  2180                 {
       
  2181                 aObject.InsertL(0, KFalse);
       
  2182                 }
       
  2183             status = CSmlDmAdapter::EOk;
       
  2184             }
       
  2185             
       
  2186             
       
  2187             
       
  2188 #ifdef FF_WLAN_EXTENSIONS 
       
  2189 		else if (lastUriSeg.Compare(KNSmlWLanAuthProvMode) == 0)
       
  2190             {
       
  2191             if (iEAPSettings->iAuthProvModeAllowedPresent && iEAPSettings->iAuthProvModeAllowed)
       
  2192                 {
       
  2193                 aObject.InsertL(0, KTrue);
       
  2194                 }
       
  2195             else
       
  2196                 {
       
  2197                 aObject.InsertL(0, KFalse);
       
  2198                 }
       
  2199             status = CSmlDmAdapter::EOk;
       
  2200             }
       
  2201             
       
  2202                         
       
  2203       	else if (lastUriSeg.Compare(KNSmlWLanUnauthProvMode) == 0)
       
  2204                         {
       
  2205             if (iEAPSettings->iUnauthProvModeAllowedPresent && iEAPSettings->iUnauthProvModeAllowed)
       
  2206                 {
       
  2207                 aObject.InsertL(0, KTrue);
       
  2208                 }
       
  2209             else
       
  2210                 {
       
  2211                 aObject.InsertL(0, KFalse);
       
  2212                 }
       
  2213             status = CSmlDmAdapter::EOk;
       
  2214             }
       
  2215                                     
       
  2216      	else if (lastUriSeg.Compare(KNSmlWLanPACGroupRef) == 0)
       
  2217             {
       
  2218             if (iEAPSettings->iPACGroupReferencePresent)
       
  2219                 {
       
  2220                 DesToBufferL(aObject, iEAPSettings->iPACGroupReference);
       
  2221                 }
       
  2222             status = CSmlDmAdapter::EOk;
       
  2223             }
       
  2224                         
       
  2225     	else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoPAC) == 0)
       
  2226             {
       
  2227             if (iEAPSettings->iWarnADHPNoPACPresent && iEAPSettings->iWarnADHPNoPAC)
       
  2228                 {
       
  2229                 aObject.InsertL(0, KTrue);
       
  2230                 }
       
  2231             else
       
  2232                 {
       
  2233                 aObject.InsertL(0, KFalse);
       
  2234                 }
       
  2235             status = CSmlDmAdapter::EOk;
       
  2236             }
       
  2237             
       
  2238             
       
  2239     	else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoMatchPAC) == 0)
       
  2240             {
       
  2241             if (iEAPSettings->iWarnADHPNoMatchingPACPresent && iEAPSettings->iWarnADHPNoMatchingPAC)
       
  2242                 {
       
  2243                 aObject.InsertL(0, KTrue);
       
  2244                 }
       
  2245             else
       
  2246                 {
       
  2247                 aObject.InsertL(0, KFalse);
       
  2248                 }
       
  2249             status = CSmlDmAdapter::EOk;
       
  2250             }
       
  2251             
       
  2252             
       
  2253             
       
  2254   		else if (lastUriSeg.Compare(KNSmlWLanWarnNotDefaultSrv) == 0)
       
  2255             {
       
  2256             if (iEAPSettings->iWarnNotDefaultServerPresent && iEAPSettings->iWarnNotDefaultServer)
       
  2257                 {
       
  2258                 aObject.InsertL(0, KTrue);
       
  2259                 }
       
  2260             else
       
  2261                 {
       
  2262                 aObject.InsertL(0, KFalse);
       
  2263                 }
       
  2264             status = CSmlDmAdapter::EOk;
       
  2265             }
       
  2266             
       
  2267 #endif  
       
  2268                                 
       
  2269             
       
  2270         else if (lastUriSeg.Compare( KNSmlWLanIssuerName ) == 0 )
       
  2271             {
       
  2272             status = CSmlDmAdapter::ENotFound;            
       
  2273             
       
  2274             TInt certId = GetCertificateIdFromUri(aURI);
       
  2275             
       
  2276             if ( iEAPSettings->iCertificatesPresent
       
  2277             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2278             	&& certId != KErrNotFound )
       
  2279                 {
       
  2280                 if (iEAPSettings->iCertificates[certId-1].iIssuerNamePresent)
       
  2281                 	{
       
  2282                 	aObject.InsertL(0, ConvertTo8LC(iEAPSettings->iCertificates[certId-1].iIssuerName));
       
  2283                    	CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  2284                    	status = CSmlDmAdapter::EOk;
       
  2285                 	}
       
  2286             	}
       
  2287             }
       
  2288         else if (lastUriSeg.Compare( KNSmlWLanSubjectName ) == 0 )
       
  2289             {
       
  2290             status = CSmlDmAdapter::ENotFound;            
       
  2291             
       
  2292             TInt certId = GetCertificateIdFromUri(aURI);
       
  2293             
       
  2294             if ( iEAPSettings->iCertificatesPresent
       
  2295             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2296             	&& certId != KErrNotFound )
       
  2297                 {
       
  2298                 if (iEAPSettings->iCertificates[certId-1].iSubjectNamePresent)
       
  2299                 	{
       
  2300                     aObject.InsertL(0, ConvertTo8LC(iEAPSettings->iCertificates[certId-1].iSubjectName));
       
  2301                     CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  2302 					status = CSmlDmAdapter::EOk;                  
       
  2303                 	}                   
       
  2304                 }
       
  2305             }
       
  2306         else if (lastUriSeg.Compare( KNSmlWLanCertType ) == 0 )
       
  2307             {
       
  2308             status = CSmlDmAdapter::ENotFound;            
       
  2309             
       
  2310             TInt certId = GetCertificateIdFromUri(aURI);
       
  2311             
       
  2312             if ( iEAPSettings->iCertificatesPresent
       
  2313             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2314             	&& certId != KErrNotFound )
       
  2315                 {
       
  2316                 aObject.InsertL(0, *IntToDes8LC(iEAPSettings->iCertificates[certId-1].iCertType));
       
  2317                 CleanupStack::PopAndDestroy(); // IntToDes8LC
       
  2318                 status = CSmlDmAdapter::EOk;
       
  2319                 }                            
       
  2320             }
       
  2321         else if (lastUriSeg.Compare( KNSmlWLanSerialNumber ) == 0 )
       
  2322             {
       
  2323             status = CSmlDmAdapter::ENotFound;            
       
  2324             
       
  2325             TInt certId = GetCertificateIdFromUri(aURI);
       
  2326             
       
  2327             if ( iEAPSettings->iCertificatesPresent
       
  2328             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2329             	&& certId != KErrNotFound )
       
  2330                 {
       
  2331                 if (iEAPSettings->iCertificates[certId-1].iSerialNumberPresent)
       
  2332     	            {
       
  2333                     aObject.InsertL(0, ConvertTo8LC(iEAPSettings->iCertificates[certId-1].iSerialNumber));
       
  2334                     CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  2335 	                status = CSmlDmAdapter::EOk;
       
  2336                     }
       
  2337                 }
       
  2338             }
       
  2339         else if (lastUriSeg.Compare( KNSmlWLanSubjectKeyId ) == 0 )
       
  2340             {
       
  2341             status = CSmlDmAdapter::ENotFound;            
       
  2342             
       
  2343             TInt certId = GetCertificateIdFromUri(aURI);
       
  2344             
       
  2345             if ( iEAPSettings->iCertificatesPresent
       
  2346             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2347             	&& certId != KErrNotFound )
       
  2348             	{         	
       
  2349                 if (iEAPSettings->iCertificates[certId-1].iSubjectKeyIDPresent)
       
  2350                     {
       
  2351                     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObject - Fetch subject key.");
       
  2352                     // check the lenght of the given subjectKeyId, if it is longer that 20, then we
       
  2353                     // update the status with error and will not go through the key
       
  2354                     if ((iEAPSettings->iCertificates[certId-1].iSubjectKeyID.Length()) > KKeyIdentifierLength)
       
  2355                     	{
       
  2356                     	status = CSmlDmAdapter::EError;        
       
  2357                     	}
       
  2358                     else 
       
  2359                     	{
       
  2360                     	_DBG_FILE("CNSmlWLanAdapter::FetchLeafObject - key is under max lenght");
       
  2361                     	TBuf8<KKeyIdentifierLength> binKey = iEAPSettings->iCertificates[certId-1].iSubjectKeyID;
       
  2362                     	TBuf8<2> idBuf;
       
  2363                     	TBuf8<KKeyIdentifierLength*2> key;
       
  2364                     	TUint8 byte;
       
  2365                     
       
  2366                     	// hexadecimal representation
       
  2367                     	_LIT8(KFormat, "%02x");
       
  2368                                              	
       
  2369                     	// looping the subject key through
       
  2370                     	for (TInt i = 0; i < binKey.Length(); i++)
       
  2371                     		{
       
  2372                     		_DBG_FILE("CNSmlWLanAdapter::FetchLeafObject - Loop the key through.");
       
  2373                     		// pick the next value from the buffer
       
  2374                     		byte = binKey[i];
       
  2375                     		// convert the value into hexadecimal format
       
  2376                     		idBuf.Format(KFormat, byte);		
       
  2377                     		// store the hexa value into the key variable
       
  2378                     		key.Append(idBuf);
       
  2379                     		}
       
  2380                     	// Copy the key to the aObject variable
       
  2381                     	aObject.InsertL(0, key);
       
  2382                     	status = CSmlDmAdapter::EOk;
       
  2383                     	}
       
  2384                     }
       
  2385             	}            
       
  2386             }
       
  2387         else if (lastUriSeg.Compare( KNSmlWLanFingerprint ) == 0 )
       
  2388             {
       
  2389             status = CSmlDmAdapter::ENotFound;            
       
  2390             
       
  2391             TInt certId = GetCertificateIdFromUri(aURI);
       
  2392 
       
  2393             if ( iEAPSettings->iCertificatesPresent
       
  2394             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2395             	&& certId != KErrNotFound )
       
  2396                 {   
       
  2397                 if (iEAPSettings->iCertificates[certId-1].iThumbprintPresent)
       
  2398                 	{
       
  2399                     aObject.InsertL(0, ConvertTo8LC(iEAPSettings->iCertificates[certId-1].iThumbprint));
       
  2400                     CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  2401                     status = CSmlDmAdapter::EOk;
       
  2402                 	}                 
       
  2403                 }
       
  2404             }
       
  2405         else if (lastUriSeg.Compare( KNSmlWLanSerialNumber ) == 0 )
       
  2406             {
       
  2407             status = CSmlDmAdapter::ENotFound;            
       
  2408             
       
  2409             TInt certId = GetCertificateIdFromUri(aURI);
       
  2410             
       
  2411             if ( iEAPSettings->iCertificatesPresent
       
  2412             	&& iEAPSettings->iCertificates.Count() >= certId
       
  2413             	&& certId != KErrNotFound )
       
  2414                 {   
       
  2415                 if (iEAPSettings->iCertificates[certId-1].iSerialNumberPresent)
       
  2416                 	{
       
  2417                     aObject.InsertL(0, ConvertTo8LC(iEAPSettings->iCertificates[certId-1].iSerialNumber));
       
  2418                     CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  2419                     status = CSmlDmAdapter::EOk;
       
  2420                 	}
       
  2421                	}
       
  2422             }
       
  2423         }
       
  2424 
       
  2425         
       
  2426     DBG_ARGS(_S16("CNSmlWLanAdapter::FetchLeafObjectL - Status <%D>"), status );
       
  2427     _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): end");
       
  2428     return status;
       
  2429     }
       
  2430 
       
  2431 //-----------------------------------------------------------------------------
       
  2432 // CNSmlWLanAdapter* CNSmlWLanAdapter::ChildURIListL( const TDesC& aURI, 
       
  2433 // const TDesC& aLUID, const CArrayFix<TNSmlDmMappingInfo>& aPreviousURISegmentList, 
       
  2434 // const TInt aResultsRef, const TInt aStatusRef )
       
  2435 //-----------------------------------------------------------------------------
       
  2436 void CNSmlWLanAdapter::ChildURIListL( const TDesC8& aURI, 
       
  2437                                       const TDesC8& aLUID, 
       
  2438                                       const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
       
  2439                                       const TInt aResultsRef, 
       
  2440                                       const TInt aStatusRef )
       
  2441     {
       
  2442     _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): begin");
       
  2443     DBG_ARGS8(_S8("WLanAdapter::ChildURIListL - <%S> <%S>"), &aURI, &aLUID );
       
  2444     CBufBase* currentUriSegmentList = CBufFlat::NewL( 128 );
       
  2445     CleanupStack::PushL( currentUriSegmentList );
       
  2446 
       
  2447     TInt uriSegs = NumOfUriSegs( aURI );
       
  2448     TInt luid = GetIdFromLuid( aLUID );
       
  2449 
       
  2450     //AP/<x>/NAPDef/<x>/
       
  2451     if( aURI.Match( _L8("AP/*/NAPDef/*") ) != KErrNotFound && uriSegs==4 )
       
  2452         {
       
  2453         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->NAPDef - <%S> <%S>"), &aURI, &aLUID );
       
  2454         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2455             {
       
  2456             currentUriSegmentList->InsertL( 0, KNSmlNAPDefWlanNode );
       
  2457             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2458             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2459 		    _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2460             }
       
  2461         else
       
  2462             {
       
  2463             currentUriSegmentList->InsertL( 0, KNSmlNAPDefWlanNode );
       
  2464             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLan );
       
  2465             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2466             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2467 		    _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2468             }
       
  2469         }
       
  2470 
       
  2471     //AP/<x>/NAPDef/<x>/WLAN
       
  2472     else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN")) != KErrNotFound && uriSegs == 5 ) 
       
  2473         {
       
  2474         if( aPreviousURISegmentList.Count() > 0 )
       
  2475             {
       
  2476             HBufC8 *uriSeg = HBufC8::NewLC(KNSmlMaxURISegLen);
       
  2477             TPtr8 uriSegPtr = uriSeg->Des();
       
  2478             uriSegPtr = aPreviousURISegmentList.At(0).iURISeg;
       
  2479             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), uriSegPtr );
       
  2480             CleanupStack::PopAndDestroy( uriSeg ); //uriSeg
       
  2481             iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::EOk);
       
  2482         	iCallBack->SetResultsL(aResultsRef,*currentUriSegmentList,KNullDesC8);
       
  2483 		    _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2484             }
       
  2485         else
       
  2486             {
       
  2487             if( iWlanSettings->RecordExists( luid ) < 0)
       
  2488                 {
       
  2489                 iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::ENotFound);
       
  2490                 _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status: Not found");
       
  2491                 }
       
  2492             else
       
  2493                 {
       
  2494                 _LIT8(Kprev,"WLId");
       
  2495                 TBuf8<9> addNAME(Kprev); // WLId
       
  2496                 addNAME.AppendNumFixedWidth(luid,EDecimal,3);
       
  2497 
       
  2498                 currentUriSegmentList->InsertL(currentUriSegmentList->Size(),addNAME);
       
  2499                 currentUriSegmentList->InsertL(currentUriSegmentList->Size(),_L8("/"));
       
  2500 
       
  2501                 TBuf8<80> addURI; // AP/<x>/NapDef/<x>/WLAN/WLIdnnn , n=aLUID
       
  2502                 addURI.Append(aURI);
       
  2503                 addURI.Append(_L8("/WLId"));
       
  2504                 addURI.AppendNumFixedWidth(luid,EDecimal,3);
       
  2505 
       
  2506                 TBuf8<16> addLUID;
       
  2507                 _LIT8(KFormat,"%d");
       
  2508                 addLUID.Format(KFormat,luid);
       
  2509         
       
  2510                 // Also added to mapping
       
  2511                 DBG_ARGS8(_S8("WLanAdapter::ChildURIListL - mapping uri: <%S> to luid: <%S>"), &addURI, &addLUID );
       
  2512                 DBG_ARGS8(_S8("Parameters - <%S> <%S>"), &aURI, &aLUID );
       
  2513                 iCallBack->SetMappingL(addURI,addLUID);
       
  2514                 iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::EOk);
       
  2515         		iCallBack->SetResultsL(aResultsRef,*currentUriSegmentList,KNullDesC8);
       
  2516 		    	_DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2517                 }
       
  2518             }        
       
  2519         }
       
  2520 
       
  2521     //AP/<x>/NAPDef/<x>/WLAN/<x>
       
  2522     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*") ) != KErrNotFound && uriSegs==6 )
       
  2523         {
       
  2524         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->NAPDef - <%S> <%S>"), &aURI, &aLUID );
       
  2525         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2526             {
       
  2527             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2528             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2529             }
       
  2530         else
       
  2531             {
       
  2532             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLanListOfLeafs );
       
  2533             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2534             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2535             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2536             }
       
  2537         }
       
  2538 
       
  2539     
       
  2540     //AP/<x>/NAPDef/<x>/WLAN/<x>/WEPKey
       
  2541     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey") ) != KErrNotFound && uriSegs==7 )
       
  2542         {
       
  2543         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->WEPKey - <%S> <%S> <%D> <%D>"), &aURI, &aLUID, aResultsRef, aStatusRef );
       
  2544 
       
  2545         for( TInt i=0; i<4; i++ )
       
  2546             {
       
  2547             if( aPreviousURISegmentList.Count()>i )
       
  2548                 {
       
  2549                 HBufC8 *uriSeg = HBufC8::NewLC( KNSmlMaxURISegLen) ;
       
  2550                 TPtr8 uriSegPtr = uriSeg->Des();
       
  2551                 uriSegPtr = aPreviousURISegmentList.At(i).iURISeg;
       
  2552                 
       
  2553                 currentUriSegmentList->InsertL( currentUriSegmentList->Size(),uriSegPtr );
       
  2554                 currentUriSegmentList->InsertL( currentUriSegmentList->Size(),_L8( "/" ) );
       
  2555                 CleanupStack::PopAndDestroy(); //uriSeg
       
  2556                 }
       
  2557             else
       
  2558                 {
       
  2559                 TBuf8<25> addNAME;
       
  2560                 addNAME.Append( _L8("WKId") );
       
  2561                 addNAME.AppendNum( i+1 );
       
  2562                 addNAME.Append( _L8("/") );
       
  2563 
       
  2564                 currentUriSegmentList->InsertL( currentUriSegmentList->Size(),addNAME );
       
  2565                 }
       
  2566             }
       
  2567 
       
  2568         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2569         iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );           
       
  2570         _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2571         }
       
  2572 
       
  2573     //AP/<x>/NAPDef/<x>/WEPKey/<x>
       
  2574     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*") ) != KErrNotFound && uriSegs==8 )
       
  2575         {
       
  2576         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->WEPKey/* - <%S> <%D>"), &aURI, luid );
       
  2577         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2578             {
       
  2579             //wlan settings not found for aLUID
       
  2580             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2581             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2582             }
       
  2583         else
       
  2584             {
       
  2585             TInt wepKeyId = GetWepKeyIdFromLuid( aLUID );
       
  2586             if( wepKeyId == KErrNotFound )
       
  2587                 {
       
  2588                 wepKeyId = GetWepKeyIdFromUri( aURI );
       
  2589 
       
  2590                 TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
       
  2591                 addLUID.AppendNum( wepKeyId );
       
  2592                 addLUID.AppendNumFixedWidth( luid, EDecimal, 3 );
       
  2593 
       
  2594                 DBG_ARGS8(_S8("WLanAdapter::ChildURIListL - mapping uri: <%S> to luid: <%S>"), &aURI, &addLUID );
       
  2595                 DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID );
       
  2596                 iCallBack->SetMappingL(aURI, addLUID);
       
  2597                 }
       
  2598 
       
  2599             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLanListOfWepKeyLeafs );
       
  2600             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2601             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2602             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2603             }
       
  2604         }
       
  2605 
       
  2606     //AP/<x>/NAPDef/<x>/WLAN/<x>/SecondarySSID/
       
  2607     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID") ) != KErrNotFound && uriSegs==7 )
       
  2608         {
       
  2609         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP - <%S> <%S> <%D> <%D>"), &aURI, &aLUID, aResultsRef, aStatusRef );
       
  2610         if( aPreviousURISegmentList.Count() > 0 )
       
  2611             {
       
  2612             HBufC8 *uriSeg = HBufC8::NewLC(KNSmlMaxURISegLen);
       
  2613             TPtr8 uriSegPtr = uriSeg->Des();
       
  2614             uriSegPtr = aPreviousURISegmentList.At(0).iURISeg;
       
  2615             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), uriSegPtr );
       
  2616             CleanupStack::PopAndDestroy( uriSeg ); //uriSeg
       
  2617             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2618         	iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );           
       
  2619         	_DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2620             }
       
  2621         else
       
  2622             {
       
  2623             if( iWlanSettings->RecordExists( luid ) < 0)
       
  2624                 {
       
  2625                 iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::ENotFound);
       
  2626                 _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status: Not found");
       
  2627                 }
       
  2628             else
       
  2629                 {
       
  2630                 RArray<TSecondarySSID> secondarySSIDs;
       
  2631                 CleanupClosePushL( secondarySSIDs );
       
  2632                 iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
       
  2633                 TInt count = secondarySSIDs.Count();
       
  2634                 _LIT8(KPrefixSSID,"SecSSID");
       
  2635                 TBuf8<5> addNAME; // number
       
  2636                 for (TInt i=0;i<count;i++)
       
  2637                     {
       
  2638                     if (i != 0) // Don't do it in first iteration, but with all the following
       
  2639                         {
       
  2640                         currentUriSegmentList->InsertL(currentUriSegmentList->Size(),_L8("/"));
       
  2641                         }
       
  2642                     currentUriSegmentList->InsertL(currentUriSegmentList->Size(),KPrefixSSID);
       
  2643                     addNAME.Zero();
       
  2644                     addNAME.AppendNumFixedWidth(secondarySSIDs[i].Id ,EDecimal,3);
       
  2645                     currentUriSegmentList->InsertL(currentUriSegmentList->Size(),addNAME);
       
  2646                     }
       
  2647                 CleanupStack::PopAndDestroy(&secondarySSIDs);
       
  2648                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2649         		iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );           
       
  2650         		_DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2651                 }
       
  2652             }       
       
  2653         }
       
  2654     //AP/<x>/NAPDef/<x>/WLAN/<x>/SecondarySSID/*
       
  2655     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*") ) != KErrNotFound && uriSegs==8 )
       
  2656         {
       
  2657         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->SecondarySSID/* - <%S> <%D>"), &aURI, luid );
       
  2658         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2659             {
       
  2660             //wlan settings not found for aLUID
       
  2661             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2662             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2663             }
       
  2664         else
       
  2665             {
       
  2666             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLanListOfSecondaryLeafs );
       
  2667             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2668             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2669             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2670             }
       
  2671         }
       
  2672     //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP
       
  2673     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP") ) != KErrNotFound && uriSegs==7 )
       
  2674         {        
       
  2675         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP - <%S> <%S> <%D> <%D>"), &aURI, &aLUID, aResultsRef, aStatusRef );
       
  2676         
       
  2677         // Need to get the service id from parent node
       
  2678 		luid = GetServiceIdFromUriL ( aURI );
       
  2679 		
       
  2680 		if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2681             {
       
  2682             //wlan settings not found for aLUID
       
  2683             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2684             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2685             }
       
  2686         else
       
  2687         	{
       
  2688 	        iWlanSettings->InstalledEAPsL(*currentUriSegmentList);
       
  2689 
       
  2690     	    iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2691 	        iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );           
       
  2692 	        _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");        	
       
  2693         	}
       
  2694         }
       
  2695     //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>
       
  2696     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*") ) != KErrNotFound && uriSegs==8 )
       
  2697         {
       
  2698 		// Need to get the service id from parent node
       
  2699 		luid = GetServiceIdFromUriL ( aURI );
       
  2700 		
       
  2701         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP/* - <%S> <%D>"), &aURI, luid );
       
  2702         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2703             {
       
  2704             //wlan settings not found for aLUID
       
  2705             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2706             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2707             }
       
  2708         else
       
  2709             {
       
  2710             currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLanListOfEAPLeafs );
       
  2711             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2712             iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2713             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2714             }
       
  2715         }
       
  2716     //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>/Certificate
       
  2717     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate") ) != KErrNotFound && uriSegs== 9 )
       
  2718         {
       
  2719 		luid = GetServiceIdFromUriL ( aURI );
       
  2720 		      
       
  2721         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->Certificate - <%S> <%D>"), &aURI, luid );
       
  2722         if( iWlanSettings->RecordExists( luid ) < 0 )
       
  2723             {
       
  2724             //wlan settings not found for aLUID
       
  2725             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2726             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2727             }
       
  2728         else
       
  2729             {
       
  2730             TInt eapId = GetEAPIdFromUri( aURI );
       
  2731             
       
  2732             // Check if the id contains encapsulating type as well
       
  2733             TInt encapsEapId = GetEncapsEAPIdFromUri( aURI );
       
  2734             if ( encapsEapId == KErrNotFound )
       
  2735             	{
       
  2736             	encapsEapId = EAPSettings::EEapNone;
       
  2737             	}
       
  2738             
       
  2739             ResetEAPStructL();
       
  2740             TInt err = iWlanSettings->GetEAPSettings(luid, eapId, encapsEapId, *iEAPSettings);
       
  2741             if (err != KErrNone || !iEAPSettings->iCertificatesPresent)
       
  2742                 {
       
  2743                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2744                 _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
       
  2745                 }
       
  2746             else
       
  2747                 {
       
  2748                 TInt certCount = iEAPSettings->iCertificates.Count();
       
  2749                 HBufC8* pBuf = HBufC8::NewLC(KNSmlMaxURISegLen);
       
  2750                 TPtr8 ptrCerts = pBuf->Des();
       
  2751                 for (TInt i=0; i<certCount; i++)
       
  2752                     {
       
  2753                     ptrCerts.Append(_L8("CertId"));
       
  2754                     ptrCerts.AppendNumFixedWidth( i+1, EDecimal, 3);
       
  2755                     ptrCerts.Append( _L8("/") );
       
  2756                     }
       
  2757                 
       
  2758                 currentUriSegmentList->InsertL( currentUriSegmentList->Size(), ptrCerts );
       
  2759                 CleanupStack::PopAndDestroy(pBuf); // pBuf
       
  2760                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2761             	iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2762             	_DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
       
  2763                 }
       
  2764             }
       
  2765         }
       
  2766     //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>/Certificate/<x>
       
  2767     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*") ) != KErrNotFound && uriSegs==10 )
       
  2768         {
       
  2769         DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP/* - <%S> <%D>"), &aURI, luid );
       
  2770         TInt eapId = GetEAPIdFromUri(aURI);
       
  2771         // Check if the id contains encapsulating type as well
       
  2772         TInt encapsEapId = GetEncapsEAPIdFromUri( aURI );
       
  2773         if ( encapsEapId == KErrNotFound )
       
  2774         	{
       
  2775         	encapsEapId = EAPSettings::EEapNone;
       
  2776         	}
       
  2777 
       
  2778         ResetEAPStructL();
       
  2779         TInt err = iWlanSettings->GetEAPSettings(luid, eapId, encapsEapId, *iEAPSettings);
       
  2780         if (err != KErrNone || !iEAPSettings->iCertificatesPresent)
       
  2781             {
       
  2782             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2783             _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");            
       
  2784             }
       
  2785         else
       
  2786           	{
       
  2787 	        currentUriSegmentList->InsertL( currentUriSegmentList->Size(), KNSmlWLanListOfCertificateLeafs );
       
  2788 	        iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2789 	        iCallBack->SetResultsL( aResultsRef, *currentUriSegmentList, KNullDesC8 );
       
  2790 	        _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");  	
       
  2791           	}                      
       
  2792         }
       
  2793 
       
  2794 
       
  2795     CleanupStack::PopAndDestroy( currentUriSegmentList );
       
  2796 
       
  2797     _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): end");
       
  2798     }
       
  2799 
       
  2800 //-----------------------------------------------------------------------------
       
  2801 // void CNSmlWLanAdapter::AddNodeObjectL( const TDesC& aURI, const TDesC& aParentLUID, 
       
  2802 // const TInt aStatusRef )
       
  2803 //-----------------------------------------------------------------------------
       
  2804 void CNSmlWLanAdapter::AddNodeObjectL( const TDesC8& aURI, 
       
  2805                                        const TDesC8& aParentLUID, 
       
  2806                                        const TInt aStatusRef )
       
  2807     {
       
  2808     _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): begin");
       
  2809     DBG_ARGS8(_S8("WLanAdapter::AddNodeObjectL - uri: <%S> to aParentLuid: <%S>"), 
       
  2810                 &aURI, &aParentLUID );
       
  2811 
       
  2812     TInt uriSegs = NumOfUriSegs( aURI );
       
  2813     if( (aURI.Match (_L8( "AP/*/NAPDef/*/WLAN") ) != KErrNotFound && uriSegs == 5 )
       
  2814     	|| (aURI.Match (_L8( "AP/*/NAPDef/*/WLAN/*/EAP") ) != KErrNotFound && uriSegs == 7 )
       
  2815     	|| (aURI.Match (_L8( "AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate") ) != KErrNotFound && uriSegs == 9 ) )
       
  2816         {
       
  2817         iCallBack->SetMappingL( aURI, aParentLUID );
       
  2818         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2819         return;
       
  2820         }
       
  2821 
       
  2822     //Add new wlan settings
       
  2823     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*") ) != 
       
  2824             KErrNotFound && NumOfUriSegs( aURI ) == 6 )
       
  2825         {
       
  2826         iSettings->Id = 0;
       
  2827         iSettings->ServiceID = DesToInt( aParentLUID ); 
       
  2828         iSettings->ConnectionMode = 0;
       
  2829       	iSettings->SSID = TPtrC(KNSmlWLanDefaultSSID);
       
  2830         iSettings->UsedSSID = _L("");
       
  2831         iSettings->ScanSSID = 0;
       
  2832         iSettings->WepKey1 = _L8("");
       
  2833         iSettings->WepKey2 = _L8("");
       
  2834         iSettings->WepKey3 = _L8("");
       
  2835         iSettings->WepKey4 = _L8("");
       
  2836         iSettings->WepIndex = 0;
       
  2837         iSettings->SecurityMode = EAllowUnsecure;
       
  2838         iSettings->WPAPreSharedKey = _L8("");
       
  2839         iSettings->UseWPAPSK = 0;
       
  2840         iSettings->EapList = _L("");
       
  2841         iSettings->AuthMode = 0;                
       
  2842 
       
  2843         TInt err = iWlanSettings->WriteWlanSettings( *iSettings );
       
  2844         if( err != KErrNone )
       
  2845             {
       
  2846             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  2847             return;
       
  2848             }
       
  2849 
       
  2850         DBG_ARGS8(_S8("WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"), &aURI, &aParentLUID );
       
  2851         iCallBack->SetMappingL( aURI, aParentLUID );
       
  2852         iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2853         }
       
  2854 
       
  2855     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey") ) != KErrNotFound && uriSegs == 7 )
       
  2856         {
       
  2857         if( iWlanSettings->RecordExists( DesToInt( aParentLUID ) ) )
       
  2858             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  2859         else
       
  2860             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  2861         return;
       
  2862         }
       
  2863 
       
  2864     //Add wep key for existing record
       
  2865     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*") ) != KErrNotFound && uriSegs == 8 )
       
  2866         {
       
  2867         for( TInt i=0; i<iBuffer->Count(); i++ )
       
  2868             {
       
  2869             if( iBuffer->At(i).iUri->Match( aURI ) != KErrNotFound )
       
  2870                 {
       
  2871                 iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists );
       
  2872 
       
  2873                 _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): EAlreadyExists");
       
  2874                 return;
       
  2875                 }
       
  2876             }
       
  2877         DBG_ARGS8(_S8("WLanAdapter::Bufferiin - uri: <%S> to aParentLuid: <%S>"), &aURI, &aParentLUID );
       
  2878 
       
  2879         TNSmlWepKeyBufferElement newNode;
       
  2880         newNode.iUri = aURI.AllocLC();
       
  2881         newNode.iData = 0;
       
  2882         newNode.iWepKeyId = 0;
       
  2883         //newNode.iUseWPAPSK = 0;
       
  2884         newNode.iIdStatusRef = 0;
       
  2885         newNode.iDataStatusRef = 0;
       
  2886         newNode.iLengthStatusRef = 0;
       
  2887         newNode.iNodeStatusRef = aStatusRef;
       
  2888         newNode.iExecuted = EFalse;
       
  2889         newNode.iDataSet = EFalse;
       
  2890         newNode.iLuid = DesToInt( aParentLUID );
       
  2891         iBuffer->AppendL( newNode );
       
  2892 
       
  2893         CleanupStack::Pop( );   //newNode.iUri
       
  2894 
       
  2895         _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): end");
       
  2896         return;
       
  2897         }
       
  2898 
       
  2899     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*") ) != 
       
  2900             KErrNotFound && NumOfUriSegs( aURI ) == 8 )
       
  2901         {
       
  2902         /*
       
  2903         TSecondarySSID ssid;
       
  2904         ssid.ScannedId = KNullDesC;
       
  2905         ssid.UsedId = KNullDesC;
       
  2906         TInt luid = GetIdFromLuid( aParentLUID );
       
  2907         TInt retval = iWlanSettings->WriteSecondarySSIDL(luid, ssid, ETrue);*/
       
  2908         
       
  2909         TNSmlSecondarySSIDBufferElement *newSecNode =  new (ELeave) TNSmlSecondarySSIDBufferElement;;
       
  2910         newSecNode->iUri = aURI.AllocLC();
       
  2911         newSecNode->ScannedId = KNullDesC;
       
  2912         newSecNode->UsedId = KNullDesC;
       
  2913         newSecNode->iExecuted = EFalse;
       
  2914         newSecNode->wlanLuid = GetIdFromLuid( aParentLUID );
       
  2915         iSecondaryBuffer.AppendL( newSecNode );
       
  2916         CleanupStack::Pop( );   //newNode.iUri
       
  2917         return;
       
  2918         }
       
  2919 
       
  2920     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*") ) != 
       
  2921             KErrNotFound && NumOfUriSegs( aURI ) == 8 )
       
  2922         {
       
  2923         TInt eapTypeId = GetEAPIdFromUri(aURI);
       
  2924 		TInt encapsEapId = GetEncapsEAPIdFromUri( aURI );
       
  2925         if ( encapsEapId == KErrNotFound )
       
  2926         	{
       
  2927         	encapsEapId = EAPSettings::EEapNone;
       
  2928         	}
       
  2929         
       
  2930                     
       
  2931         TInt WLANServiceId = GetServiceIdFromUriL ( aURI );
       
  2932         
       
  2933         if ( WLANServiceId == KErrNotFound )
       
  2934         	{
       
  2935         	_DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): Could not find WLAN service ID from URI.");
       
  2936         	User::Leave( KErrNotFound );
       
  2937         	}
       
  2938         
       
  2939         TInt i(0);
       
  2940         // Check if the buffer for this EAP already exists
       
  2941         for ( i = 0 ; i < iEAPBuffer.Count() ; i++ )
       
  2942             {
       
  2943             if ( eapTypeId == iEAPBuffer[i]->iEAPSettings->iEAPType
       
  2944                 && encapsEapId == iEAPBuffer[i]->iEncapsulatingEAPId )
       
  2945                 {
       
  2946                 // The correct buffer was found.                
       
  2947                 _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): Found existing buffer.");
       
  2948                 break;                              
       
  2949                 }
       
  2950             }
       
  2951         // buffer did not exist. Update the existing buffer
       
  2952         if ( i == iEAPBuffer.Count() )
       
  2953             {   
       
  2954             TNSmlEAPBufferElement* buffer = new (ELeave) TNSmlEAPBufferElement;
       
  2955             CleanupStack::PushL( buffer );
       
  2956        	
       
  2957             buffer->iEAPSettings = new (ELeave) EAPSettings;
       
  2958             CleanupStack::PushL( buffer->iEAPSettings );
       
  2959 	                
       
  2960             buffer->iEAPSettings->iEAPType = static_cast<EAPSettings::TEapType> (eapTypeId);        
       
  2961             buffer->iStatusRefArray.AppendL(aStatusRef);
       
  2962             buffer->iWLANServiceId = WLANServiceId;
       
  2963             buffer->iEncapsulatingEAPId = static_cast<EAPSettings::TEapType>(encapsEapId);
       
  2964             iEAPBuffer.AppendL(buffer);       
       
  2965 
       
  2966             CleanupStack::Pop( buffer->iEAPSettings );
       
  2967             CleanupStack::Pop( buffer );
       
  2968             }
       
  2969         
       
  2970         // Set the mapping luid to be the index to the iEAPBuffer
       
  2971         TBuf8<2> luid;
       
  2972         luid.Num( iEAPBuffer.Count() - 1 );
       
  2973         DBG_ARGS8(_S8("WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"), &aURI, &luid );
       
  2974         iCallBack->SetMappingL( aURI, luid);
       
  2975             
       
  2976         }
       
  2977     else if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*") ) != 
       
  2978             KErrNotFound && NumOfUriSegs( aURI ) == 10 )
       
  2979         {
       
  2980 		TPtrC8 ptr = NSmlDmURI::ParentURI( aURI );
       
  2981 		TPtrC8 ptr2 = NSmlDmURI::ParentURI( ptr );
       
  2982 							
       
  2983        	HBufC8* eapLuidBuf = iCallBack->GetLuidAllocL( ptr2 );
       
  2984 		
       
  2985 		TInt index = GetIdFromLuid( *eapLuidBuf );
       
  2986         
       
  2987         delete eapLuidBuf;
       
  2988         
       
  2989   		CertificateEntry entry;
       
  2990 		iEAPBuffer[index]->iEAPSettings->iCertificates.AppendL(entry);
       
  2991 		iEAPBuffer[index]->iEAPSettings->iCertificatesPresent = ETrue;
       
  2992         iEAPBuffer[index]->iStatusRefArray.AppendL(aStatusRef);
       
  2993         
       
  2994         TBuf8<2> luid;
       
  2995 		luid.Num( iEAPBuffer[index]->iEAPSettings->iCertificates.Count() - 1 );
       
  2996 		
       
  2997         DBG_ARGS8(_S8("WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"), &aURI, &luid );
       
  2998         iCallBack->SetMappingL( aURI, luid);
       
  2999         }
       
  3000     _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): end");
       
  3001     }
       
  3002     
       
  3003 //------------------------------------------------------------------------------
       
  3004 // CNSmlWLanAdapter::ExecuteCommandL
       
  3005 // not supported
       
  3006 //------------------------------------------------------------------------------
       
  3007 void CNSmlWLanAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, 
       
  3008                               const TDesC8& /*aLUID*/,
       
  3009                               const TDesC8& /*aArgument*/, 
       
  3010                               const TDesC8& /*aType*/,
       
  3011                               TInt aStatusRef )
       
  3012     {
       
  3013     _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): begin");
       
  3014     iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
       
  3015     _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): end");
       
  3016     }
       
  3017 
       
  3018 //------------------------------------------------------------------------------
       
  3019 // CNSmlWLanAdapter::ExecuteCommandL ( .. RWriteStream ..)
       
  3020 // not supported
       
  3021 //------------------------------------------------------------------------------
       
  3022 void CNSmlWLanAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, 
       
  3023                               const TDesC8& /*aLUID*/,
       
  3024                               RWriteStream*& /*aStream*/, 
       
  3025                               const TDesC8& /*aType*/,
       
  3026                               TInt aStatusref )
       
  3027     {
       
  3028     _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): begin");
       
  3029     iCallBack->SetStatusL(aStatusref, CSmlDmAdapter::EError);
       
  3030     _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): end");
       
  3031     }
       
  3032 
       
  3033 //------------------------------------------------------------------------------
       
  3034 // CNSmlWLanAdapter::CopyCommandL
       
  3035 // not supported
       
  3036 //------------------------------------------------------------------------------
       
  3037 void CNSmlWLanAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/,
       
  3038                                      const TDesC8& /*aTargetLUID*/,
       
  3039                                      const TDesC8& /* aSourceURI*/,
       
  3040                                      const TDesC8& /*aSourceLUID*/, 
       
  3041                                      const TDesC8& /*aType*/,
       
  3042                                      TInt aStatusRef )
       
  3043     {
       
  3044     _DBG_FILE("CNSmlWLanAdapter::CopyCommandL(): begin");
       
  3045     iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
       
  3046     _DBG_FILE("CNSmlWLanAdapter::CopyCommandL(): end");
       
  3047     }
       
  3048 //------------------------------------------------------------------------------
       
  3049 // CNSmlWLanAdapter::StartAtomicL
       
  3050 // not supported
       
  3051 //------------------------------------------------------------------------------
       
  3052 void CNSmlWLanAdapter::StartAtomicL()
       
  3053     {
       
  3054     _DBG_FILE("CNSmlWLanAdapter::StartAtomicL(): begin");
       
  3055     _DBG_FILE("CNSmlWLanAdapter::StartAtomicL(): end");
       
  3056     }
       
  3057 
       
  3058 //------------------------------------------------------------------------------
       
  3059 // CNSmlWLanAdapter::CommitAtomicL
       
  3060 // not supported
       
  3061 //------------------------------------------------------------------------------
       
  3062 void CNSmlWLanAdapter::CommitAtomicL()
       
  3063     {
       
  3064     _DBG_FILE("CNSmlWLanAdapter::CommitAtomicL(): begin");
       
  3065     _DBG_FILE("CNSmlWLanAdapter::CommitAtomicL(): end");
       
  3066     }
       
  3067 
       
  3068 //------------------------------------------------------------------------------
       
  3069 // CNSmlWLanAdapter::RollbackAtomicL
       
  3070 // returns EError
       
  3071 //------------------------------------------------------------------------------
       
  3072 void CNSmlWLanAdapter::RollbackAtomicL()
       
  3073     {
       
  3074     _DBG_FILE("CNSmlWLanAdapter::RollbackAtomicL(): begin");
       
  3075     _DBG_FILE("CNSmlWLanAdapter::RollbackAtomicL(): end");
       
  3076     }
       
  3077 
       
  3078 //------------------------------------------------------------------------------
       
  3079 // CNSmlWLanAdapter::StreamingSupport
       
  3080 // returns EFalse
       
  3081 //------------------------------------------------------------------------------
       
  3082 
       
  3083 TBool CNSmlWLanAdapter::StreamingSupport( TInt& /*aItemSize*/ )
       
  3084     {
       
  3085     _DBG_FILE("CNSmlWLanAdapter::StreamingSupport(): begin");
       
  3086     _DBG_FILE("CNSmlWLanAdapter::StreamingSupport(): end");
       
  3087     return EFalse;
       
  3088     }
       
  3089 
       
  3090 //------------------------------------------------------------------------------
       
  3091 // CNSmlWLanAdapter::StreamCommittedL
       
  3092 // not used in this adapter
       
  3093 //------------------------------------------------------------------------------
       
  3094 
       
  3095 void CNSmlWLanAdapter::StreamCommittedL()
       
  3096     {
       
  3097     _DBG_FILE("CNSmlWLanAdapter::StreamCommittedL(): begin");
       
  3098     _DBG_FILE("CNSmlWLanAdapter::StreamCommittedL(): end");
       
  3099     }
       
  3100 
       
  3101 //-----------------------------------------------------------------------------
       
  3102 // CNSmlWLanAdapter* CNSmlWLanAdapter::CompleteOutstandingCmdsL( )
       
  3103 //-----------------------------------------------------------------------------
       
  3104 void CNSmlWLanAdapter::CompleteOutstandingCmdsL( )
       
  3105     {
       
  3106     _DBG_FILE("CNSmlWLanAdapter::CompleteOutStandingCmdsL(): begin");
       
  3107 
       
  3108     ExecuteBufferL( ETrue );
       
  3109 
       
  3110     _DBG_FILE("CNSmlWLanAdapter::CompleteOutStandingCmdsL(): end");
       
  3111     }
       
  3112 
       
  3113 // ------------------------------------------------------------------------------------------------
       
  3114 // TPtrC8 CNSmlWLanAdapter::GetLastUriSeg(const TDesC8& aURI)
       
  3115 // Returns only the last uri segemnt
       
  3116 // ------------------------------------------------------------------------------------------------
       
  3117 TPtrC8 CNSmlWLanAdapter::GetLastUriSeg( const TDesC8& aURI )
       
  3118     {
       
  3119     _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): begin");
       
  3120 
       
  3121     TInt i;
       
  3122     for( i = aURI.Length()-1; i >= 0; i-- )
       
  3123         {
       
  3124         if( aURI[i] == '/' )
       
  3125             {
       
  3126             break;
       
  3127             }
       
  3128         }
       
  3129 
       
  3130     if( i==0 )
       
  3131         {
       
  3132         _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): end");
       
  3133         return aURI;
       
  3134         }
       
  3135     else
       
  3136         {
       
  3137         _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): end");
       
  3138         return aURI.Mid( i+1 );
       
  3139         }
       
  3140     }
       
  3141 
       
  3142 
       
  3143 // ------------------------------------------------------------------------------------------------
       
  3144 // TPtrC16 CNSmlWLanAdapter::RemoveLastURISeg(const TDesC8& aURI)
       
  3145 // returns parent uri, i.e. removes last uri segment
       
  3146 // ------------------------------------------------------------------------------------------------
       
  3147 TPtrC8 CNSmlWLanAdapter::RemoveLastUriSeg(const TDesC8& aURI)
       
  3148     {
       
  3149     _DBG_FILE("CNSmlWLanAdapter::RemoveLastUriSeg(): begin");
       
  3150 
       
  3151     TInt i;
       
  3152     for( i = aURI.Length()-1; i >= 0; i-- )
       
  3153         {
       
  3154         if(aURI[i] == '/')
       
  3155             {
       
  3156             break;
       
  3157             }
       
  3158         }
       
  3159 
       
  3160     _DBG_FILE("CNSmlWLanAdapter::RemoveLastUriSeg(): end");
       
  3161     return aURI.Left(i);
       
  3162     }
       
  3163 
       
  3164 
       
  3165 // ------------------------------------------------------------------------------------------------
       
  3166 // TInt CNSmlWLanAdapter::DesToInt( const TDesC8& aLuid )
       
  3167 // Returns aLuid as integer value
       
  3168 // ------------------------------------------------------------------------------------------------
       
  3169 TInt CNSmlWLanAdapter::DesToInt( const TDesC8& aLuid )
       
  3170     {
       
  3171     _DBG_FILE("CNSmlWLanAdapter::DesToInt(): begin");
       
  3172 
       
  3173     TLex8 lex(aLuid);
       
  3174     TInt value = 0;
       
  3175     lex.Val( value );
       
  3176 
       
  3177     DBG_ARGS8(_S8("WLanAdapter::DesToInt() - Des: <%S> Int: <%D>"), &aLuid, value );
       
  3178     _DBG_FILE("CNSmlWLanAdapter::DesToInt(): end");
       
  3179     return value;
       
  3180     }
       
  3181 
       
  3182 
       
  3183 // ------------------------------------------------------------------------------------------------
       
  3184 // HBufC* CNSmlWLanAdapter::IntToDesLC(const TInt aLuid)
       
  3185 // ------------------------------------------------------------------------------------------------
       
  3186 HBufC* CNSmlWLanAdapter::IntToDesLC(const TInt aLuid)
       
  3187     {
       
  3188     _DBG_FILE("CNSmlWLanAdapter::IntToDesLC(): begin");
       
  3189 
       
  3190     HBufC* buf = HBufC::NewLC(10);
       
  3191     TPtr ptrBuf = buf->Des();
       
  3192     ptrBuf.Num(aLuid);
       
  3193 
       
  3194     _DBG_FILE("CNSmlWLanAdapter::IntToDesLC(): end");
       
  3195     return buf;
       
  3196     }
       
  3197 
       
  3198 // ------------------------------------------------------------------------------------------------
       
  3199 // HBufC8* CNSmlWLanAdapter::IntToDes8LC(const TInt aLuid)
       
  3200 // ------------------------------------------------------------------------------------------------
       
  3201 HBufC8* CNSmlWLanAdapter::IntToDes8LC(const TInt aLuid)
       
  3202     {
       
  3203     _DBG_FILE("CNSmlWLanAdapter::IntToDes8LC(): begin");
       
  3204 
       
  3205     HBufC8* buf = HBufC8::NewLC(10);
       
  3206     TPtr8 ptrBuf = buf->Des();
       
  3207     ptrBuf.Num(aLuid);
       
  3208     
       
  3209     _DBG_FILE("CNSmlWLanAdapter::IntToDes8LC(): end");
       
  3210     return buf;
       
  3211     }
       
  3212 
       
  3213 // ------------------------------------------------------------------------------------------------
       
  3214 // TInt CNSmlWLanAdapter::NumOfUriSegs( const TDesC8& aUri )
       
  3215 // Return count of URI segments of aUri
       
  3216 // ------------------------------------------------------------------------------------------------
       
  3217 TInt CNSmlWLanAdapter::NumOfUriSegs( const TDesC8& aUri )
       
  3218     {
       
  3219     _DBG_FILE("CNSmlWLanAdapter::NumOfUriSegs(): begin");
       
  3220 
       
  3221     TInt count = 1;
       
  3222     for( TInt i=0; i<aUri.Length(); i++ )
       
  3223         {
       
  3224         if( aUri[i] == '/' )
       
  3225             count ++;
       
  3226         }
       
  3227 
       
  3228     _DBG_FILE("CNSmlWLanAdapter::NumOfUriSegs(): end");
       
  3229     return count;
       
  3230     }
       
  3231 
       
  3232 
       
  3233 // -------------------------------------------------------------------------------------
       
  3234 // CNSmlWLanAdapter::FillNodeInfoL()
       
  3235 // Fills the node info in ddf structure
       
  3236 // -------------------------------------------------------------------------------------
       
  3237 void CNSmlWLanAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,
       
  3238                                           TSmlDmAccessTypes aAccTypes,
       
  3239                                           MSmlDmDDFObject::TOccurence aOccurrence, 
       
  3240                                           MSmlDmDDFObject::TScope aScope, 
       
  3241                                           MSmlDmDDFObject::TDFFormat aFormat,
       
  3242                                           const TDesC8& aDescription )
       
  3243                                           
       
  3244     {
       
  3245     aNode.SetAccessTypesL(aAccTypes);
       
  3246     aNode.SetOccurenceL(aOccurrence);
       
  3247     aNode.SetScopeL(aScope);
       
  3248     aNode.SetDFFormatL(aFormat);
       
  3249     if(aFormat!=MSmlDmDDFObject::ENode)
       
  3250         {
       
  3251         aNode.AddDFTypeMimeTypeL(KNSmlMimeType);
       
  3252         }
       
  3253     aNode.SetDescriptionL(aDescription);
       
  3254     }
       
  3255 
       
  3256 
       
  3257 
       
  3258 // ------------------------------------------------------------------------------------------------
       
  3259 // TInt CNSmlWLanAdapter::GetEAPIdFromUri( const TDesC8& aUri )
       
  3260 // Return WLan ID number from URI
       
  3261 // ------------------------------------------------------------------------------------------------
       
  3262 TInt CNSmlWLanAdapter::GetEAPIdFromUri( const TDesC8& aUri )
       
  3263     {
       
  3264     DBG_ARGS8(_S8("WLanAdapter::GetEAPIdFromUri - <%S>"), &aUri );
       
  3265 
       
  3266     if( aUri.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*") ) == KErrNotFound )
       
  3267         {
       
  3268         return KErrNotFound;
       
  3269         }
       
  3270     
       
  3271     TInt begin = aUri.Find(_L8("/EAPId")) + 6;
       
  3272     if ( begin == KErrNotFound )
       
  3273     	{
       
  3274     	return KErrNotFound;
       
  3275     	}
       
  3276 
       
  3277     TInt eapId = DesToInt( aUri.Mid( begin, 3 ) );    
       
  3278     
       
  3279     return eapId;
       
  3280     }
       
  3281 
       
  3282 // ------------------------------------------------------------------------------------------------
       
  3283 // TInt CNSmlWLanAdapter::GetEncapsEAPIdFromUri( const TDesC8& aUri )
       
  3284 // Return WLan ID number from URI
       
  3285 // ------------------------------------------------------------------------------------------------
       
  3286 TInt CNSmlWLanAdapter::GetEncapsEAPIdFromUri( const TDesC8& aUri )
       
  3287     {
       
  3288     DBG_ARGS8(_S8("WLanAdapter::GetEncapsEAPIdFromUri - <%S>"), &aUri );
       
  3289 
       
  3290     if( aUri.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/EAPId*-*") ) == KErrNotFound )
       
  3291         {
       
  3292         return KErrNotFound;
       
  3293         }
       
  3294     
       
  3295     TInt begin = aUri.Find(_L8("/EAPId")) + 9;
       
  3296     if ( aUri[begin] != '-' )
       
  3297     	{
       
  3298     	return KErrNotFound;
       
  3299     	}
       
  3300     begin++;
       
  3301     TInt end = -1;
       
  3302     TInt count;
       
  3303 
       
  3304     for( count=0; count+begin<aUri.Length(); count++ )
       
  3305         {
       
  3306         if( aUri[begin+count]=='/' )
       
  3307             {
       
  3308             end = begin+count;
       
  3309             break;
       
  3310             }
       
  3311         else if( aUri.Length() == begin+count+1 )
       
  3312             {
       
  3313             count++;
       
  3314             end = begin+count;
       
  3315             break;
       
  3316             }
       
  3317         }
       
  3318 
       
  3319     if( end > 0 )
       
  3320         {
       
  3321         TInt eapId = DesToInt( aUri.Mid( begin, count ) );
       
  3322         return eapId;
       
  3323         }
       
  3324     return KErrNotFound;
       
  3325     }
       
  3326     
       
  3327 // ------------------------------------------------------------------------------------------------
       
  3328 // TInt CNSmlWLanAdapter::GetEAPIdFromUriL( const TDesC8& aUri )
       
  3329 // Return WLan ID number from URI
       
  3330 // ------------------------------------------------------------------------------------------------
       
  3331 TInt CNSmlWLanAdapter::GetServiceIdFromUriL( const TDesC8& aURI)
       
  3332     {
       
  3333     DBG_ARGS8(_S8("WLanAdapter::GetServiceIdFromUriL - <%S>"), &aURI );
       
  3334 
       
  3335     if( aURI.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP*") ) == KErrNotFound )
       
  3336         {
       
  3337         return KErrNotFound;
       
  3338         }
       
  3339     
       
  3340     TInt end = aURI.Find(_L8("/EAP")) + 4;
       
  3341     
       
  3342     if( end > 0 )
       
  3343         {        
       
  3344         
       
  3345        	HBufC8* luidBuf = iCallBack->GetLuidAllocL( aURI.Left( end ) );
       
  3346 		
       
  3347 		TInt serviceId = GetIdFromLuid( *luidBuf );
       
  3348         
       
  3349 	    delete luidBuf;		
       
  3350           
       
  3351 	    return serviceId;        
       
  3352         }
       
  3353  	return KErrNotFound;        
       
  3354  }
       
  3355 
       
  3356 // ------------------------------------------------------------------------------------------------
       
  3357 // TInt CNSmlWLanAdapter::GetSecSSIDFromUriL( const TDesC8& aUri )
       
  3358 // Return WLan ID number from URI
       
  3359 // ------------------------------------------------------------------------------------------------
       
  3360 TUint32 CNSmlWLanAdapter::GetSecSSIDFromUriL( const TDesC8& aUri )
       
  3361     {
       
  3362     DBG_ARGS8(_S8("WLanAdapter::GetSecSSIDFromUriL - <%S>"), &aUri );
       
  3363 
       
  3364     if( aUri.Match( _L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*") ) == KErrNotFound )
       
  3365         {
       
  3366         User::Leave(KErrNotFound);
       
  3367         }
       
  3368     _LIT8(KSSIDString, "/SecondarySSID/SecSSID");
       
  3369     TInt begin = aUri.Find(KSSIDString) + KSSIDString().Length();
       
  3370     TInt end = -1;
       
  3371     TInt count;
       
  3372 
       
  3373     for( count=0; count+begin<aUri.Length(); count++ )
       
  3374         {
       
  3375         if( aUri[begin+count]=='/' )
       
  3376             {
       
  3377             end = begin+count;
       
  3378             break;
       
  3379             }
       
  3380         else if( aUri.Length() == begin+count+1 )
       
  3381             {
       
  3382             count++;
       
  3383             end = begin+count;
       
  3384             break;
       
  3385             }
       
  3386         }
       
  3387 
       
  3388     if( end > 0 )
       
  3389         {
       
  3390         TLex8 lex(aUri.Mid( begin, count ));
       
  3391         TUint32 value = 0;
       
  3392         lex.Val( value, EDecimal );
       
  3393         return value;
       
  3394         }
       
  3395     else
       
  3396         {
       
  3397         User::Leave(KErrNotFound);
       
  3398         }
       
  3399     return 0;
       
  3400     }
       
  3401 
       
  3402 
       
  3403 // ------------------------------------------------------------------------------------------------
       
  3404 // TInt CNSmlWLanAdapter::GetEAPIdFromUri( const TDesC8& aUri )
       
  3405 // Return WLan ID number from URI
       
  3406 // ------------------------------------------------------------------------------------------------
       
  3407 TInt CNSmlWLanAdapter::GetCertificateIdFromUri( const TDesC8& aUri )
       
  3408     {
       
  3409     DBG_ARGS8(_S8("WLanAdapter::GetCertificateIdFromUri - <%S>"), &aUri );
       
  3410 
       
  3411     if( aUri.Match( _L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*") ) == KErrNotFound )
       
  3412         {
       
  3413         return KErrNotFound;
       
  3414         }
       
  3415     _LIT8(KCertString, "/Certificate/CertId");
       
  3416     
       
  3417     TInt begin = aUri.Find(KCertString);
       
  3418     if ( begin == KErrNotFound )
       
  3419         {
       
  3420         return KErrNotFound;
       
  3421         }
       
  3422     
       
  3423     begin += KCertString().Length();
       
  3424     
       
  3425     TInt end = -1;
       
  3426     TInt count;
       
  3427 
       
  3428     for( count=0; count+begin<aUri.Length(); count++ )
       
  3429         {
       
  3430         if( aUri[begin+count]=='/' )
       
  3431             {
       
  3432             end = begin+count;
       
  3433             break;
       
  3434             }
       
  3435         else if( aUri.Length() == begin+count+1 )
       
  3436             {
       
  3437             count++;
       
  3438             end = begin+count;
       
  3439             break;
       
  3440             }
       
  3441         }
       
  3442 
       
  3443     if( end > 0 )
       
  3444         {
       
  3445         TInt certId = DesToInt( aUri.Mid( begin, count ) );
       
  3446         return certId;
       
  3447         }
       
  3448     return KErrNotFound;
       
  3449     }
       
  3450 
       
  3451 
       
  3452 // ------------------------------------------------------------------------------------------------
       
  3453 // TInt CNSmlWLanAdapter::GetWepKeyIdFromUri( const TDesC8& aUri )
       
  3454 // Returns WepKey ID number from URI
       
  3455 // ------------------------------------------------------------------------------------------------
       
  3456 TInt CNSmlWLanAdapter::GetWepKeyIdFromUri( const TDesC8& aUri )
       
  3457     {
       
  3458     if( aUri.Match( _L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*") ) == KErrNotFound )
       
  3459         {
       
  3460         return KErrNotFound;
       
  3461         }
       
  3462     
       
  3463     TInt begin = aUri.Find(_L8("WEPKey/WKId")) + 11;
       
  3464     TInt end = -1;
       
  3465     TInt count;
       
  3466 
       
  3467     for( count=0; count<aUri.Length()-11; count++ )
       
  3468         {
       
  3469         if( aUri[begin+count]=='/' )
       
  3470             {
       
  3471             end = begin+count;
       
  3472             break;
       
  3473             }
       
  3474         
       
  3475         else if( aUri.Length() == begin+count+1 )
       
  3476             {
       
  3477             count ++;
       
  3478             end = begin+count;
       
  3479             break;
       
  3480             }
       
  3481         }
       
  3482 
       
  3483     if( end > 0 )
       
  3484         {
       
  3485         TInt wlanId = DesToInt( aUri.Mid( begin, count ) );
       
  3486         return wlanId;
       
  3487         }
       
  3488     return KErrNotFound;
       
  3489     }
       
  3490 
       
  3491 // ------------------------------------------------------------------------------------------------
       
  3492 // TInt CNSmlWLanAdapter::GetWepKeyIdFromLuid( const TDesC8& aLuid )
       
  3493 // Return id number of wepkey
       
  3494 // ------------------------------------------------------------------------------------------------
       
  3495 TInt CNSmlWLanAdapter::GetWepKeyIdFromLuid( const TDesC8& aLuid )
       
  3496     {
       
  3497     TLex8 iLex( aLuid );
       
  3498 
       
  3499     TInt luid;
       
  3500     if (iLex.Val( luid ) == KErrNone)
       
  3501         {
       
  3502         if( luid > 1000 )
       
  3503             {
       
  3504             return luid / 1000;
       
  3505             }
       
  3506         else
       
  3507             {
       
  3508             return KErrNotFound;
       
  3509             }
       
  3510         }
       
  3511     else
       
  3512         {
       
  3513         return KErrNotFound;
       
  3514         }
       
  3515     }
       
  3516 
       
  3517 // ------------------------------------------------------------------------------------------------
       
  3518 // TInt CNSmlWLanAdapter::GetIdFromLuid( const TDesC& aLuid )
       
  3519 // Return luid of wlan node
       
  3520 // ------------------------------------------------------------------------------------------------
       
  3521 TInt CNSmlWLanAdapter::GetIdFromLuid( const TDesC8& aLuid )
       
  3522     {
       
  3523     TLex8 iLex( aLuid );
       
  3524 
       
  3525     TInt luid;
       
  3526     if( iLex.Val(luid) == KErrNone )
       
  3527         {
       
  3528         if( luid < 1000 )
       
  3529             {
       
  3530             return luid;
       
  3531             }
       
  3532         else
       
  3533             {
       
  3534             TInt tmp = luid / 1000 * 1000; //First number of luid > 1000
       
  3535             return luid - tmp;
       
  3536             }
       
  3537         }
       
  3538     else
       
  3539         {
       
  3540         return KErrNotFound;
       
  3541         }
       
  3542     }
       
  3543 
       
  3544 // ------------------------------------------------------------------------------------------------
       
  3545 // void CNSmlWLanAdapter::ExecuteBufferL( TBool aFinal )
       
  3546 // Executes buffered commands from iBuffer
       
  3547 // ------------------------------------------------------------------------------------------------
       
  3548 void CNSmlWLanAdapter::ExecuteBufferL( TBool aFinal )
       
  3549     {
       
  3550     for( TInt index=0; index<iBuffer->Count(); index++ )
       
  3551         {
       
  3552         DBG_ARGS8(_S8("WLanAdapter::ExecuteBuffer(): Buf count: <%D> index: <%D>"), iBuffer->Count(), index );
       
  3553 
       
  3554         if( iBuffer->At(index).iExecuted )
       
  3555             {
       
  3556             continue;
       
  3557             }
       
  3558         TInt err = 0;
       
  3559 
       
  3560         TInt luid = iBuffer->At(index).iLuid;
       
  3561         TInt wepKeyId = iBuffer->At(index).iWepKeyId;
       
  3562         if( ! wepKeyId && ! aFinal )
       
  3563             {
       
  3564             continue;
       
  3565             }
       
  3566 
       
  3567         if( wepKeyId > 4 ||
       
  3568             ! wepKeyId && aFinal )
       
  3569             {
       
  3570             if( iBuffer->At(index).iDataStatusRef )
       
  3571                 iCallBack->SetStatusL( iBuffer->At(index).iDataStatusRef, CSmlDmAdapter::EError );
       
  3572             if( iBuffer->At(index).iNodeStatusRef )
       
  3573                 iCallBack->SetStatusL( iBuffer->At(index).iNodeStatusRef, CSmlDmAdapter::EError );
       
  3574             if( iBuffer->At(index).iLengthStatusRef )
       
  3575                 iCallBack->SetStatusL( iBuffer->At(index).iLengthStatusRef, CSmlDmAdapter::EError );
       
  3576 
       
  3577             iBuffer->At(index).iIdStatusRef = 0;
       
  3578             iBuffer->At(index).iNodeStatusRef = 0;
       
  3579             iBuffer->At(index).iDataStatusRef = 0;
       
  3580             iBuffer->At(index).iLengthStatusRef = 0;
       
  3581             iBuffer->At(index).iExecuted = ETrue;
       
  3582 
       
  3583             continue;
       
  3584             }
       
  3585         
       
  3586         if( iBuffer->At(index).iDataSet &&
       
  3587             iBuffer->At(index).iWepKeyId > 0 )
       
  3588             {
       
  3589             iWlanSettings->GetWlanSettings( luid, *iSettings );
       
  3590 
       
  3591             switch( wepKeyId )
       
  3592                 {
       
  3593             case 1:
       
  3594                 iSettings->WepKey1 = iBuffer->At(index).iData->Des();
       
  3595                 break;
       
  3596             case 2:
       
  3597                 iSettings->WepKey2 = iBuffer->At(index).iData->Des();
       
  3598                 break;
       
  3599             case 3:
       
  3600                 iSettings->WepKey3 = iBuffer->At(index).iData->Des();
       
  3601                 break;
       
  3602             case 4:
       
  3603                 iSettings->WepKey4 = iBuffer->At(index).iData->Des();
       
  3604                 break;
       
  3605             default:
       
  3606                 continue;
       
  3607                 }
       
  3608 
       
  3609             err = iWlanSettings->WriteWlanSettings( *iSettings );
       
  3610             if( err == KErrNone )
       
  3611                 {
       
  3612                 iCallBack->SetStatusL( iBuffer->At(index).iDataStatusRef, CSmlDmAdapter::EOk );
       
  3613                 }
       
  3614             else
       
  3615                 {
       
  3616                 iCallBack->SetStatusL( iBuffer->At(index).iDataStatusRef, CSmlDmAdapter::EError );
       
  3617                 }
       
  3618 
       
  3619             iBuffer->At(index).iDataStatusRef = 0;
       
  3620             }
       
  3621 
       
  3622         TBuf8<5> addLUID;
       
  3623         addLUID.AppendNum( wepKeyId );
       
  3624         addLUID.AppendNumFixedWidth( luid, EDecimal, 3 );
       
  3625         
       
  3626         iCallBack->SetMappingL( iBuffer->At( index).iUri->Des(), addLUID );
       
  3627         if( iBuffer->At(index).iIdStatusRef )
       
  3628             iCallBack->SetStatusL( iBuffer->At(index).iIdStatusRef, CSmlDmAdapter::EOk );
       
  3629         if( iBuffer->At(index).iNodeStatusRef )
       
  3630             iCallBack->SetStatusL( iBuffer->At(index).iNodeStatusRef, CSmlDmAdapter::EOk );
       
  3631         if( iBuffer->At(index).iLengthStatusRef )
       
  3632             iCallBack->SetStatusL( iBuffer->At(index).iLengthStatusRef, CSmlDmAdapter::EOk );
       
  3633 
       
  3634         iBuffer->At(index).iIdStatusRef = 0;
       
  3635         iBuffer->At(index).iNodeStatusRef = 0;
       
  3636         iBuffer->At(index).iLengthStatusRef = 0;
       
  3637         iBuffer->At(index).iExecuted = ETrue;
       
  3638         }
       
  3639 
       
  3640     //Clean executed command from buffer
       
  3641     for( TInt i=0; i<iBuffer->Count(); i++ )
       
  3642         {
       
  3643         if( iBuffer->At(i).iExecuted )
       
  3644             {
       
  3645             if( iBuffer->At(i).iUri )
       
  3646                 {
       
  3647                 delete iBuffer->At(i).iUri;
       
  3648                 iBuffer->At(i).iUri = 0;
       
  3649                 }
       
  3650             if( iBuffer->At(i).iData )
       
  3651                 {
       
  3652                 delete iBuffer->At(i).iData;
       
  3653                 iBuffer->At(i).iData = 0;
       
  3654                 }
       
  3655             iBuffer->Delete(i);
       
  3656             iBuffer->Compress();
       
  3657             }
       
  3658         }
       
  3659 // Secondary SSID Buffer 
       
  3660       for( TInt index=0; index<iSecondaryBuffer.Count(); index++ )
       
  3661         {
       
  3662         DBG_ARGS8(_S8("WLanAdapter::ExecuteBuffer(): Buf count: <%D> index: <%D>"), iBuffer->Count(), index );
       
  3663 
       
  3664         if( iSecondaryBuffer[index]->iExecuted )
       
  3665             {
       
  3666             continue;
       
  3667             }
       
  3668                
       
  3669         TSecondarySSID ssid;
       
  3670         ssid.ScannedId = iSecondaryBuffer[index]->ScannedId;
       
  3671         ssid.UsedId = iSecondaryBuffer[index]->UsedId;
       
  3672         
       
  3673         DBG_ARGS8(_S8("CWlanadaptes::Execute Buffer - WLAN_SEC_SSID_SCANNED_SSID uri: <%S> ad  WLAN_SEC_SSID_USED_SSID : <%S>"), &iSecondaryBuffer[index]->ScannedId, &iSecondaryBuffer[index]->UsedId );
       
  3674         
       
  3675         TInt retval = iWlanSettings->WriteSecondarySSIDL(iSecondaryBuffer[index]->wlanLuid, ssid, ETrue);
       
  3676         iSecondaryBuffer[index]->iExecuted=ETrue;
       
  3677         
       
  3678         }
       
  3679       // EAP settings
       
  3680       for( TInt i = 0 ; i < iEAPBuffer.Count() ; i++ )
       
  3681       	{
       
  3682       	// Check if this method has encapsulated methods
       
  3683       	for ( TInt j = 0; j < iEAPBuffer.Count() ; j++ )
       
  3684       		{
       
  3685       		if ( iEAPBuffer[i]->iEAPSettings->iEAPType == iEAPBuffer[j]->iEncapsulatingEAPId )
       
  3686       			{
       
  3687       			// j is encapsulated inside i
       
  3688       			iEAPBuffer[i]->iEAPSettings->iEncapsulatedEAPTypes.Append( iEAPBuffer[j]->iEAPSettings->iEAPType );
       
  3689 				iEAPBuffer[i]->iEAPSettings->iEncapsulatedEAPTypesPresent = ETrue;
       
  3690       			}
       
  3691       		}
       
  3692       	
       
  3693       	TRAPD( err, iWlanSettings->GetEAPInterfaceL(iEAPBuffer[i]->iWLANServiceId, 
       
  3694       												iEAPBuffer[i]->iEncapsulatingEAPId, 
       
  3695       												static_cast<TInt> (iEAPBuffer[i]->iEAPSettings->iEAPType ) ) );
       
  3696  		if ( err == KErrNone )
       
  3697  			{ 			
       
  3698  			err = iWlanSettings->WriteEAPSettings( *iEAPBuffer[i]->iEAPSettings );
       
  3699  			}
       
  3700       											      											      	
       
  3701       	MSmlDmAdapter::TError status;
       
  3702       	switch ( err ) 
       
  3703       		{
       
  3704       			case KErrNotFound:
       
  3705       				{
       
  3706       				status = CSmlDmAdapter::ENotFound;
       
  3707       				break;
       
  3708       				}
       
  3709       			case KErrNone:
       
  3710       				{
       
  3711       				status = CSmlDmAdapter::EOk;
       
  3712       				break;
       
  3713       				}
       
  3714       			default:
       
  3715       				{
       
  3716       				status = CSmlDmAdapter::EError;      				
       
  3717       				}
       
  3718       		}
       
  3719       		
       
  3720       	for ( TInt j = 0; j < iEAPBuffer[i]->iStatusRefArray.Count() ; j++)
       
  3721       		{
       
  3722       			iCallBack->SetStatusL( iEAPBuffer[i]->iStatusRefArray[j], status );	
       
  3723       		}      	
       
  3724       	}      	
       
  3725       	for ( TInt i = 0 ; i < iEAPBuffer.Count() ; i++ )
       
  3726     		{
       
  3727     		iEAPBuffer[i]->iStatusRefArray.Close();
       
  3728     		iEAPBuffer[i]->iEAPSettings->iEncapsulatedEAPTypes.Close();
       
  3729     		iEAPBuffer[i]->iEAPSettings->iCipherSuites.Close();
       
  3730     		delete iEAPBuffer[i]->iEAPSettings;
       
  3731     		iEAPBuffer[i]->iEAPSettings = NULL;
       
  3732 	    	}
       
  3733       	iEAPBuffer.ResetAndDestroy();
       
  3734     }
       
  3735 
       
  3736 
       
  3737 //=============================================
       
  3738 //      CNSmlWLanAdapter::ConvertTo8LC()
       
  3739 //      Converts string value to 8-bit
       
  3740 //      
       
  3741 //=============================================
       
  3742 TDesC8& CNSmlWLanAdapter::ConvertTo8LC( const TDesC& aSource )
       
  3743     {
       
  3744     HBufC8* buf = HBufC8::NewLC( aSource.Length()*2);
       
  3745     TPtr8 bufPtr = buf->Des();
       
  3746     CnvUtfConverter::ConvertFromUnicodeToUtf8( bufPtr, aSource );
       
  3747 
       
  3748     return *buf;
       
  3749     }
       
  3750 
       
  3751 //=============================================
       
  3752 //      CNSmlWLanAdapter::ConvertTo16LC()
       
  3753 //      Converts string value to 16-bit
       
  3754 //      
       
  3755 //=============================================
       
  3756 TDesC16& CNSmlWLanAdapter::ConvertTo16LC( const TDesC8& aSource)
       
  3757     {
       
  3758     HBufC16* buf16 = HBufC16::NewLC( aSource.Length() );
       
  3759     TPtr bufPtr16 = buf16->Des();
       
  3760 
       
  3761     CnvUtfConverter::ConvertToUnicodeFromUtf8(bufPtr16, aSource);
       
  3762 
       
  3763     return *buf16;
       
  3764     }
       
  3765 
       
  3766 void CNSmlWLanAdapter::ResetEAPStructL()
       
  3767     {
       
  3768     DeleteEAPStructL();
       
  3769     iEAPSettings = new (ELeave) EAPSettings;
       
  3770     }
       
  3771 
       
  3772     
       
  3773 void CNSmlWLanAdapter::DeleteEAPStructL()
       
  3774     {
       
  3775     if (iEAPSettings != NULL)
       
  3776         {        
       
  3777         if (iEAPSettings->iCertificatesPresent)
       
  3778             {
       
  3779             iEAPSettings->iCertificates.Reset();
       
  3780             }
       
  3781         iEAPSettings->iEncapsulatedEAPTypes.Close();
       
  3782         iEAPSettings->iCipherSuites.Close();
       
  3783             
       
  3784         delete iEAPSettings;
       
  3785         iEAPSettings = NULL;
       
  3786         }
       
  3787     }
       
  3788 
       
  3789 
       
  3790 void CNSmlWLanAdapter::DesToBufferL(CBufBase& aTo, const TDesC& aFrom)
       
  3791     {
       
  3792     aTo.InsertL( 0, ConvertTo8LC(aFrom) );
       
  3793     CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
  3794     }
       
  3795 
       
  3796 void CNSmlWLanAdapter::FillCipherSuiteBufferL(CBufBase& aBuffer)
       
  3797     {
       
  3798     if (iEAPSettings == NULL || !iEAPSettings->iCipherSuitesPresent)
       
  3799         {
       
  3800         return;
       
  3801         }
       
  3802                         // 0    5    10   15   20   25   30   35
       
  3803     _LIT8(KPlus, "+");
       
  3804     aBuffer.InsertL(0,KSuitesDefault);
       
  3805     TInt count = iEAPSettings->iCipherSuites.Count();
       
  3806     for (TInt i=count-1; i>=0;--i)
       
  3807         {
       
  3808         switch (iEAPSettings->iCipherSuites[i])
       
  3809             {
       
  3810             case RSA_3DES_SHA:
       
  3811                 {
       
  3812                 aBuffer.Write(0, KPlus);
       
  3813                 break;
       
  3814                 }
       
  3815             case DHE_RSA_3DES_SHA:
       
  3816                 {
       
  3817                 aBuffer.Write(5, KPlus);
       
  3818                 break;
       
  3819                 }
       
  3820             case DHE_DSS_3DES_SHA:
       
  3821                 {
       
  3822                 aBuffer.Write(10, KPlus);
       
  3823                 break;
       
  3824                 }
       
  3825             case RSA_AES_SHA:
       
  3826                 {
       
  3827                 aBuffer.Write(15, KPlus);
       
  3828                 break;
       
  3829                 }
       
  3830             case DHE_RSA_AES_SHA:
       
  3831                 {
       
  3832                 aBuffer.Write(20, KPlus);
       
  3833                 break;
       
  3834                 }
       
  3835             case DHE_DSS_AES_SHA:
       
  3836                 {
       
  3837                 aBuffer.Write(25, KPlus);
       
  3838                 break;
       
  3839                 }
       
  3840             case RSA_RC4_MD5:
       
  3841                 {
       
  3842                 aBuffer.Write(30, KPlus);
       
  3843                 break;
       
  3844                 }
       
  3845             case RSA_RC4_SHA:
       
  3846                 {
       
  3847                 aBuffer.Write(35, KPlus);
       
  3848                 break;
       
  3849                 }
       
  3850             default:
       
  3851                 {
       
  3852                 break;
       
  3853                 }
       
  3854                 
       
  3855             }
       
  3856         }
       
  3857         
       
  3858     }
       
  3859 
       
  3860     
       
  3861 void CNSmlWLanAdapter::FillCipherSuitesL(const TDesC8& aObject, const TInt aLuid)
       
  3862     {
       
  3863     if (iEAPBuffer[aLuid] == NULL)
       
  3864         {
       
  3865         return;
       
  3866         }
       
  3867     iEAPBuffer[aLuid]->iEAPSettings->iCipherSuites.Reset();
       
  3868     iEAPBuffer[aLuid]->iEAPSettings->iCipherSuitesPresent = EFalse; // init to EFalse
       
  3869     
       
  3870     TChar plus('+');
       
  3871     
       
  3872     TInt length = aObject.Length();
       
  3873     for (TInt i=0; i+3<length;i+=5)
       
  3874         {
       
  3875         if (aObject[i] == plus)
       
  3876             {
       
  3877             TLex8 lex(aObject.Mid(i+1, 3));
       
  3878             TUint suite;
       
  3879             lex.Val(suite);
       
  3880             iEAPBuffer[aLuid]->iEAPSettings->iCipherSuites.Append(suite);
       
  3881             iEAPBuffer[aLuid]->iEAPSettings->iCipherSuitesPresent = ETrue;
       
  3882             }
       
  3883         }
       
  3884     }
       
  3885 
       
  3886 void CNSmlWLanAdapter::ConvertEAPStringToIds( const TDesC8& aEAPString, TDes8& aExpandedId, EAPSettings::TEapType& aId)
       
  3887 	{
       
  3888     if ( aEAPString == KEAPSIM )
       
  3889 		{	
       
  3890 		aExpandedId.Copy( KEapSimTypeId, KExpandedEAPIdLength );		
       
  3891 		aId = EAPSettings::EEapSim;
       
  3892 		}
       
  3893     else if( aEAPString == KEAPAKA )
       
  3894         {
       
  3895 		aExpandedId.Copy( KEapAkaTypeId, KExpandedEAPIdLength );	
       
  3896 		aId = EAPSettings::EEapAka;	
       
  3897         }
       
  3898     else if( aEAPString == KEAPTLS )
       
  3899         {		
       
  3900 		aExpandedId.Copy( KEapTlsTypeId, KExpandedEAPIdLength );	
       
  3901 		aId = EAPSettings::EEapTls;	
       
  3902         }
       
  3903     else if( aEAPString == KEAPPEAP )
       
  3904     	{   
       
  3905 		aExpandedId.Copy( KEapPeapTypeId, KExpandedEAPIdLength );	
       
  3906 		aId = EAPSettings::EEapPeap;	
       
  3907         }
       
  3908     else if( aEAPString == KEAPTTLS )
       
  3909         {
       
  3910 		aExpandedId.Copy( KEapTtlsTypeId, KExpandedEAPIdLength );		
       
  3911 		aId = EAPSettings::EEapTtls;
       
  3912         }
       
  3913    else if( aEAPString == KEAPLEAP )
       
  3914         {
       
  3915 		aExpandedId.Copy( KEapLeapTypeId, KExpandedEAPIdLength );
       
  3916 		aId = EAPSettings::EEapLeap;		
       
  3917         }                                    
       
  3918    else if( aEAPString == KEAPMSCHAPV2 )
       
  3919         {
       
  3920 		aExpandedId.Copy( KEapMschapv2TypeId, KExpandedEAPIdLength );		
       
  3921 		aId = EAPSettings::EEapMschapv2;
       
  3922         }     
       
  3923    else if( aEAPString == KMSCHAPV2 )
       
  3924         {
       
  3925 		aExpandedId.Copy( KMschapv2TypeId, KExpandedEAPIdLength );		
       
  3926 		aId = EAPSettings::EPlainMschapv2;
       
  3927         }     
       
  3928    else if( aEAPString == KEAPGTC )
       
  3929    		{
       
  3930    		aExpandedId.Copy( KEapGtcTypeId, KExpandedEAPIdLength );
       
  3931 		aId = EAPSettings::EEapGtc;
       
  3932         }
       
  3933    else if( aEAPString == KEAPFAST )
       
  3934         {		
       
  3935 		aExpandedId.Copy( KEapFastTypeId, KExpandedEAPIdLength );		
       
  3936 		aId = EAPSettings::EEapFast;
       
  3937         }
       
  3938    else if( aEAPString == KEAPTTLSPAP )
       
  3939        {		
       
  3940 		aExpandedId.Copy( KTtlspapTypeId, KExpandedEAPIdLength );		
       
  3941 		aId = static_cast<EAPSettings::TEapType>(98);
       
  3942        }
       
  3943     else
       
  3944         {		
       
  3945 		aExpandedId.Copy( KEapNoneId, KExpandedEAPIdLength );
       
  3946 		aId = EAPSettings::EEapNone;
       
  3947         }
       
  3948 
       
  3949 	}
       
  3950 
       
  3951 
       
  3952 // end of file