omadmadapters/connmoadapter/src/NapBranch.cpp
changeset 30 d3981f4fe6a4
equal deleted inserted replaced
27:516a867811c3 30:d3981f4fe6a4
       
     1 /*
       
     2  * ==============================================================================
       
     3  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     4  * All rights reserved.
       
     5  * This component and the accompanying materials are made available
       
     6  * under the terms of "Eclipse Public License v1.0"
       
     7  * which accompanies this distribution, and is available
       
     8  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9  *
       
    10  * Initial Contributors:
       
    11  * Nokia Corporation - initial contribution.
       
    12  *
       
    13  * Contributors:
       
    14  * 
       
    15  * Description:
       
    16  * 
       
    17  * ==============================================================================
       
    18  */
       
    19 #include <featmgr.h>
       
    20 #include <cmmanagerext.h> 
       
    21 #include <cmpluginpacketdatadef.h>
       
    22 #include <cmpluginwlandef.h>
       
    23 #include <cmconnectionmethoddef.h>
       
    24 #include <nsmldmtreedbclient.h>
       
    25 #include "NapBranch.h"
       
    26 #include "Utils.h"
       
    27 #include "AddBuffer.h"
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "NapBranchTraces.h"
       
    31 #endif
       
    32 // ------------------------------------------------------------------------------------------------
       
    33 // Constants
       
    34 // ------------------------------------------------------------------------------------------------
       
    35 // NAP Branch
       
    36 _LIT8( KCMDdfID, "ID" );
       
    37 _LIT8( KCMDdfName, "Name" );
       
    38 _LIT8( KCMDdfAddrType, "AddrType" );
       
    39 _LIT8( KCMDdfAddr, "Addr" );
       
    40 _LIT8( KCMDdfIP, "IP" );
       
    41 _LIT8( KCMDdfAuthInfo, "AuthInfo" );
       
    42 _LIT8( KCMDdfAuthType, "AuthType" );
       
    43 _LIT8( KCMDdfBearerType, "BearerType" );
       
    44 _LIT8( KCMDdfBearerParams, "BearerParams" );
       
    45 _LIT8( KCMDdfIPv4, "IPv4" );
       
    46 _LIT8( KCMDdfAutoConfig, "AutoConfig" );
       
    47 _LIT8( KCMDdfIPAddr, "IPAddr" );
       
    48 _LIT8( KCMDdfNetMask, "NetMask" );
       
    49 _LIT8( KCMDdfGateway, "Gateway" );
       
    50 _LIT8( KCMDdfAutoDNS, "AutoDNS" );
       
    51 _LIT8( KCMDdfDNS, "DNS" );
       
    52 _LIT8( KCMDdfServers, "Servers" );
       
    53 _LIT8( KCMDdfServer, "Server" );
       
    54 _LIT8( KCMDdfAuthName, "AuthName" );
       
    55 _LIT8( KCMDdfAuthSecret, "AuthSecret" );
       
    56 // NAP Child URI List
       
    57 _LIT8( KCMNapFields, "ID/Name/AddrType/Addr/IP/AuthInfo/BearerType" );
       
    58 _LIT8( KCMNIPFields, "IPv4" );
       
    59 _LIT8( KCMNIPv4Fields, "AutoConfig/IPAddr/NetMask/Gateway/AutoDNS/DNS" );
       
    60 _LIT8( KCMNDNSFields, "Servers" );
       
    61 _LIT8( KCMNAuthInfoFields, "AuthType/AuthName/AuthSecret" );
       
    62 _LIT8( KCMNDNSServersFields, "Addr");
       
    63 _LIT8( KSlash, "/" );
       
    64 _LIT8( KDynamicNapNode, "NAP/*" );
       
    65 _LIT8( KDynamicNapNodeChildUri, "NAP/*/*" );
       
    66 _LIT8( KDynamicIPNode, "NAP/*/IP" );
       
    67 _LIT8( KDynamicIPNodeChildUri, "NAP/*/IP/*" );
       
    68 _LIT8( KDynamicIPv4Node, "NAP/*/IP/IPv4" );
       
    69 _LIT8( KDynamicIPv4NodeChildUri, "NAP/*/IP/IPv4/*" );
       
    70 _LIT8( KDynamicIPv4DnsNode, "NAP/*/IP/IPv4/DNS" );
       
    71 _LIT8( KDynamicIPv4DnsNodeChildUri, "NAP/*/IP/IPv4/DNS/*" );
       
    72 _LIT8( KDynamicIPv4DnsServersNode, "NAP/*/IP/IPv4/DNS/Servers" );
       
    73 _LIT8( KDynamicIPv4DnsServersNodeChildUri, "NAP/*/IP/IPv4/DNS/Servers/*" );
       
    74 _LIT8( KDynamicIPv4DnsServersNodeChildUriNodes, "NAP/*/IP/IPv4/DNS/Servers/*/*");
       
    75 _LIT8( KDynamicAuthInfoNode, "NAP/*/AuthInfo");
       
    76 _LIT8( KDynamicAuthInfoNodeChildUri, "NAP/*/AuthInfo/*");
       
    77 _LIT8( KNapBearerTypeUri, "NAP/*/BearerType");
       
    78 _LIT8( KNapAddrUri, "NAP/*/Addr");
       
    79 _LIT8( KNapDNSAddr1Uri, "NAP/*/Server1/Addr");
       
    80 _LIT8( KNapDNSAddr2Uri, "NAP/*/Server2/Addr");
       
    81 _LIT8( KNapIPv4AddrUri, "NAP/*/IPv4/*Addr");
       
    82 _LIT8( KPacketDataBearerType, "3GPPPS");
       
    83 _LIT8( KGPRSAddrType, "APN");
       
    84 _LIT8( KGPRSAuthType, "PAP");
       
    85 
       
    86 
       
    87 TInt const KInvalidBearerType = 0;
       
    88 TInt const KBufferExpandSize = 128;
       
    89 TInt const KNumOfNAPNodes = 8;
       
    90 TInt const KMaxResultSize = 64;
       
    91 TInt const KMaxDnsAddr = 2;
       
    92 _LIT8( KFalse, "False");
       
    93 _LIT8( KTrue, "True");
       
    94 
       
    95 _LIT8( KDynamicNodePrefix, "NAPId" );
       
    96 
       
    97 // ======== LOCAL FUNCTIONS =========
       
    98 //-----------------------------------------------------------------------------
       
    99 // TUint32 CNapBranch::CheckForUnmodifiableFieldL()
       
   100 //-----------------------------------------------------------------------------
       
   101 CSmlDmAdapter::TError CNapBranch::GetUnmodifiableFieldValueL(
       
   102         const TDesC8& aUri, CBufBase* aResult)
       
   103     {
       
   104     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_GETUNMODIFIABLEFIELDVALUEL_ENTRY,
       
   105             "ENTRY: CNapBranch::GetUnmodifiableFieldValueL;aUri=%s", aUri );
       
   106 
       
   107     CSmlDmAdapter::TError retval( CSmlDmAdapter::ENotFound );
       
   108     TPtrC8 nodeName = CUtils::GetLastURISeg( aUri );
       
   109 
       
   110     if ( nodeName.Match( KCMDdfAddrType ) != KErrNotFound )
       
   111         {
       
   112         aResult->InsertL( 0, KGPRSAddrType );
       
   113         retval = CSmlDmAdapter::EOk;
       
   114         }
       
   115     else if ( nodeName.Match( KCMDdfBearerType ) != KErrNotFound )
       
   116         {
       
   117         aResult->InsertL( 0, KPacketDataBearerType );
       
   118         retval = CSmlDmAdapter::EOk;
       
   119         }
       
   120     else if ( nodeName.Match( KCMDdfAuthType ) != KErrNotFound )
       
   121         {
       
   122         aResult->InsertL( 0, KGPRSAuthType );
       
   123         retval = CSmlDmAdapter::EOk;
       
   124         }
       
   125     else if ( nodeName.Match( KCMDdfID ) != KErrNotFound )
       
   126         {
       
   127         TPtrC8 dynamicNode = GetDynamicNAPNodeUri( aUri );
       
   128         aResult->InsertL( 0, dynamicNode );
       
   129         retval = CSmlDmAdapter::EOk;
       
   130         }
       
   131 
       
   132     OstTrace1( TRACE_NORMAL, CNAPBRANCH_GETUNMODIFIABLEFIELDVALUEL_EXIT,
       
   133             "EXIT: CNapBranch::GetUnmodifiableFieldValueL;retval=%{TError}", retval );
       
   134 
       
   135     return retval;
       
   136     }
       
   137 //-----------------------------------------------------------------------------
       
   138 // CSmlDmAdapter::TErrorCNapBranch::GetLeafData()
       
   139 //-----------------------------------------------------------------------------
       
   140 CSmlDmAdapter::TError CNapBranch::GetLeafDataL(const TDesC8& aURI,
       
   141         RCmConnectionMethodExt& aCm, CBufBase* aResult)
       
   142     {
       
   143     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_GETLEAFDATAL_ENTRY,
       
   144             "ENTRY: CNapBranch::GetLeafDataL;aURI=%s", aURI );
       
   145 
       
   146     TUint32 attributeRef( 0 );
       
   147     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
       
   148     HBufC16* resultTmp;
       
   149 
       
   150     attributeRef = MapUriToCmAttribute( aURI );
       
   151     switch ( attributeRef )
       
   152         {
       
   153         case CMManager::ECmName:
       
   154         case CMManager::EPacketDataIPNameServer1:
       
   155         case CMManager::EPacketDataIPNameServer2:
       
   156         case CMManager::EPacketDataAPName:
       
   157         case CMManager::EPacketDataIFAuthName:
       
   158         case CMManager::EPacketDataIPAddr:
       
   159         case CMManager::EPacketDataIPNetmask:
       
   160         case CMManager::EPacketDataIPGateway:
       
   161         resultTmp = aCm.GetStringAttributeL( attributeRef );
       
   162         CleanupStack::PushL( resultTmp );
       
   163         aResult->InsertL( 0, CUtils::ConvertTo8LC( *resultTmp ) );
       
   164         CleanupStack::PopAndDestroy(); // ConvertTo8LC
       
   165         CleanupStack::PopAndDestroy( resultTmp );
       
   166         break;
       
   167         case CMManager::EPacketDataIPAddrFromServer:
       
   168         case CMManager::EPacketDataIPDNSAddrFromServer:
       
   169         if ( aCm.GetBoolAttributeL( attributeRef ) )
       
   170             {
       
   171             aResult->InsertL( 0, KTrue );
       
   172             }
       
   173         else
       
   174             {
       
   175             aResult->InsertL( 0, KFalse );
       
   176             }
       
   177 
       
   178         break;
       
   179         default:
       
   180         status = GetUnmodifiableFieldValueL( aURI, aResult );
       
   181         break;
       
   182         }
       
   183     OstTrace1( TRACE_NORMAL, CNAPBRANCH_GETLEAFDATAL_EXIT,
       
   184             "EXIT: CNapBranch::GetLeafDataL;status=%{TError}", status );
       
   185 
       
   186     return status;
       
   187     }
       
   188 
       
   189 //-----------------------------------------------------------------------------
       
   190 // CNapBranch::GetUnmodifiableFieldAddResult()
       
   191 //-----------------------------------------------------------------------------
       
   192 CSmlDmAdapter::TError CNapBranch::GetUnmodifiableFieldAddResult(
       
   193         const TDesC8& aUri, const TDesC8& aObject)
       
   194     {
       
   195     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_GETUNMODIFIABLEFIELDADDRESULT_ENTRY,
       
   196             "ENTRY: CNapBranch::GetUnmodifiableFieldAddResult;aUri=%s", aUri );
       
   197 
       
   198     CSmlDmAdapter::TError retval( CSmlDmAdapter::ENotFound );
       
   199     TPtrC8 nodeName = CUtils::GetLastURISeg( aUri );
       
   200 
       
   201     if ( nodeName.Match( KCMDdfAddrType ) != KErrNotFound )
       
   202         {
       
   203         if ( aObject.Match( KGPRSAddrType ) != KErrNotFound )
       
   204             {
       
   205             retval = CSmlDmAdapter::EOk;
       
   206             }
       
   207         else
       
   208             {
       
   209             retval = CSmlDmAdapter::EInvalidObject;
       
   210             }
       
   211         }
       
   212     else if ( nodeName.Match( KCMDdfAuthType ) != KErrNotFound )
       
   213         {
       
   214         if ( aObject.Match( KGPRSAuthType ) != KErrNotFound )
       
   215             {
       
   216             retval = CSmlDmAdapter::EOk;
       
   217             }
       
   218         else
       
   219             {
       
   220             retval = CSmlDmAdapter::EInvalidObject;
       
   221             }
       
   222         }
       
   223 
       
   224     OstTrace1( TRACE_NORMAL, DUP1_CNAPBRANCH_GETUNMODIFIABLEFIELDADDRESULT_EXIT,
       
   225             "EXIT: CNapBranch::GetUnmodifiableFieldAddResult;retval=%{TError}", retval );
       
   226 
       
   227     return retval;
       
   228     }
       
   229 //-----------------------------------------------------------------------------
       
   230 // CNapBranch::MapUriToCmAttribute(()
       
   231 //-----------------------------------------------------------------------------
       
   232 TUint32 CNapBranch::MapUriToCmAttribute(const TDesC8& aUri)
       
   233     {
       
   234     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_MAPURITOCMATTRIBUTE_ENTRY,
       
   235             "ENTRY: CNapBranch::MapUriToCmAttribute;aUri=%s", aUri );
       
   236 
       
   237     TUint32 retval( 0 );
       
   238 
       
   239     TPtrC8 nodeName = CUtils::GetLastURISeg( aUri );
       
   240 
       
   241     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_MAPURITOCMATTRIBUTE_GET_NODE,
       
   242             "CNapBranch::MapUriToCmAttribute;nodeName=%s", nodeName );
       
   243 
       
   244     if ( nodeName.Match( KCMDdfName ) != KErrNotFound )
       
   245         {
       
   246         retval = CMManager::ECmName;
       
   247         }
       
   248     else if ( nodeName.Match( KCMDdfAddr ) != KErrNotFound )
       
   249         {
       
   250         // IP branch and NAP branch have both "Addr" leaf. Select between them.
       
   251         if ( aUri.Match( KNapAddrUri ) != KErrNotFound &&
       
   252                 aUri.Match( KNapIPv4AddrUri ) == KErrNotFound )
       
   253             {
       
   254             retval = CMManager::EPacketDataAPName;
       
   255             }
       
   256         else if ( aUri.Match( KNapDNSAddr1Uri ) != KErrNotFound )
       
   257             {
       
   258             retval = CMManager::EPacketDataIPNameServer1;
       
   259             }
       
   260         else if ( aUri.Match( KNapDNSAddr2Uri ) != KErrNotFound )
       
   261             {
       
   262             retval = CMManager::EPacketDataIPNameServer2;
       
   263             }
       
   264         }
       
   265     else if ( nodeName.Match( KCMDdfBearerType ) != KErrNotFound )
       
   266         {
       
   267         retval = CMManager::ECmBearerType;
       
   268         }
       
   269     else if ( nodeName.Match( KCMDdfAuthName ) != KErrNotFound )
       
   270         {
       
   271         retval = CMManager::EPacketDataIFAuthName;
       
   272         }
       
   273     else if ( nodeName.Match( KCMDdfAuthSecret ) != KErrNotFound )
       
   274         {
       
   275         retval = CMManager::EPacketDataIFAuthPass;
       
   276         }
       
   277     else if ( nodeName.Match( KCMDdfAutoConfig ) != KErrNotFound )
       
   278         {
       
   279         retval = CMManager::EPacketDataIPAddrFromServer;
       
   280         }
       
   281     else if ( nodeName.Match( KCMDdfIPAddr ) != KErrNotFound )
       
   282         {
       
   283         retval = CMManager::EPacketDataIPAddr;
       
   284         }
       
   285     else if ( nodeName.Match( KCMDdfNetMask ) != KErrNotFound )
       
   286         {
       
   287         retval = CMManager::EPacketDataIPNetmask;
       
   288         }
       
   289     else if ( nodeName.Match( KCMDdfGateway ) != KErrNotFound )
       
   290         {
       
   291         retval = CMManager::EPacketDataIPGateway;
       
   292         }
       
   293     else if ( nodeName.Match( KCMDdfAutoDNS )!= KErrNotFound )
       
   294         {
       
   295         retval = CMManager::EPacketDataIPDNSAddrFromServer;
       
   296         }
       
   297 
       
   298     OstTrace1( TRACE_NORMAL, CNAPBRANCH_MAPURITOCMATTRIBUTE_EXIT,
       
   299             "EXIT: CNapBranch::MapUriToCmAttribute;retval=%{TError}", retval );
       
   300 
       
   301     return retval;
       
   302     }
       
   303 //-----------------------------------------------------------------------------
       
   304 // void CNapBranch::SetLeafData()
       
   305 //-----------------------------------------------------------------------------
       
   306 void CNapBranch::SetLeafDataL(const TDesC8& aURI, const TDesC8& aObject,
       
   307         TInt aStatusRef, RCmConnectionMethodExt& aCm)
       
   308     {
       
   309     OstTraceExt1( TRACE_FLOW, CNAPBRANCH_SETLEAFDATAL_ENTRY,
       
   310             "ENTRY: CNapBranch::SetLeafDataL;aURI=%s", aURI );
       
   311 
       
   312     TUint32 attributeRef( 0 );
       
   313     TBool tmpBool = EFalse;
       
   314     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
       
   315 
       
   316     attributeRef = MapUriToCmAttribute( aURI );
       
   317     OstTrace1( TRACE_NORMAL, CNAPBRANCH_SETLEAFDATAL_GET_CMATTRIB,
       
   318             "CNapBranch::SetLeafDataL;CM Attribute:;attributeRef=%{TConnectionMethodCommonAttributes}",
       
   319             attributeRef );
       
   320 
       
   321     switch ( attributeRef )
       
   322         {
       
   323         case CMManager::ECmName:
       
   324         case CMManager::EPacketDataIPNameServer1:
       
   325         case CMManager::EPacketDataIPNameServer2:
       
   326         case CMManager::EPacketDataAPName:
       
   327         case CMManager::EPacketDataIFAuthName:
       
   328         case CMManager::EPacketDataIFAuthPass:
       
   329         case CMManager::EPacketDataIPAddr:
       
   330         case CMManager::EPacketDataIPNetmask:
       
   331         case CMManager::EPacketDataIPGateway:
       
   332         aCm.SetStringAttributeL( attributeRef, CUtils::ConvertTo16LC( aObject ) );
       
   333         CleanupStack::PopAndDestroy(); // ConvertTo16LC
       
   334         break;
       
   335         case CMManager::EPacketDataIPAddrFromServer:
       
   336         case CMManager::EPacketDataIPDNSAddrFromServer:
       
   337         if ( CUtils::DesToBool( aObject, tmpBool ) == KErrNone )
       
   338             {
       
   339             aCm.SetBoolAttributeL( attributeRef, tmpBool );
       
   340             }
       
   341         else
       
   342             {
       
   343             status = CSmlDmAdapter::EInvalidObject;
       
   344             }
       
   345         break;
       
   346         case CMManager::ECmBearerType:
       
   347         // BearerType is already set when CM was created.
       
   348         break;
       
   349         default:
       
   350         // Attribute field was not from CM. Check if value is hard coded to CM.
       
   351         status = GetUnmodifiableFieldAddResult( aURI, aObject );
       
   352         break;
       
   353         }
       
   354     iCallback->SetStatusL( aStatusRef, status );
       
   355     OstTrace1( TRACE_NORMAL, CNAPBRANCH_SETLEAFDATAL_EXIT,
       
   356             "EXIT: CNapBranch::SetLeafDataL;status=%{TError}", status );
       
   357     }
       
   358 
       
   359 //-----------------------------------------------------------------------------
       
   360 // TBool CNapBranch::SetNodeData()
       
   361 //-----------------------------------------------------------------------------
       
   362 void CNapBranch::SetNodeDataL(CConnMoNodeElement* aNode,
       
   363         RCmConnectionMethodExt& aCm)
       
   364     {
       
   365     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_SETNODEDATAL_ENTRY,
       
   366             "ENTRY: CNapBranch::SetNodeDataL;aNode->iUri=%s", aNode->iUri );
       
   367 
       
   368     if ( aNode->iParentLUID.Length() == 0 )
       
   369         {
       
   370         TBuf8<16> addLUID;
       
   371         _LIT8( KFormat, "%d" );    
       
   372         addLUID.Format( KFormat, aCm.GetIntAttributeL( CMManager::ECmId ) );
       
   373         
       
   374         iCallback->SetMappingL( aNode->iUri, addLUID );
       
   375         iCallback->SetStatusL( aNode->iStatusRef, CSmlDmAdapter::EOk );
       
   376 
       
   377         OstTrace0( TRACE_NORMAL, CNAPBRANCH_SETNODEDATAL_OK,
       
   378                 "CNapBranch::SetNodeDataL; CSmlDmAdapter::EOk" );
       
   379         }
       
   380     else
       
   381         {
       
   382         iCallback->SetStatusL( aNode->iStatusRef, CSmlDmAdapter::EAlreadyExists );
       
   383         OstTrace0( TRACE_NORMAL, CNAPBRANCH_SETNODEDATAL_EXISTS,
       
   384                 "CNapBranch::SetNodeDataL; CSmlDmAdapter::EAlreadyExists" );
       
   385         }
       
   386     OstTrace0( TRACE_NORMAL, CNAPBRANCH_SETNODEDATAL_EXIT,
       
   387             "EXIT: CNapBranch::SetNodeDataL" );
       
   388     }
       
   389 
       
   390 //-----------------------------------------------------------------------------
       
   391 // TBool CNapBranch::FindNewCmType
       
   392 //-----------------------------------------------------------------------------
       
   393 TBool CNapBranch::FindNewCmType(TUint32& aBearerType)
       
   394     {
       
   395     OstTrace0( TRACE_NORMAL, CNAPBRANCH_FINDNEWCMTYPE_ENTRY, "ENTRY: CNapBranch::FindNewCmType" );
       
   396 
       
   397     TBool retval = EFalse;
       
   398     // Find bearer type for creating a connection methdod
       
   399     CConnMoNodeElement* processNode = iBuffer->CacheFind( KNapBearerTypeUri );
       
   400     if ( processNode )
       
   401         {
       
   402         if ( processNode->iObject.Match( KPacketDataBearerType ) != KErrNotFound )
       
   403             {
       
   404             OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_FINDNEWCMTYPE_3GPP,
       
   405                     "CNapBranch::FindNewCmType;Bearer Type: %s", KPacketDataBearerType );
       
   406 
       
   407             aBearerType = KUidPacketDataBearerType;
       
   408             retval = ETrue;
       
   409             }
       
   410         else
       
   411             {
       
   412             aBearerType = KInvalidBearerType;
       
   413             }
       
   414         }
       
   415     OstTrace1( TRACE_NORMAL, CNAPBRANCH_FINDNEWCMTYPE_EXIT,
       
   416             "EXIT: CNapBranch::FindNewCmType;retval=%d", retval );
       
   417 
       
   418     return retval;
       
   419     }
       
   420 //-----------------------------------------------------------------------------
       
   421 // TBool CNapBranch::AllMandatoryNapFieldsFound()
       
   422 //-----------------------------------------------------------------------------
       
   423 TBool CNapBranch::AllMandatoryNapFieldsFound()
       
   424     {
       
   425     OstTrace0( TRACE_NORMAL, CNAPBRANCH_ALLMANDATORYNAPFIELDSFOUND_ENTRY,
       
   426             "ENTRY: CNapBranch::AllMandatoryNapFieldsFound" );
       
   427 
       
   428     TBool retval = ETrue;
       
   429 
       
   430     // Check that NAP Address addition is found
       
   431     if ( !iBuffer->CacheFind( KNapAddrUri ) )
       
   432         {
       
   433         retval = EFalse;
       
   434         }
       
   435     // Check that dynamic nap node addition is found
       
   436     if ( !iBuffer->CacheFindDynamicNode( KDynamicNapNode ) )
       
   437         {
       
   438         retval = EFalse;
       
   439         }
       
   440 
       
   441     OstTrace1( TRACE_NORMAL, CNAPBRANCH_ALLMANDATORYNAPFIELDSFOUND_EXIT,
       
   442             "EXIT: CNapBranch::AllMandatoryNapFieldsFound;retval=%d", retval );
       
   443 
       
   444     return retval;
       
   445     }
       
   446 //-----------------------------------------------------------------------------
       
   447 // TBool CNapBranch::NapChildURIListL
       
   448 // TBool CNapBranch::NapChildURIList( )
       
   449 //-----------------------------------------------------------------------------
       
   450 void CNapBranch::NapChildURIListL(const TDesC8& aURI, const CArrayFix<
       
   451         TSmlDmMappingInfo>& aPreviousURISegmentList, TInt aResultsRef,
       
   452         TInt aStatusRef, CBufBase& aCurrentURISegmentList)
       
   453     {
       
   454     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_NAPCHILDURILISTL_ENTRY,
       
   455             "ENTRY: CNapBranch::NapChildURIListL;aURI=%s", aURI );
       
   456 
       
   457     RArray<TUint32> CmArray;
       
   458     CleanupClosePushL( CmArray );
       
   459 
       
   460     TPtrC8 napTree = CUtils::GetEndOfURIFromSeg( aURI, KCMDdfNAP );
       
   461 
       
   462     GetAllConnectionMethodsL( CmArray, *iCmManager );
       
   463 
       
   464     for (TInt i = 0; i < CmArray.Count(); i++ )
       
   465         {
       
   466         TBuf8<KBufferExpandSize> addURISeg;
       
   467         if ( !CheckPreviousURIList( aPreviousURISegmentList, CmArray[i], addURISeg ) )
       
   468             {
       
   469             // Connection Method not found in previous URI list                        
       
   470             addURISeg.Append( aURI );
       
   471             addURISeg.Append( KSlash );
       
   472             addURISeg.Append( KDynamicNodePrefix );
       
   473 
       
   474             addURISeg.AppendNumFixedWidth( CmArray[i], EDecimal, 3);
       
   475 
       
   476             TBuf8<16> addLUID;
       
   477             _LIT8( KFormat, "%d" );    
       
   478             addLUID.Format( KFormat, CmArray[i] );
       
   479 
       
   480             OstTraceExt1( TRACE_NORMAL,
       
   481                     CNAPBRANCH_NAPCHILDURILISTL_ADDED_TO_LIST,
       
   482                     "CNapBranch::NapChildURIListL;Added to list: URI=%s", addURISeg );
       
   483 
       
   484             iCallback->SetMappingL( addURISeg, addLUID );
       
   485             }
       
   486 
       
   487         // Child is the last segment in uri
       
   488         aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(),
       
   489                 CUtils::GetLastURISeg(addURISeg) );
       
   490         aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), KSlash );
       
   491         }
       
   492     iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
   493     iCallback->SetResultsL( aResultsRef, aCurrentURISegmentList, KNullDesC8 );
       
   494 
       
   495     CleanupStack::PopAndDestroy( &CmArray );
       
   496 
       
   497     OstTrace0( TRACE_NORMAL, CNAPBRANCH_NAPCHILDURILISTL_EXIT,
       
   498             "EXIT: CNapBranch::NapChildURIListL" );
       
   499     }
       
   500 //-----------------------------------------------------------------------------
       
   501 // CSmlDmAdapter::TError CNapBranch::DeleteObjectL
       
   502 //-----------------------------------------------------------------------------
       
   503 CSmlDmAdapter::TError CNapBranch::DeleteObjectL(const TDesC8& aURI,
       
   504         const TDesC8& aLUID)
       
   505     {
       
   506     OstTrace0( TRACE_NORMAL, CNAPBRANCH_DELETEOBJECTL_PRIVATE_ENTRY,
       
   507             "ENTRY: CNapBranch::DeleteObjectL" );
       
   508 
       
   509     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
       
   510 
       
   511     // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
   512     TInt cmId = GetCmIdFromURIL( aURI );
       
   513     
       
   514     RCmConnectionMethodExt cm;
       
   515     
       
   516     if( aLUID.Length() > 0 )
       
   517         {       
       
   518         cmId = CUtils::IntLUID( aLUID );
       
   519         }
       
   520 
       
   521     // Check, if referred connection method exists           
       
   522     if ( GetConnectionMethodLC( *iCmManager, cm, cmId ) )
       
   523         {
       
   524         cm.DeleteL();
       
   525         status = CSmlDmAdapter::EOk;
       
   526         OstTrace1( TRACE_NORMAL, CNAPBRANCH_DELETEOBJECTL_PRIVATE_DELETE,
       
   527                 "CNapBranch::DeleteObjectL; Connection Method=%u deleted.", cmId );
       
   528         }
       
   529 
       
   530     CleanupStack::PopAndDestroy( &cm );
       
   531 
       
   532     OstTrace1( TRACE_NORMAL, CNAPBRANCH_DELETEOBJECTL_PRIVATE_EXIT,
       
   533             "EXIT: CNapBranch::DeleteObjectL;status=%{TError}", status );
       
   534 
       
   535     return status;
       
   536     }
       
   537 
       
   538 // ======== MEMBER FUNCTIONS ========
       
   539 //-----------------------------------------------------------------------------
       
   540 // CNapBranch* CNapBranch::NewL( )
       
   541 //-----------------------------------------------------------------------------
       
   542 CNapBranch* CNapBranch::NewL(MSmlDmCallback* aDmCallback,
       
   543         CAddBuffer* aBuffer, RCmManagerExt* aCmManagerExt)
       
   544     {
       
   545     OstTraceFunctionEntry1( CNAPBRANCH_NEWL_ENTRY, ( TUint )( aDmCallback ) );
       
   546 
       
   547     CNapBranch* self = new (ELeave) CNapBranch( aDmCallback );
       
   548     CleanupStack::PushL(self);
       
   549 
       
   550     self->ConstructL( aBuffer, aCmManagerExt );
       
   551 
       
   552     CleanupStack::Pop(self);
       
   553 
       
   554     OstTraceFunctionExit1( CNAPBRANCH_NEWL_EXIT, ( TUint )( self ) );
       
   555     return self;
       
   556     }
       
   557 
       
   558 //------------------------------------------------------------------------------
       
   559 // CNapBranch::CNapBranch()
       
   560 //------------------------------------------------------------------------------
       
   561 CNapBranch::CNapBranch(MSmlDmCallback* aDmCallback) :
       
   562     CBranchBase(aDmCallback)
       
   563     {
       
   564     OstTraceFunctionEntry1( CNAPBRANCH_CONSTRUCTOR_ENTRY, this );
       
   565 
       
   566     iCallback = aDmCallback;
       
   567 
       
   568     OstTraceFunctionExit1( CNAPBRANCH_CONSTRUCTOR_EXIT, this );
       
   569     }
       
   570 
       
   571 //------------------------------------------------------------------------------
       
   572 // CNapBranch::~CNapBranch()
       
   573 //------------------------------------------------------------------------------
       
   574 CNapBranch::~CNapBranch()
       
   575     {
       
   576     OstTraceFunctionEntry1( CNAPBRANCH_DESTRUCTOR_ENTRY, this );
       
   577 
       
   578     OstTraceFunctionExit1( CNAPBRANCH_DESTRUCTOR_EXIT, this );
       
   579     }
       
   580 
       
   581 //=============================================
       
   582 //      CNapBranch::ConstructL()
       
   583 //      Second phase constructor.
       
   584 //=============================================
       
   585 void CNapBranch::ConstructL(CAddBuffer* aBuffer, RCmManagerExt* aCmManagerExt)
       
   586     {
       
   587     OstTraceFunctionEntry1( CNAPBRANCH_CONSTRUCTL_ENTRY, this );
       
   588 
       
   589     iBuffer = aBuffer;
       
   590     iCmManager = aCmManagerExt;
       
   591 
       
   592     OstTraceFunctionExit1( CNAPBRANCH_CONSTRUCTL_EXIT, this );
       
   593     }
       
   594 
       
   595 //------------------------------------------------------------------------------
       
   596 //  void CNapBranch::DDFStructureL()
       
   597 //------------------------------------------------------------------------------
       
   598 void CNapBranch::DDFStructureL(MSmlDmDDFObject& aDDF)
       
   599     {
       
   600     OstTraceFunctionEntry0( CNAPBRANCH_DDFSTRUCTUREL_ENTRY );
       
   601 
       
   602     //
       
   603     // Set rest acceptable operations for data itself
       
   604     //
       
   605     TSmlDmAccessTypes aclTypesNoDelete;
       
   606     aclTypesNoDelete.SetGet();
       
   607     aclTypesNoDelete.SetReplace();
       
   608     aclTypesNoDelete.SetAdd();
       
   609 
       
   610     TSmlDmAccessTypes aclTypesNoGet;
       
   611     aclTypesNoGet.SetReplace();
       
   612     aclTypesNoGet.SetAdd();
       
   613     aclTypesNoGet.SetDelete();
       
   614 
       
   615     TSmlDmAccessTypes aclTypesOnlyGet;
       
   616     aclTypesOnlyGet.SetGet();
       
   617 
       
   618     MSmlDmDDFObject& nIDDDF = aDDF.AddChildObjectL( KCMDdfID ); // ID
       
   619     CUtils::FillNodeInfoL( nIDDDF,
       
   620             aclTypesOnlyGet,
       
   621             MSmlDmDDFObject::EOne,
       
   622             MSmlDmDDFObject::EDynamic,
       
   623             MSmlDmDDFObject::EChr,
       
   624             KNullDesC8 );
       
   625 
       
   626     MSmlDmDDFObject& nNameDDF = aDDF.AddChildObjectL( KCMDdfName ); // Name
       
   627     CUtils::FillNodeInfoL( nNameDDF,
       
   628             aclTypesNoDelete,
       
   629             MSmlDmDDFObject::EZeroOrOne,
       
   630             MSmlDmDDFObject::EDynamic,
       
   631             MSmlDmDDFObject::EChr,
       
   632             KNullDesC8 );
       
   633 
       
   634     MSmlDmDDFObject& nAddrTypeDDF = aDDF.AddChildObjectL( KCMDdfAddrType ); // AddrType
       
   635     CUtils::FillNodeInfoL( nAddrTypeDDF,
       
   636             aclTypesNoDelete,
       
   637             MSmlDmDDFObject::EZeroOrOne,
       
   638             MSmlDmDDFObject::EDynamic,
       
   639             MSmlDmDDFObject::EChr,
       
   640             KNullDesC8 );
       
   641 
       
   642     MSmlDmDDFObject& nAddrDDF = aDDF.AddChildObjectL( KCMDdfAddr ); // Addr
       
   643     CUtils::FillNodeInfoL( nAddrDDF,
       
   644             aclTypesNoDelete,
       
   645             MSmlDmDDFObject::EOne,
       
   646             MSmlDmDDFObject::EDynamic,
       
   647             MSmlDmDDFObject::EChr,
       
   648             KNullDesC8 );
       
   649 
       
   650     MSmlDmDDFObject& nIPDDF = aDDF.AddChildObjectL( KCMDdfIP ); // IP
       
   651     CUtils::FillNodeInfoL( nIPDDF,
       
   652             aclTypesNoDelete,
       
   653             MSmlDmDDFObject::EOne,
       
   654             MSmlDmDDFObject::EDynamic,
       
   655             MSmlDmDDFObject::ENode,
       
   656             KNullDesC8 );
       
   657 
       
   658     MSmlDmDDFObject& nIPv4DDF = nIPDDF.AddChildObjectL( KCMDdfIPv4 ); // IPv4
       
   659     CUtils::FillNodeInfoL( nIPv4DDF,
       
   660             aclTypesNoDelete,
       
   661             MSmlDmDDFObject::EZeroOrOne,
       
   662             MSmlDmDDFObject::EDynamic,
       
   663             MSmlDmDDFObject::ENode,
       
   664             KNullDesC8 );
       
   665     IpBranchDDFStructureL( nIPv4DDF );
       
   666 
       
   667     MSmlDmDDFObject& nAuthInfoDDF = aDDF.AddChildObjectL( KCMDdfAuthInfo ); // AuthInfo
       
   668     CUtils::FillNodeInfoL( nAuthInfoDDF,
       
   669             aclTypesNoDelete,
       
   670             MSmlDmDDFObject::EZeroOrOne,
       
   671             MSmlDmDDFObject::EDynamic,
       
   672             MSmlDmDDFObject::ENode,
       
   673             KNullDesC8 );
       
   674 
       
   675     MSmlDmDDFObject& nAuthNameDDF = nAuthInfoDDF.AddChildObjectL( KCMDdfAuthName ); // AuthName
       
   676     CUtils::FillNodeInfoL( nAuthNameDDF,
       
   677             aclTypesNoDelete,
       
   678             MSmlDmDDFObject::EZeroOrOne,
       
   679             MSmlDmDDFObject::EDynamic,
       
   680             MSmlDmDDFObject::EChr,
       
   681             KNullDesC8 );
       
   682 
       
   683     MSmlDmDDFObject& nAuthTypeDDF = nAuthInfoDDF.AddChildObjectL( KCMDdfAuthType ); // AuthType
       
   684     CUtils::FillNodeInfoL( nAuthTypeDDF,
       
   685             aclTypesNoDelete,
       
   686             MSmlDmDDFObject::EZeroOrOne,
       
   687             MSmlDmDDFObject::EDynamic,
       
   688             MSmlDmDDFObject::EChr,
       
   689             KNullDesC8 );
       
   690 
       
   691     MSmlDmDDFObject& nAuthSecretDDF = nAuthInfoDDF.AddChildObjectL( KCMDdfAuthSecret ); // AuthSecret
       
   692     CUtils::FillNodeInfoL( nAuthSecretDDF,
       
   693             aclTypesNoGet,
       
   694             MSmlDmDDFObject::EZeroOrOne,
       
   695             MSmlDmDDFObject::EDynamic,
       
   696             MSmlDmDDFObject::EChr,
       
   697             KNullDesC8 );
       
   698 
       
   699     MSmlDmDDFObject& nBearerTypeDDF = aDDF.AddChildObjectL( KCMDdfBearerType ); // BearerType
       
   700     CUtils::FillNodeInfoL( nBearerTypeDDF,
       
   701             aclTypesNoDelete,
       
   702             MSmlDmDDFObject::EOne,
       
   703             MSmlDmDDFObject::EDynamic,
       
   704             MSmlDmDDFObject::EChr,
       
   705             KNullDesC8 );
       
   706 
       
   707     MSmlDmDDFObject& nBearerParamsDDF = aDDF.AddChildObjectL( KCMDdfBearerParams ); // BearerParams
       
   708     CUtils::FillNodeInfoL( nBearerParamsDDF,
       
   709             aclTypesNoDelete,
       
   710             MSmlDmDDFObject::EOne,
       
   711             MSmlDmDDFObject::EDynamic,
       
   712             MSmlDmDDFObject::ENode,
       
   713             KNullDesC8 );
       
   714 
       
   715     OstTraceFunctionExit0( CNAPBRANCH_DDFSTRUCTUREL_EXIT );
       
   716     }
       
   717 
       
   718 // -------------------------------------------------------------------------------------
       
   719 // CNapBranch::IpBranchDDFStructureL
       
   720 // -------------------------------------------------------------------------------------
       
   721 void CNapBranch::IpBranchDDFStructureL(MSmlDmDDFObject& nIPvXDDF)
       
   722     {
       
   723     OstTraceFunctionEntry0( CNAPBRANCH_IPBRANCHDDFSTRUCTUREL_ENTRY );
       
   724 
       
   725     //
       
   726     // Set rest acceptable operations for data itself
       
   727     //
       
   728     TSmlDmAccessTypes aclTypesNoDelete;
       
   729     aclTypesNoDelete.SetGet();
       
   730     aclTypesNoDelete.SetReplace();
       
   731     aclTypesNoDelete.SetAdd();
       
   732 
       
   733     MSmlDmDDFObject& nAutoConfigDDF = nIPvXDDF.AddChildObjectL( KCMDdfAutoConfig ); // AutoConfig
       
   734     CUtils::FillNodeInfoL( nAutoConfigDDF,
       
   735             aclTypesNoDelete,
       
   736             MSmlDmDDFObject::EZeroOrOne,
       
   737             MSmlDmDDFObject::EDynamic,
       
   738             MSmlDmDDFObject::EChr,
       
   739             KNullDesC8 );
       
   740 
       
   741     MSmlDmDDFObject& nIPAddrDDF = nIPvXDDF.AddChildObjectL( KCMDdfIPAddr ); // IPAddr
       
   742     CUtils::FillNodeInfoL( nIPAddrDDF,
       
   743             aclTypesNoDelete,
       
   744             MSmlDmDDFObject::EZeroOrOne,
       
   745             MSmlDmDDFObject::EDynamic,
       
   746             MSmlDmDDFObject::EChr,
       
   747             KNullDesC8 );
       
   748 
       
   749     MSmlDmDDFObject& nNetMaskDDF = nIPvXDDF.AddChildObjectL( KCMDdfNetMask ); // NetMask
       
   750     CUtils::FillNodeInfoL( nNetMaskDDF,
       
   751             aclTypesNoDelete,
       
   752             MSmlDmDDFObject::EZeroOrOne,
       
   753             MSmlDmDDFObject::EDynamic,
       
   754             MSmlDmDDFObject::EChr,
       
   755             KNullDesC8 );
       
   756 
       
   757     MSmlDmDDFObject& nGatewayDDF = nIPvXDDF.AddChildObjectL( KCMDdfGateway ); // Gateway
       
   758     CUtils::FillNodeInfoL( nGatewayDDF,
       
   759             aclTypesNoDelete,
       
   760             MSmlDmDDFObject::EZeroOrOne,
       
   761             MSmlDmDDFObject::EDynamic,
       
   762             MSmlDmDDFObject::EChr,
       
   763             KNullDesC8 );
       
   764 
       
   765     MSmlDmDDFObject& nAutoDNSDDF = nIPvXDDF.AddChildObjectL( KCMDdfAutoDNS ); // AutoDNS
       
   766     CUtils::FillNodeInfoL( nAutoDNSDDF,
       
   767             aclTypesNoDelete,
       
   768             MSmlDmDDFObject::EZeroOrOne,
       
   769             MSmlDmDDFObject::EDynamic,
       
   770             MSmlDmDDFObject::EBool,
       
   771             KNullDesC8 );
       
   772 
       
   773     MSmlDmDDFObject& nDNSDDF = nIPvXDDF.AddChildObjectL( KCMDdfDNS ); // DNS
       
   774     CUtils::FillNodeInfoL( nDNSDDF,
       
   775             aclTypesNoDelete,
       
   776             MSmlDmDDFObject::EZeroOrOne,
       
   777             MSmlDmDDFObject::EDynamic,
       
   778             MSmlDmDDFObject::ENode,
       
   779             KNullDesC8 );
       
   780 
       
   781     MSmlDmDDFObject& nServersDDF = nDNSDDF.AddChildObjectL( KCMDdfServers ); // Servers
       
   782     CUtils::FillNodeInfoL( nServersDDF,
       
   783             aclTypesNoDelete,
       
   784             MSmlDmDDFObject::EZeroOrOne,
       
   785             MSmlDmDDFObject::EDynamic,
       
   786             MSmlDmDDFObject::ENode,
       
   787             KNullDesC8 );
       
   788 
       
   789     MSmlDmDDFObject& nServersRootDDF = nServersDDF.AddChildObjectGroupL(); // Servers/<x>
       
   790     CUtils::FillNodeInfoL( nServersRootDDF,
       
   791             aclTypesNoDelete,
       
   792             MSmlDmDDFObject::EOneOrMore,
       
   793             MSmlDmDDFObject::EDynamic,
       
   794             MSmlDmDDFObject::ENode,
       
   795             KNullDesC8 );
       
   796 
       
   797     MSmlDmDDFObject& nAddrDDF = nServersRootDDF.AddChildObjectL( KCMDdfAddr ); // Addr
       
   798     CUtils::FillNodeInfoL( nAddrDDF,
       
   799             aclTypesNoDelete,
       
   800             MSmlDmDDFObject::EOne,
       
   801             MSmlDmDDFObject::EDynamic,
       
   802             MSmlDmDDFObject::EChr,
       
   803             KNullDesC8 );
       
   804 
       
   805     OstTraceFunctionExit0( CNAPBRANCH_IPBRANCHDDFSTRUCTUREL_EXIT );
       
   806     }
       
   807 
       
   808 // -------------------------------------------------------------------------------------
       
   809 // CNapBranch::UpdateLeafObjectL
       
   810 // -------------------------------------------------------------------------------------
       
   811 void CNapBranch::UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
       
   812         const TDesC8& aObject, const TDesC8& /*aType*/, TInt aStatusRef)
       
   813     {
       
   814     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_UPDATELEAFOBJECTL_ENTRY,
       
   815             "ENTRY: CNapBranch::UpdateLeafObjectL;aURI=%s", aURI );
       
   816 
       
   817     // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
   818     TInt cmId = GetCmIdFromURIL( aURI );
       
   819     
       
   820     if ( aLUID.Length() == 0 && cmId == KErrNotFound )
       
   821         {
       
   822             // New node, add to buffer
       
   823             iBuffer->AddNodeToBufferL( aURI, aLUID, aObject, aStatusRef );    
       
   824         }  
       
   825     else
       
   826         {
       
   827         // Existing node, update data immediately
       
   828         TInt err( KErrNone );
       
   829         RCmConnectionMethodExt cm;
       
   830         if ( cmId == KErrNotFound )
       
   831             {
       
   832             cmId = CUtils::IntLUID( aLUID );
       
   833             }
       
   834             
       
   835         TRAP( err, cm = iCmManager->ConnectionMethodL( cmId ) );
       
   836         CleanupClosePushL( cm );
       
   837 
       
   838         if ( !err )
       
   839             {
       
   840             OstTrace0( TRACE_NORMAL, CNAPBRANCH_UPDATELEAFOBJECTL, "CNapBranch::UpdateLeafObjectL; Update existing node data immediately." );
       
   841             SetLeafDataL( aURI, aObject, aStatusRef, cm );
       
   842             cm.UpdateL();
       
   843             }
       
   844         else
       
   845             {
       
   846             OstTrace0( TRACE_NORMAL, DUP1_CNAPBRANCH_UPDATELEAFOBJECTL, "CNapBranch::UpdateLeafObjectL; Stale LUID - Buffer setting." );
       
   847             iBuffer->AddNodeToBufferL( aURI, KNullDesC8, aObject, aStatusRef );
       
   848             }
       
   849 
       
   850         CleanupStack::PopAndDestroy( &cm );
       
   851         }
       
   852 
       
   853     OstTrace0( TRACE_NORMAL, CNAPBRANCH_UPDATELEAFOBJECTL_EXIT,
       
   854             "EXIT: CNapBranch::UpdateLeafObjectL" );
       
   855     }
       
   856 
       
   857 // -------------------------------------------------------------------------------------
       
   858 // CNapBranch::DeleteObjectL
       
   859 // -------------------------------------------------------------------------------------
       
   860 void CNapBranch::DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
       
   861         TInt aStatusRef)
       
   862     {
       
   863     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_DELETEOBJECTL_ENTRY,
       
   864             "ENTRY: CNapBranch::DeleteObjectL;aURI=%s", aURI );
       
   865 
       
   866     CSmlDmAdapter::TError status = CSmlDmAdapter::EError;
       
   867 
       
   868     TPtrC8 napTree = CUtils::GetEndOfURIFromSeg( aURI, KCMDdfNAP );
       
   869 
       
   870     if ( napTree.Match( KDynamicNapNode ) != KErrNotFound &&
       
   871             napTree.Match( KDynamicNapNodeChildUri ) == KErrNotFound )
       
   872         {
       
   873 
       
   874         status = DeleteObjectL( aURI, aLUID );
       
   875 
       
   876         }
       
   877 
       
   878     iCallback->SetStatusL( aStatusRef, status );
       
   879 
       
   880     OstTrace1( TRACE_NORMAL, CNAPBRANCH_DELETEOBJECTL_EXIT,
       
   881             "EXIT: CNapBranch::DeleteObjectL;status=%{TError}", status );
       
   882     }
       
   883 
       
   884 // -------------------------------------------------------------------------------------
       
   885 // CNapBranch::FetchLeafObjectL
       
   886 // -------------------------------------------------------------------------------------
       
   887 void CNapBranch::FetchLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
       
   888         const TDesC8& aType, TInt aResultsRef, TInt aStatusRef)
       
   889     {
       
   890     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTL_ENTRY,
       
   891             "ENTRY: CNapBranch::FetchLeafObjectL;aURI=%s", aURI );
       
   892     TInt cmId( KErrNotFound );
       
   893     if ( aLUID.Length() > 0 )
       
   894          {
       
   895          cmId = CUtils::IntLUID( aLUID );      
       
   896          }
       
   897      else
       
   898          {
       
   899          // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
   900          cmId = GetCmIdFromURIL( aURI );
       
   901          }
       
   902     if ( cmId != KErrNotFound )
       
   903         {
       
   904         CBufBase* result = CBufFlat::NewL( KBufferExpandSize );
       
   905         CleanupStack::PushL( result );
       
   906 
       
   907         // Open connection method.
       
   908         RCmConnectionMethodExt cm;
       
   909         TRAPD(err, cm = iCmManager->ConnectionMethodL( cmId ) );
       
   910         if (err != KErrNone )
       
   911             {
       
   912             CleanupStack::PopAndDestroy( result );
       
   913             iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   914             OstTrace0( TRACE_NORMAL, CNAPBRANCH_DUP_FETCHLEAFOBJECTL_NOT_FOUND, "CSmlDmAdapter::ENotFound" );
       
   915             return;
       
   916             }
       
   917         CleanupClosePushL( cm );
       
   918 
       
   919         // Find data from CM
       
   920         CSmlDmAdapter::TError status = GetLeafDataL( aURI,
       
   921                 cm,
       
   922                 result );
       
   923 
       
   924         OstTrace1( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTL_STATUS,
       
   925                 "CNapBranch::FetchLeafObjectL;status=%{TError}", status );
       
   926 
       
   927         if ( status == CSmlDmAdapter::EOk )
       
   928             {
       
   929             iCallback->SetResultsL( aResultsRef, *result, aType );
       
   930             }
       
   931         iCallback->SetStatusL( aStatusRef, status );
       
   932 
       
   933         CleanupStack::PopAndDestroy( &cm );
       
   934         CleanupStack::PopAndDestroy( result );
       
   935         }
       
   936     else
       
   937         {
       
   938         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   939         OstTrace0( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTL_NOT_FOUND, "CSmlDmAdapter::ENotFound" );
       
   940         }
       
   941     OstTrace0( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTL_EXIT, "EXIT: CNapBranch::FetchLeafObjectL" );
       
   942     }
       
   943 
       
   944 // -------------------------------------------------------------------------------------
       
   945 // CNapBranch::FetchLeafObjectSizeL
       
   946 // -------------------------------------------------------------------------------------
       
   947 void CNapBranch::FetchLeafObjectSizeL(const TDesC8& aURI,
       
   948         const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef,
       
   949         TInt aStatusRef)
       
   950     {
       
   951     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTSIZEL_ENTRY,
       
   952             "ENTRY: CNapBranch::FetchLeafObjectSizeL;aURI=%s", aURI );
       
   953     TInt cmId( KErrNotFound );
       
   954     if ( aLUID.Length() > 0 )
       
   955          {
       
   956          cmId = CUtils::IntLUID( aLUID );        
       
   957          }
       
   958      else
       
   959          {
       
   960          // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
   961          cmId = GetCmIdFromURIL( aURI );
       
   962          }
       
   963     if ( cmId != KErrNotFound )
       
   964         {
       
   965         CBufBase* result = CBufFlat::NewL( KBufferExpandSize );
       
   966         CleanupStack::PushL(result);
       
   967 
       
   968         // Open connection method.
       
   969         RCmConnectionMethodExt cm;
       
   970         TRAPD(err, cm = iCmManager->ConnectionMethodL( cmId ) );
       
   971         if (err != KErrNone )
       
   972             {
       
   973             CleanupStack::PopAndDestroy( result );
       
   974             iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
   975             OstTrace0( TRACE_NORMAL, CNAPBRANCH_DUP1_FETCHLEAFOBJECTL_NOT_FOUND, "CSmlDmAdapter::ENotFound" );
       
   976             return;
       
   977             }
       
   978         CleanupClosePushL( cm );
       
   979 
       
   980         // Find data from CM
       
   981         CSmlDmAdapter::TError status = GetLeafDataL( aURI,
       
   982                 cm,
       
   983                 result );
       
   984 
       
   985         OstTrace1( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTSIZEL_STATUS,
       
   986                 "CNapBranch::FetchLeafObjectSizeL;status=%{TError}", status );
       
   987 
       
   988         if ( status == CSmlDmAdapter::EOk )
       
   989             {
       
   990             TInt size = result->Size();
       
   991             TBuf8<KMaxResultSize> sizeStr;
       
   992             sizeStr.AppendNum( size );
       
   993 
       
   994             result->Reset();
       
   995             result->InsertL( 0, sizeStr );
       
   996 
       
   997             iCallback->SetResultsL( aResultsRef, *result, aType);
       
   998             }
       
   999         iCallback->SetStatusL( aStatusRef, status );
       
  1000 
       
  1001         CleanupStack::PopAndDestroy( &cm );
       
  1002         CleanupStack::PopAndDestroy( result );
       
  1003         }
       
  1004     else
       
  1005         {
       
  1006         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1007         OstTrace0( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTSIZEL_NOT_FOUND,
       
  1008                 "CNapBranch::FetchLeafObjectSizeL;CSmlDmAdapter::ENotFound" );
       
  1009         }
       
  1010     OstTrace0( TRACE_NORMAL, CNAPBRANCH_FETCHLEAFOBJECTSIZEL_EXIT,
       
  1011             "EXIT: CNapBranch::FetchLeafObjectSizeL" );
       
  1012     }
       
  1013 
       
  1014 // -------------------------------------------------------------------------------------
       
  1015 // CNapBranch::ChildURIListL
       
  1016 // -------------------------------------------------------------------------------------
       
  1017 void CNapBranch::ChildURIListL(const TDesC8& aURI, const TDesC8& aLUID,
       
  1018         const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
       
  1019         TInt aResultsRef, TInt aStatusRef)
       
  1020     {
       
  1021     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_CHILDURILISTL_ENTRY,
       
  1022             "ENTRY: CNapBranch::ChildURIListL;aURI=%s", aURI );
       
  1023     
       
  1024        
       
  1025     TPtrC8 napTree = CUtils::GetEndOfURIFromSeg( aURI,KCMDdfNAP );
       
  1026 
       
  1027     CBufBase* currentURISegmentList = CBufFlat::NewL( KSmlMaxURISegLen );
       
  1028     CleanupStack::PushL( currentURISegmentList );    
       
  1029     
       
  1030     // First handle ./NAP as a special case
       
  1031     if ( napTree.Match( KCMDdfNAP ) != KErrNotFound )
       
  1032         {
       
  1033         NapChildURIListL( aURI,
       
  1034                 aPreviousURISegmentList,
       
  1035                 aResultsRef,
       
  1036                 aStatusRef,
       
  1037                 *currentURISegmentList );
       
  1038         CleanupStack::PopAndDestroy( currentURISegmentList );
       
  1039         return;
       
  1040         }
       
  1041 
       
  1042     // Then check if the CM exists. Use LUID or predefined ID    
       
  1043     TInt cmId( KErrNotFound );
       
  1044     if ( aLUID.Length() > 0 )
       
  1045         {
       
  1046         cmId = CUtils::IntLUID( aLUID );
       
  1047         }
       
  1048     else
       
  1049         {
       
  1050         // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
  1051         cmId = GetCmIdFromURIL( aURI );
       
  1052         }
       
  1053     // If after this cmId is still not found then the branch does not exist
       
  1054     if ( cmId == KErrNotFound )
       
  1055         {
       
  1056         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1057         CleanupStack::PopAndDestroy( currentURISegmentList );
       
  1058         OstTrace0( TRACE_NORMAL, DUP1_CNAPBRANCH_CHILDURILISTL, "CNapBranch::ChildURIListL; CSmlDmAdapter::ENotFound" );
       
  1059         return;
       
  1060         }
       
  1061     
       
  1062     RCmConnectionMethodExt cm;
       
  1063     // Check it the method actually can be found      
       
  1064     if ( !GetConnectionMethodLC( *iCmManager, cm, cmId ) )       
       
  1065         {
       
  1066         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1067         CleanupStack::PopAndDestroy( &cm );
       
  1068         CleanupStack::PopAndDestroy( currentURISegmentList );        
       
  1069         OstTrace0( TRACE_NORMAL, DUP2_CNAPBRANCH_CHILDURILISTL, "CNapBranch::ChildURIListL; CSmlDmAdapter::ENotFound" );
       
  1070         return;
       
  1071         }            
       
  1072     CleanupStack::PopAndDestroy( &cm );    
       
  1073             
       
  1074     if ( napTree.Match( KDynamicNapNode ) != KErrNotFound &&
       
  1075             napTree.Match( KDynamicNapNodeChildUri ) == KErrNotFound )
       
  1076         {
       
  1077         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNapFields ); 
       
  1078         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1079         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );        
       
  1080         }
       
  1081     // ./NAP/*/IP
       
  1082 
       
  1083     else if ( napTree.Match( KDynamicIPNode ) != KErrNotFound &&
       
  1084             napTree.Match( KDynamicIPNodeChildUri ) == KErrNotFound )
       
  1085         {
       
  1086         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNIPFields );
       
  1087         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1088         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
       
  1089         }
       
  1090     // ./NAP/*/IP/IPv4
       
  1091 
       
  1092     else if ( napTree.Match( KDynamicIPv4Node ) != KErrNotFound &&
       
  1093             napTree.Match( KDynamicIPv4NodeChildUri ) == KErrNotFound )
       
  1094         {
       
  1095         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNIPv4Fields );
       
  1096         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1097         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
       
  1098         }
       
  1099     // ./NAP/*/IP/IPv4/DNS
       
  1100 
       
  1101     else if ( napTree.Match( KDynamicIPv4DnsNode ) != KErrNotFound &&
       
  1102             napTree.Match( KDynamicIPv4DnsNodeChildUri ) == KErrNotFound )
       
  1103         {
       
  1104         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNDNSFields );
       
  1105         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1106         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
       
  1107         }
       
  1108     // ./NAP/*/IP/IPv4/DNS/Servers
       
  1109 
       
  1110     else if ( napTree.Match( KDynamicIPv4DnsServersNode ) != KErrNotFound )
       
  1111         {
       
  1112         GetAllDynamicNodesL( aURI,
       
  1113                 aLUID,
       
  1114                 aPreviousURISegmentList,
       
  1115                 aResultsRef,
       
  1116                 aStatusRef,
       
  1117                 *iCmManager,
       
  1118                 *currentURISegmentList,
       
  1119                 KCMDdfServer,
       
  1120                 KMaxDnsAddr,
       
  1121                 iCallback );
       
  1122         }
       
  1123     // ./NAP/*/IP/IPv4/DNS/Servers*
       
  1124 
       
  1125     else if ( napTree.Match( KDynamicIPv4DnsServersNodeChildUri ) != KErrNotFound &&
       
  1126             napTree.Match( KDynamicIPv4DnsServersNodeChildUriNodes ) == KErrNotFound )
       
  1127         {
       
  1128         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNDNSServersFields ); 
       
  1129         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1130         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
       
  1131         }
       
  1132     // ./NAP/*/AuthInfo
       
  1133 
       
  1134     else if ( napTree.Match( KDynamicAuthInfoNode ) != KErrNotFound &&
       
  1135             napTree.Match( KDynamicAuthInfoNodeChildUri ) == KErrNotFound )
       
  1136         {
       
  1137         currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMNAuthInfoFields );
       
  1138         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1139         iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
       
  1140         }
       
  1141     else
       
  1142         {
       
  1143         iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
       
  1144         OstTrace0( TRACE_NORMAL, CNAPBRANCH_CHILDURILISTL,
       
  1145                 "CNapBranch::ChildURIListL; CSmlDmAdapter::ENotFound" );
       
  1146         }
       
  1147 
       
  1148     CleanupStack::PopAndDestroy( currentURISegmentList );
       
  1149 
       
  1150     OstTrace0( TRACE_NORMAL, DUP1_CNAPBRANCH_CHILDURILISTL_EXIT,
       
  1151             "EXIT: CNapBranch::ChildURIListL" );
       
  1152     }
       
  1153 
       
  1154 // -------------------------------------------------------------------------------------
       
  1155 // CNapBranch::AddNodeObjectL
       
  1156 // -------------------------------------------------------------------------------------
       
  1157 void CNapBranch::AddNodeObjectL(const TDesC8& aURI,
       
  1158         const TDesC8& aParentLUID, TInt aStatusRef)
       
  1159     {
       
  1160     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL_ENTRY,
       
  1161             "ENTRY: CNapBranch::AddNodeObjectL;aURI=%s", aURI );
       
  1162 
       
  1163     if ( aParentLUID.Length() == 0 )
       
  1164         {        
       
  1165         // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx)
       
  1166         TInt cmId = GetCmIdFromURIL( aURI );
       
  1167         RCmConnectionMethodExt cm;
       
  1168         // Check if CM exists
       
  1169         if ( cmId != KErrNotFound && GetConnectionMethodLC( *iCmManager, cm, cmId ) )
       
  1170             {
       
  1171             CleanupStack::PopAndDestroy( &cm );
       
  1172             // Pre-defined CM already exists for this ID.
       
  1173             // NAPs must be added in one message. If luid is given add is done to existing AP or node
       
  1174             iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists );
       
  1175             OstTrace0( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL, 
       
  1176                     "CNapBranch::AddNodeObjectL; CSmlDmAdapter::EAlreadyExists because tried to add in predefined node format that exists" );
       
  1177             return;
       
  1178             }                          
       
  1179         if ( cmId != KErrNotFound )
       
  1180             {
       
  1181             CleanupStack::PopAndDestroy( &cm );
       
  1182             }
       
  1183 
       
  1184         // New node, add to buffer
       
  1185         iBuffer->AddNodeToBufferL( aURI, aParentLUID, aStatusRef );
       
  1186         //iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
       
  1187         OstTrace0( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL_NEW_NODE,
       
  1188                 "CNapBranch::AddNodeObjectL;New node -> Add to buffer." );
       
  1189         }
       
  1190     else
       
  1191         {
       
  1192         // Sanity check: If the dynamic name of the NAP node has is the same as deleted previously and
       
  1193         // DM Framework hasn't updated the tree, it will give the LUID when calling this method. Thus,
       
  1194         // it's needed to check that the connection method really exists.
       
  1195         TBuf8<KSmlMaxURISegLen> parentLUID;
       
  1196         parentLUID.Zero();
       
  1197         parentLUID = aParentLUID;
       
  1198         RCmConnectionMethodExt cm;               
       
  1199         if ( !GetConnectionMethodLC( *iCmManager, cm,  CUtils::IntLUID( parentLUID) ) )
       
  1200             {            
       
  1201 			if(aParentLUID.Length() > 0)
       
  1202 				{
       
  1203 				TInt ret = iCallback->RemoveMappingL(KConnMoAdapterUid,
       
  1204 							GetDynamicNAPNodeUri( aURI ), ETrue );
       
  1205 				if(ret)
       
  1206 					{
       
  1207 					iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1208 					CleanupStack::PopAndDestroy( &cm );
       
  1209 					return;
       
  1210 					}				
       
  1211 				}
       
  1212 			// New node, add to buffer
       
  1213             iBuffer->AddNodeToBufferL( aURI, KNullDesC8, aStatusRef );
       
  1214             OstTrace0( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL_NEW_NODE2,
       
  1215                     "CNapBranch::AddNodeObjectL;New node -> Add to buffer." );
       
  1216             }
       
  1217         else
       
  1218             {
       
  1219             // NAPs must be added in one message. If luid is given add is done to existing AP or node
       
  1220             iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists );
       
  1221             OstTrace0( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL_ALLREADY_EXISTS,
       
  1222                     "CNapBranch::AddNodeObjectL; CSmlDmAdapter::EAlreadyExists" );
       
  1223             }
       
  1224 
       
  1225         CleanupStack::PopAndDestroy( &cm );
       
  1226         }
       
  1227     OstTrace0( TRACE_NORMAL, CNAPBRANCH_ADDNODEOBJECTL_EXIT, "EXIT: CNapBranch::AddNodeObjectL" );
       
  1228 
       
  1229     }
       
  1230 
       
  1231 // -------------------------------------------------------------------------------------
       
  1232 // CNapBranch::ProcessNodeBufferL()
       
  1233 // -------------------------------------------------------------------------------------
       
  1234 void CNapBranch::ProcessBufferL()
       
  1235     {
       
  1236     OstTrace0( TRACE_NORMAL, CNAPBRANCH_PROCESSBUFFERL_ENTRY, "ENTRY: CNapBranch::ProcessBufferL" );
       
  1237 
       
  1238     TUint32 bearerType;
       
  1239 
       
  1240     RPointerArray<CConnMoNodeElement> napNodes( KNumOfNAPNodes );
       
  1241     CleanupClosePushL( napNodes );
       
  1242 
       
  1243     while ( iBuffer->GetGroup( KCMDdfNAP, &napNodes ) != KErrNotFound )
       
  1244         {
       
  1245 
       
  1246         if ( FindNewCmType( bearerType ) && AllMandatoryNapFieldsFound() )
       
  1247             {
       
  1248             // Create new connection method and update nodes
       
  1249             RCmConnectionMethodExt cm = iCmManager->CreateConnectionMethodL( bearerType );
       
  1250             CleanupClosePushL( cm );
       
  1251             cm.UpdateL();
       
  1252 
       
  1253             for ( TInt i = 0; i < napNodes.Count(); ++i )
       
  1254                 {
       
  1255                 if ( napNodes[i]->iLeaf )
       
  1256                     {
       
  1257                     // Leaf data found
       
  1258                     SetLeafDataL( napNodes[i]->iUri,
       
  1259                             napNodes[i]->iObject,
       
  1260                             napNodes[i]->iStatusRef, cm );
       
  1261                     napNodes[i]->iProcessed = ETrue;
       
  1262                     }
       
  1263                 else
       
  1264                     {
       
  1265                     // Node has no leaf data
       
  1266                     SetNodeDataL( napNodes[i], cm);
       
  1267                     napNodes[i]->iProcessed = ETrue;
       
  1268                     }
       
  1269                 }
       
  1270             cm.UpdateL();
       
  1271             CleanupStack::PopAndDestroy( &cm );
       
  1272             }
       
  1273         else
       
  1274             {
       
  1275             for ( TInt i = 0; i < napNodes.Count(); ++i )
       
  1276                 {
       
  1277                 iCallback->SetStatusL( napNodes[i]->iStatusRef, CSmlDmAdapter::EError );
       
  1278                 napNodes[i]->iProcessed = ETrue;
       
  1279                 }
       
  1280             }
       
  1281         napNodes.Reset();
       
  1282         }
       
  1283     CleanupStack::Pop( &napNodes );
       
  1284     napNodes.Close();
       
  1285 
       
  1286     OstTrace0( TRACE_NORMAL, CNAPBRANCH_PROCESSBUFFERL_EXIT, "EXIT: CNapBranch::ProcessBufferL" );
       
  1287 
       
  1288     }
       
  1289 
       
  1290 //------------------------------------------------------------------------------
       
  1291 // TPtrC8 CUtils::GetDynamicAPNodeUri( const TDesC8& aURI )
       
  1292 // returns NAP/xxx URI
       
  1293 //------------------------------------------------------------------------------
       
  1294 TPtrC8 CNapBranch::GetDynamicNAPNodeUri(const TDesC8& aURI)
       
  1295     {
       
  1296 
       
  1297     OstTraceExt1( TRACE_NORMAL, CNAPBRANCH_GETDYNAMICNAPNODEURI, "CNapBranch::GetDynamicNAPNodeUri;aURI=%s", aURI );
       
  1298 
       
  1299     TInt i= 0;
       
  1300     for ( i = aURI.Find( KCMDdfNAP ) + 4; i < aURI.Length(); i++ )
       
  1301         {
       
  1302         if( aURI[i] == '/' )
       
  1303             {
       
  1304             break;
       
  1305             }
       
  1306         }
       
  1307     OstTraceExt1( TRACE_NORMAL, DUP1_CNAPBRANCH_GETDYNAMICNAPNODEURI, "CNapBranch::GetDynamicNAPNodeUri;return URI=%s", aURI.Left( i ) );
       
  1308 
       
  1309     return aURI.Left( i );
       
  1310     }
       
  1311 
       
  1312 //--------------------------------------------------------------------
       
  1313 //TInt CNapBranch::IsNAPUriFormatMatchPredefined(const TDesC8 & aURI)
       
  1314 //
       
  1315 //-------------------------------------------------------------------
       
  1316 
       
  1317 
       
  1318 TBool CNapBranch::IsNAPUriFormatMatchPredefined(const TDesC8 & aURI)
       
  1319 {
       
  1320     if( aURI.Match( _L8( "NAP/NAPId*" ) ) != KErrNotFound )
       
  1321     {
       
  1322         return ETrue;
       
  1323     }
       
  1324     else
       
  1325     {
       
  1326         return EFalse;
       
  1327     }
       
  1328 }
       
  1329 //------------------------------------------------------------------------------
       
  1330 // TUint32 CNapBranch::GetAPIdFromURIL(const TDesC8& aURI)
       
  1331 //         Get NAP id for given aURI
       
  1332 //------------------------------------------------------------------------------
       
  1333 TInt CNapBranch::GetCmIdFromURIL(const TDesC8& aURI)
       
  1334     {
       
  1335     TInt ret(KErrNotFound);
       
  1336     
       
  1337     if( !IsNAPUriFormatMatchPredefined( aURI ) )
       
  1338         {
       
  1339         // Cannot get CmIds from any other format URIs than predefined
       
  1340         return ret;
       
  1341         }
       
  1342    
       
  1343     TLex8 lex;
       
  1344     //  Find xxx from ./NAP/NAPIdxxx/...    
       
  1345     TInt start = aURI.Find( KDynamicNodePrefix ) + KDynamicNodePrefix().Length();
       
  1346     lex = aURI.Mid( start, 3 );
       
  1347     lex.Val( ret );
       
  1348     
       
  1349     return ret;
       
  1350     }