natfw/tsrc/natfwtestconsoles/natfwtestconsole/src/iap.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Iap
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "iap.h"
       
    22 #include <commdb.h>
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // TIap::TIap
       
    26 // ---------------------------------------------------------------------------
       
    27 //  
       
    28 TIap::TIap( TUint32 aIapId, const TDesC& aIapName ) :
       
    29     iIapId( aIapId ), iIapName( aIapName )
       
    30     {
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // TIap::IapId
       
    35 // ---------------------------------------------------------------------------
       
    36 //  
       
    37 TUint32 TIap::IapId()
       
    38     {
       
    39     return iIapId;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // TIap::IapName
       
    44 // ---------------------------------------------------------------------------
       
    45 //  
       
    46 const TDesC& TIap::IapName()
       
    47     {
       
    48     return iIapName;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // TIap::ResolveIapL
       
    53 // ---------------------------------------------------------------------------
       
    54 //  
       
    55 TInt TIap::ResolveIapL( RArray<TIap>& aIapArray )
       
    56     {
       
    57     RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -start\n") );
       
    58     
       
    59     TBuf<40> name;
       
    60     TUint32 iapid;
       
    61 
       
    62     CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
    63     CleanupStack::PushL( db );
       
    64     CCommsDbTableView* view = db->OpenTableLC( TPtrC( IAP ) );
       
    65 
       
    66     TInt res = view->GotoFirstRecord();
       
    67     
       
    68     if ( res != KErrNone )
       
    69         {
       
    70         CleanupStack::PopAndDestroy( 2 ); // db, view
       
    71         RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end err: %d\n"), res );
       
    72         return res;
       
    73         }
       
    74     while ( res == KErrNone )  
       
    75         {
       
    76         view->ReadTextL( TPtrC( COMMDB_NAME ), name );
       
    77         view->ReadUintL( TPtrC( COMMDB_ID ), iapid );
       
    78         aIapArray.AppendL( TIap( iapid, name ) );
       
    79         res = view->GotoNextRecord();
       
    80         }
       
    81     CleanupStack::PopAndDestroy( 2 ); // db, view
       
    82 
       
    83     RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end" ) );
       
    84     return KErrNone;
       
    85     }