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