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