omadmadapters/connmoadapter/src/BranchBase.cpp
author hgs
Tue, 13 Jul 2010 03:48:30 +0530
changeset 45 0f9fc722d255
parent 44 deviceupdatesui/omadmadapters/connmoadapter/src/BranchBase.cpp@137912d1a556
permissions -rw-r--r--
201021_01
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
hgs
parents:
diff changeset
    20
#include <smldmadapter.h>
hgs
parents:
diff changeset
    21
#include <cdbcols.h>
hgs
parents:
diff changeset
    22
#include <cmpluginpacketdatadef.h>
hgs
parents:
diff changeset
    23
#include "BranchBase.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
#include "Utils.h"
hgs
parents:
diff changeset
    26
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    27
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    28
#include "BranchBaseTraces.h"
hgs
parents:
diff changeset
    29
#endif
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
_LIT8( KCMProxyNodeSeparator,   "/" );
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// ======== LOCAL FUNCTIONS =========
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
// ======== MEMBER FUNCTIONS ========
hgs
parents:
diff changeset
    38
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    39
// CBranchBase::CBranchBase()
hgs
parents:
diff changeset
    40
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    41
CBranchBase::CBranchBase()
hgs
parents:
diff changeset
    42
    {
hgs
parents:
diff changeset
    43
    OstTraceFunctionEntry0( CBRANCHBASE_CBRANCHBASE_ENTRY );
hgs
parents:
diff changeset
    44
    
hgs
parents:
diff changeset
    45
    OstTraceFunctionExit0( CBRANCHBASE_CBRANCHBASE_EXIT );
hgs
parents:
diff changeset
    46
    }
hgs
parents:
diff changeset
    47
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    48
// CBranchBase::CBranchBase
hgs
parents:
diff changeset
    49
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    50
CBranchBase::CBranchBase( MSmlDmCallback* aDmCallback )
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
    {
hgs
parents:
diff changeset
    53
    OstTraceFunctionEntry0( CBRANCHBASE_CBRANCHBASE_2_ENTRY );
hgs
parents:
diff changeset
    54
    iCallback = aDmCallback;
hgs
parents:
diff changeset
    55
    OstTraceFunctionExit0( DUP1_CBRANCHBASE_CBRANCHBASE_2_EXIT );
hgs
parents:
diff changeset
    56
    }
hgs
parents:
diff changeset
    57
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    58
// CBranchBase::~CBranchBase()
hgs
parents:
diff changeset
    59
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    60
CBranchBase::~CBranchBase()
hgs
parents:
diff changeset
    61
    {
hgs
parents:
diff changeset
    62
    OstTraceFunctionEntry0( CBRANCHBASE_DELETE_ENTRY );
hgs
parents:
diff changeset
    63
    
hgs
parents:
diff changeset
    64
    OstTraceFunctionExit0( CBRANCHBASE_DELETE_EXIT );
hgs
parents:
diff changeset
    65
    }
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
// CBranchBase::GetAllConnectionMethodsL()
hgs
parents:
diff changeset
    69
// Returns all connection methods
hgs
parents:
diff changeset
    70
// -------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    71
void CBranchBase::GetAllConnectionMethodsL( RArray<TUint32>& aCmArray,
hgs
parents:
diff changeset
    72
                                           RCmManagerExt& aCmManager )
hgs
parents:
diff changeset
    73
    {
hgs
parents:
diff changeset
    74
    OstTraceFunctionEntry0( CBRANCHBASE_GETALLCONNECTIONMETHODSL_ENTRY );
hgs
parents:
diff changeset
    75
    
hgs
parents:
diff changeset
    76
    // Get all connection methods
hgs
parents:
diff changeset
    77
    TBool supportedBearersOnly = EFalse;
hgs
parents:
diff changeset
    78
    TBool legacyCmsOnly = EFalse;
hgs
parents:
diff changeset
    79
    TBool includeEasyWlan = EFalse;
hgs
parents:
diff changeset
    80
        
hgs
parents:
diff changeset
    81
    aCmManager.ConnectionMethodL( aCmArray, 
hgs
parents:
diff changeset
    82
                                 supportedBearersOnly,
hgs
parents:
diff changeset
    83
                                 legacyCmsOnly,
hgs
parents:
diff changeset
    84
                                 includeEasyWlan );
hgs
parents:
diff changeset
    85
    
hgs
parents:
diff changeset
    86
    RCmConnectionMethodExt cm;
hgs
parents:
diff changeset
    87
    
hgs
parents:
diff changeset
    88
    // Loop all connection methods and filter away everything else besides packet data.
hgs
parents:
diff changeset
    89
    // Other bearer types are not supported
hgs
parents:
diff changeset
    90
    for( TInt i = 0; i < aCmArray.Count(); i++ )
hgs
parents:
diff changeset
    91
        {
hgs
parents:
diff changeset
    92
        if ( GetConnectionMethodLC( aCmManager, cm, aCmArray[i] ) )
hgs
parents:
diff changeset
    93
            {
hgs
parents:
diff changeset
    94
            TUint bearerType = cm.GetIntAttributeL( CMManager::ECmBearerType );                      
hgs
parents:
diff changeset
    95
            
hgs
parents:
diff changeset
    96
            if( bearerType != KUidPacketDataBearerType )
hgs
parents:
diff changeset
    97
                {
hgs
parents:
diff changeset
    98
                // Non supported bearer type. Remove
hgs
parents:
diff changeset
    99
                aCmArray.Remove( i );
hgs
parents:
diff changeset
   100
                i--;              
hgs
parents:
diff changeset
   101
                }            
hgs
parents:
diff changeset
   102
            }        
hgs
parents:
diff changeset
   103
        CleanupStack::PopAndDestroy( &cm );
hgs
parents:
diff changeset
   104
        }
hgs
parents:
diff changeset
   105
    OstTrace1( TRACE_NORMAL, CBRANCHBASE_GETALLCONNECTIONMETHODSL_COUNT, "CBranchBase::GetAllConnectionMethodsL; Found %u connection methods.", aCmArray.Count() );
hgs
parents:
diff changeset
   106
    
hgs
parents:
diff changeset
   107
    OstTraceFunctionExit0( CBRANCHBASE_GETALLCONNECTIONMETHODSL_EXIT );
hgs
parents:
diff changeset
   108
    }
hgs
parents:
diff changeset
   109
hgs
parents:
diff changeset
   110
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   111
// TBool CBranchBase::CheckPreviousURIList()
hgs
parents:
diff changeset
   112
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   113
TBool CBranchBase::CheckPreviousURIList( const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
hgs
parents:
diff changeset
   114
                                         const TUint32 aCmId,
hgs
parents:
diff changeset
   115
                                         TDes8& aURISeg )
hgs
parents:
diff changeset
   116
    {
hgs
parents:
diff changeset
   117
    OstTraceExt2( TRACE_NORMAL, CBRANCHBASE_CHECKPREVIOUSURILIST_ENTRY, "ENTRY: CBranchBase::CheckPreviousURIList;aURISeg=%s;aCmId=%u", aURISeg, aCmId );
hgs
parents:
diff changeset
   118
    
hgs
parents:
diff changeset
   119
    TBool retval = EFalse;
hgs
parents:
diff changeset
   120
    
hgs
parents:
diff changeset
   121
    for ( TInt i = 0; i < aPreviousURISegmentList.Count(); i++ )
hgs
parents:
diff changeset
   122
        {        
hgs
parents:
diff changeset
   123
        if ( CUtils::IntLUID( aPreviousURISegmentList.At(i).iURISegLUID ) == aCmId )
hgs
parents:
diff changeset
   124
            {
hgs
parents:
diff changeset
   125
            aURISeg.Copy( aPreviousURISegmentList.At(i).iURISeg );
hgs
parents:
diff changeset
   126
            retval = ETrue;
hgs
parents:
diff changeset
   127
            break;
hgs
parents:
diff changeset
   128
            }
hgs
parents:
diff changeset
   129
        }
hgs
parents:
diff changeset
   130
    OstTrace1( TRACE_NORMAL, CBRANCHBASE_CHECKPREVIOUSURILIST_EXIT, "EXIT: CBranchBase::CheckPreviousURIList;retval=%d", retval );
hgs
parents:
diff changeset
   131
    
hgs
parents:
diff changeset
   132
    return retval;
hgs
parents:
diff changeset
   133
    }
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   137
// CBranchBase::GetAllDynamicNodesL
hgs
parents:
diff changeset
   138
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   139
void CBranchBase::GetAllDynamicNodesL( const TDesC8& aURI, 
hgs
parents:
diff changeset
   140
                                       const TDesC8& /*aLUID*/,
hgs
parents:
diff changeset
   141
                                       const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
hgs
parents:
diff changeset
   142
                                       TInt aResultsRef,
hgs
parents:
diff changeset
   143
                                       TInt aStatusRef,
hgs
parents:
diff changeset
   144
                                       RCmManagerExt& /*aCmManagerExt*/,
hgs
parents:
diff changeset
   145
                                       CBufBase& aCurrentURISegmentList,
hgs
parents:
diff changeset
   146
                                       const TDesC8& aField,
hgs
parents:
diff changeset
   147
                                       const TInt aNodeCount,
hgs
parents:
diff changeset
   148
                                       MSmlDmCallback* aCallback )
hgs
parents:
diff changeset
   149
    {
hgs
parents:
diff changeset
   150
    OstTraceExt3( TRACE_NORMAL, 
hgs
parents:
diff changeset
   151
                  CBRANCHBASE_GETALLDYNAMICNODESL_ENTRY, 
hgs
parents:
diff changeset
   152
                  "ENTRY: CBranchBase::GetAllDynamicNodesL;aURI=%s;aField=%s;aNodeCount=%d", 
hgs
parents:
diff changeset
   153
                  aURI, 
hgs
parents:
diff changeset
   154
                  aField, 
hgs
parents:
diff changeset
   155
                  aNodeCount );
hgs
parents:
diff changeset
   156
    
hgs
parents:
diff changeset
   157
    if ( aPreviousURISegmentList.Count() > 0 ) // Already mapped
hgs
parents:
diff changeset
   158
        {
hgs
parents:
diff changeset
   159
        for ( TInt i = 0; i < aPreviousURISegmentList.Count(); i++ )
hgs
parents:
diff changeset
   160
            {
hgs
parents:
diff changeset
   161
            aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), 
hgs
parents:
diff changeset
   162
                                            aPreviousURISegmentList.At(i).iURISeg );
hgs
parents:
diff changeset
   163
            aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), 
hgs
parents:
diff changeset
   164
                                            KCMProxyNodeSeparator );                
hgs
parents:
diff changeset
   165
            }
hgs
parents:
diff changeset
   166
        }
hgs
parents:
diff changeset
   167
    else
hgs
parents:
diff changeset
   168
        {
hgs
parents:
diff changeset
   169
        TBuf8<KSmlMaxURISegLen> addNodeName;
hgs
parents:
diff changeset
   170
   
hgs
parents:
diff changeset
   171
        // Generate as many nodes as defined
hgs
parents:
diff changeset
   172
        for ( TInt i = 1; i <= aNodeCount; i++ )
hgs
parents:
diff changeset
   173
            {
hgs
parents:
diff changeset
   174
            addNodeName.Format( _L8( "%s%d" ), aField.Ptr(), i );
hgs
parents:
diff changeset
   175
            aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), addNodeName );
hgs
parents:
diff changeset
   176
            aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), 
hgs
parents:
diff changeset
   177
                                            KCMProxyNodeSeparator );
hgs
parents:
diff changeset
   178
            }            
hgs
parents:
diff changeset
   179
       }
hgs
parents:
diff changeset
   180
    
hgs
parents:
diff changeset
   181
    aCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
hgs
parents:
diff changeset
   182
    aCallback->SetResultsL( aResultsRef, aCurrentURISegmentList, KNullDesC8);
hgs
parents:
diff changeset
   183
    
hgs
parents:
diff changeset
   184
    OstTrace0( TRACE_NORMAL, 
hgs
parents:
diff changeset
   185
               CBRANCHBASE_GETALLDYNAMICNODESL_EXIT, 
hgs
parents:
diff changeset
   186
               "EXIT: CBranchBase::GetAllDynamicNodesL" );
hgs
parents:
diff changeset
   187
       
hgs
parents:
diff changeset
   188
    }
hgs
parents:
diff changeset
   189
hgs
parents:
diff changeset
   190
//------------------------------------------------------------------------------
hgs
parents:
diff changeset
   191
//  TBool CBranchBase::GetConnectionMethodLC()
hgs
parents:
diff changeset
   192
//------------------------------------------------------------------------------ 
hgs
parents:
diff changeset
   193
TBool CBranchBase::GetConnectionMethodLC( RCmManagerExt& aCmManagerExt,
hgs
parents:
diff changeset
   194
                                          RCmConnectionMethodExt& aCm,
hgs
parents:
diff changeset
   195
                                          TUint32 aCmId )
hgs
parents:
diff changeset
   196
    {
hgs
parents:
diff changeset
   197
    OstTrace1( TRACE_NORMAL, CBRANCHBASE_GETCONNECTIONMETHODLC_ENTRY, "ENTRY: CBranchBase::GetConnectionMethodLC;aCmId=%d", aCmId );
hgs
parents:
diff changeset
   198
    TInt error( KErrNone );
hgs
parents:
diff changeset
   199
    
hgs
parents:
diff changeset
   200
    TRAP( error, aCm = aCmManagerExt.ConnectionMethodL( aCmId ) );
hgs
parents:
diff changeset
   201
    
hgs
parents:
diff changeset
   202
    CleanupClosePushL( aCm );
hgs
parents:
diff changeset
   203
    
hgs
parents:
diff changeset
   204
    if ( error != KErrNone )
hgs
parents:
diff changeset
   205
        {
hgs
parents:
diff changeset
   206
        OstTrace0( TRACE_NORMAL, 
hgs
parents:
diff changeset
   207
                   CBRANCHBASE_GETCONNECTIONMETHODLC_EXIT_NOT_FOUND, 
hgs
parents:
diff changeset
   208
                   "EXIT: CBranchBase::GetConnectionMethodLC;Connection Method NOT found: EFalse." );
hgs
parents:
diff changeset
   209
        return EFalse;
hgs
parents:
diff changeset
   210
        }
hgs
parents:
diff changeset
   211
    
hgs
parents:
diff changeset
   212
    OstTrace0( TRACE_NORMAL, 
hgs
parents:
diff changeset
   213
               CBRANCHBASE_GETCONNECTIONMETHODLC_EXIT_FOUND, 
hgs
parents:
diff changeset
   214
               "EXIT: CBranchBase::GetConnectionMethodLC;Connection Method FOUND: ETrue." );
hgs
parents:
diff changeset
   215
    
hgs
parents:
diff changeset
   216
    return ETrue;
hgs
parents:
diff changeset
   217
    }
hgs
parents:
diff changeset
   218
hgs
parents:
diff changeset
   219
// ======== GLOBAL FUNCTIONS ========
hgs
parents:
diff changeset
   220