apengine/apeng/src/APSelect.cpp
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
child 18 fcbbe021d614
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Declaration of the CApSelect class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <cdbcols.h>
       
    21 #include <commdb.h>
       
    22 #include <eikdef.h>
       
    23 #include <d32dbms.h>
       
    24 #include <featmgr.h>
       
    25 
       
    26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 #include <ProtectDb.h>
       
    28 #else
       
    29 #include <comms-infras/commdb/protection/protectdb.h>
       
    30 #endif
       
    31 
       
    32 #include <etelpckt.h>
       
    33 #ifdef __TEST_USE_SHARED_DATA
       
    34     #include <sharedDataValues.h>
       
    35 #endif // __TEST_USE_SHARED_DATA
       
    36 
       
    37 #include "ApListItem.h"
       
    38 #include "ApListItemList.h"
       
    39 #include "ApSelect.h"
       
    40 #include "ApUtils.h"
       
    41 #include "ApEngineCommons.h"
       
    42 #include <ApEngineConsts.h>
       
    43 #include "ApEngineLogger.h"
       
    44 #include "ApListItemKey.h"
       
    45 
       
    46 
       
    47 
       
    48 
       
    49 // CONSTANTS
       
    50 const TInt KCursorNullPos = 0;
       
    51 const TInt KItemCountNull = 0;
       
    52 
       
    53 #ifdef __TEST_USE_SHARED_DATA
       
    54     // General Settings UID, Hardcoded
       
    55     const TUid KGeneralSettingsUid={0X100058EC};
       
    56 #endif // __TEST_USE_SHARED_DATA
       
    57 
       
    58 
       
    59 const TInt KDIALOUT     = 0;
       
    60 const TInt KGPRSIN      = 1;
       
    61 const TInt KGPRSOUT     = 2;
       
    62 const TInt KCDMA_ISP    = 3;
       
    63 const TInt KVPN         = 4;
       
    64 
       
    65 
       
    66 const TInt  KUID        = 0;
       
    67 const TInt  KISPTYPE    = 1;
       
    68 const TInt  KBEARERTYPE = 2;
       
    69 
       
    70 
       
    71 
       
    72 // LOCAL CONSTANTS AND MACROS
       
    73 
       
    74 
       
    75 // LOCAL FUNCTION PROTOTYPES
       
    76 
       
    77 // ================= MEMBER FUNCTIONS =======================
       
    78 // Two-phased constructor.
       
    79 // ---------------------------------------------------------
       
    80 // CApSelect::NewLC
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 EXPORT_C CApSelect* CApSelect::NewLC( CCommsDatabase& aDb,
       
    84                                      TInt aIspFilter,
       
    85                                      TInt aBearerFilter,
       
    86                                      TInt aSortType )
       
    87     {
       
    88     CLOG( ( ESelect, 0, _L( "-> CApSelect::NewLC" ) ) );
       
    89 
       
    90     CApSelect* db = CApSelect::NewLC( aDb, aIspFilter, 
       
    91                                       aBearerFilter, aSortType, EIPv4 );
       
    92 
       
    93     CLOG( ( ESelect, 1, _L( "<- CApSelect::NewLC" ) ) );
       
    94     return db;
       
    95     }
       
    96 
       
    97 
       
    98 // Destructor
       
    99 // ---------------------------------------------------------
       
   100 // CApSelect::~CApSelect
       
   101 // ---------------------------------------------------------
       
   102 //
       
   103 EXPORT_C CApSelect::~CApSelect()
       
   104     {
       
   105     CLOG( ( ESelect, 0, _L( "-> CApSelect::~CApSelect" ) ) );
       
   106 
       
   107     if ( iExt )
       
   108         {
       
   109         if ( iExt->iIsFeatureManagerInitialised )
       
   110             {
       
   111             FeatureManager::UnInitializeLib();
       
   112             }
       
   113         }
       
   114 
       
   115     if ( iApList )
       
   116         {
       
   117         iApList->ResetAndDestroy();
       
   118         delete iApList;
       
   119         }
       
   120     
       
   121     delete iExt;
       
   122 
       
   123     CLOG( ( ESelect, 1, _L( "<- CApSelect::~CApSelect" ) ) );
       
   124     }
       
   125 
       
   126 
       
   127 // C++ default constructor can NOT contain any code that
       
   128 // might leave.
       
   129 //
       
   130 // ---------------------------------------------------------
       
   131 // CApSelect::CApSelect
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 EXPORT_C CApSelect::CApSelect()
       
   135 :iCursor( KCursorNullPos ),
       
   136 iCount( KItemCountNull )
       
   137     {
       
   138     }
       
   139 
       
   140 
       
   141 // Symbian OS default constructor can leave.
       
   142 // ---------------------------------------------------------
       
   143 // CApSelect::ConstructL
       
   144 // ---------------------------------------------------------
       
   145 //
       
   146 EXPORT_C void CApSelect::ConstructL( CCommsDatabase& aDb,
       
   147                                  TInt aIspFilter,
       
   148                                  TInt aBearerFilter,
       
   149                                  TInt aSortType )
       
   150 
       
   151     {
       
   152     ConstructL( aDb, aIspFilter, aBearerFilter, 
       
   153                 aSortType, EIPv4, EVpnFilterBoth );
       
   154     }
       
   155 
       
   156 
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CApSelect::SetFilters
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 EXPORT_C void CApSelect::SetFiltersL( TInt aIspFilter,
       
   163                                     TInt aBearerFilter,
       
   164                                     TInt aSortType )
       
   165     {
       
   166     SetFiltersL( aIspFilter, aBearerFilter, aSortType, 
       
   167                  iExt->iReqIpvType, iExt->iVpnFilterType );
       
   168                  
       
   169     }
       
   170 
       
   171 
       
   172 // ---------------------------------------------------------
       
   173 // CApSelect::IspTypeFilter
       
   174 // ---------------------------------------------------------
       
   175 //
       
   176 EXPORT_C TInt CApSelect::IspTypeFilter()
       
   177     {
       
   178     CLOG( ( ESelect, 0, _L( "<-> CApSelect::IspTypeFilter" ) ) );
       
   179 
       
   180     return iIsp;
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CApSelect::BearerFilter
       
   186 // ---------------------------------------------------------
       
   187 //
       
   188 EXPORT_C TInt CApSelect::BearerFilter()
       
   189     {
       
   190     CLOG( ( ESelect, 0, _L( "<-> CApSelect::BearerFilter" ) ) );
       
   191 
       
   192     return iBearer;
       
   193     }
       
   194 
       
   195 
       
   196 // ---------------------------------------------------------
       
   197 // CApSelect::SortOrder
       
   198 // ---------------------------------------------------------
       
   199 //
       
   200 EXPORT_C TInt CApSelect::SortOrder()
       
   201     {
       
   202     CLOG( ( ESelect, 0, _L( "<-> CApSelect::SortOrder" ) ) );
       
   203 
       
   204     return iSort;
       
   205     }
       
   206 
       
   207 
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // CApSelect::MoveToFirst
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 EXPORT_C TBool CApSelect::MoveToFirst()
       
   214     {
       
   215     CLOG( ( ESelect, 0, _L( "<-> CApSelect::MoveToFirst" ) ) );
       
   216 
       
   217     iCursor = 0;
       
   218     return ( iExt->iMaxIndex >= 0 );
       
   219     }
       
   220 
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // CApSelect::MoveNext
       
   224 // ---------------------------------------------------------
       
   225 //
       
   226 EXPORT_C TBool CApSelect::MoveNext()
       
   227     {
       
   228     CLOG( ( ESelect, 0, _L( "<-> CApSelect::MoveNext" ) ) );
       
   229 
       
   230     if ( iCursor < iExt->iMaxIndex )
       
   231         {
       
   232         iCursor++;
       
   233         return ETrue;
       
   234         }
       
   235     return EFalse;
       
   236     }
       
   237 
       
   238 
       
   239 // ---------------------------------------------------------
       
   240 // CApSelect::MoveLast
       
   241 // ---------------------------------------------------------
       
   242 //
       
   243 EXPORT_C TBool CApSelect::MoveLast()
       
   244     {
       
   245     CLOG( ( ESelect, 0, _L( "<-> CApSelect::MoveLast" ) ) );
       
   246 
       
   247     iCursor = iExt->iMaxIndex;
       
   248     return ( iCursor >= 0 );
       
   249     }
       
   250 
       
   251 
       
   252 // ---------------------------------------------------------
       
   253 // CApSelect::MovePrev
       
   254 // ---------------------------------------------------------
       
   255 //
       
   256 EXPORT_C TBool CApSelect::MovePrev()
       
   257     {
       
   258     CLOG( ( ESelect, 0, _L( "<-> CApSelect::MovePrev" ) ) );
       
   259 
       
   260     if ( iCursor>0 )
       
   261         {
       
   262         iCursor--;
       
   263         return ETrue;
       
   264         }
       
   265     return EFalse;
       
   266     }
       
   267 
       
   268 
       
   269 // ---------------------------------------------------------
       
   270 // CApSelect::Count
       
   271 // ---------------------------------------------------------
       
   272 //
       
   273 EXPORT_C TUint32 CApSelect::Count()
       
   274     {
       
   275     CLOG( ( ESelect, 0, _L( "<-> CApSelect::Count" ) ) );
       
   276 
       
   277     return iApList->Count( );
       
   278     }
       
   279 
       
   280 
       
   281 // ---------------------------------------------------------
       
   282 // CApSelect::Name
       
   283 // ---------------------------------------------------------
       
   284 //
       
   285 EXPORT_C const TDesC& CApSelect::Name()
       
   286     {
       
   287     CLOG( ( ESelect, 0, _L( "<-> CApSelect::Name" ) ) );
       
   288 
       
   289     return *iApList->At( iCursor )->iName;
       
   290     }
       
   291 
       
   292 
       
   293 // ---------------------------------------------------------
       
   294 // CApSelect::Uid
       
   295 // ---------------------------------------------------------
       
   296 //
       
   297 EXPORT_C TUint32 CApSelect::Uid()
       
   298     {
       
   299     CLOG( ( ESelect, 0, _L( "<-> CApSelect::Uid" ) ) );
       
   300 
       
   301     return iApList->At( iCursor )->iUid;
       
   302     }
       
   303 
       
   304 
       
   305 // ---------------------------------------------------------
       
   306 // CApSelect::Type
       
   307 // ---------------------------------------------------------
       
   308 //
       
   309 EXPORT_C TCommsDbIspType CApSelect::Type()
       
   310     {
       
   311     CLOG( ( ESelect, 0, _L( "<-> CApSelect::Type" ) ) );
       
   312 
       
   313     return iApList->At( iCursor )->iIspType;
       
   314     }
       
   315 
       
   316 
       
   317 // ---------------------------------------------------------
       
   318 // CApSelect::BearerType
       
   319 // ---------------------------------------------------------
       
   320 //
       
   321 EXPORT_C TApBearerType CApSelect::BearerType()
       
   322     {
       
   323     CLOG( ( ESelect, 0, _L( "<-> CApSelect::BearerType" ) ) );
       
   324 
       
   325     return iApList->At( iCursor )->iBearerType;
       
   326     }
       
   327 
       
   328 
       
   329 
       
   330 
       
   331 // ---------------------------------------------------------
       
   332 // CApSelect::AllListItemDataL
       
   333 // ---------------------------------------------------------
       
   334 //
       
   335 EXPORT_C TInt CApSelect::AllListItemDataL( CApListItemList& aList )
       
   336     {
       
   337     CLOG( ( ESelect, 0, _L( "-> CApSelect::AllListItemDataL" ) ) );
       
   338 
       
   339     aList.ResetAndDestroy();
       
   340 
       
   341     CApListItem* item=NULL;
       
   342 
       
   343     TInt i;
       
   344     TInt count = iApList->Count();
       
   345     for ( i=0; i<count; i++ )
       
   346         {
       
   347         item = CApListItem::NewLC( ( *iApList )[i] );
       
   348         aList.AppendL( item );
       
   349         CleanupStack::Pop( item ); // item owned by aList !
       
   350         }
       
   351     CLOG( ( ESelect, 1, _L( "<- CApSelect::AllListItemDataL" ) ) );
       
   352 
       
   353     return aList.Count();
       
   354     }
       
   355 
       
   356 
       
   357 
       
   358 // ---------------------------------------------------------
       
   359 // CApSelect::IsReadOnly
       
   360 // ---------------------------------------------------------
       
   361 //
       
   362 EXPORT_C TBool CApSelect::IsReadOnly() const
       
   363     {
       
   364     CLOG( ( ESelect, 0, _L( "<-> CApSelect::IsReadOnly" ) ) );
       
   365 
       
   366     return iApList->At( iCursor )->iExt->iReadOnly;
       
   367     }
       
   368 
       
   369 
       
   370 
       
   371 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   372 
       
   373 // ================== OTHER MEMBER FUNCTIONS ===============
       
   374 
       
   375 
       
   376 
       
   377 // ---------------------------------------------------------
       
   378 // CApSelect::DoUpdate
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 TInt CApSelect::DoUpdateL()
       
   382     {
       
   383     CLOG( ( ESelect, 0, _L( "-> CApSelect::DoUpdateL" ) ) );
       
   384 
       
   385     // filtering criteria:
       
   386     // Bearer type
       
   387     // Isp type
       
   388     // HasMandatory
       
   389     // + ordering (name or UID...)
       
   390     // first filter WAP_ACCESS_POINT table and order it
       
   391     TBool OwnTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   392     if ( !OwnTransaction )
       
   393         {
       
   394         __ASSERT_DEBUG( EFalse, ApCommons::Panic( ENotSupported ) );
       
   395         User::Leave( KErrNotSupported );
       
   396         }
       
   397 
       
   398     CCommsDbTableView* wapt = NULL;
       
   399     CCommsDbTableView* ipbearert = NULL;
       
   400 
       
   401     CCommsDbTableView* iapt = NULL;
       
   402                                      // csdOut, GprsIn, gprsOut, cdma,  VPN
       
   403     CCommsDbTableView* isptables[5] = { NULL,   NULL,   NULL,   NULL,   NULL};
       
   404 
       
   405 
       
   406     wapt = GetFilteredSortedWapTableViewLC();
       
   407     TInt err = wapt->GotoFirstRecord(); // OK.
       
   408     if ( ( err == KErrNone ) || ( err == KErrNotFound ) )
       
   409         { // even if it is empty, we must clear the list.
       
   410         // otherwise, Leave
       
   411         // fill up list. First empty it
       
   412         iApList->ResetAndDestroy();
       
   413         iCount = 0;
       
   414         if ( err == KErrNone )
       
   415             { // have some, we can go on...
       
   416             // First get ip_bearer table, then iap, then isp & gprs, if needed
       
   417             if ( ( iBearer & EApBearerTypeCSD ) ||
       
   418                  ( iBearer & EApBearerTypeHSCSD ) ||
       
   419                  ( iBearer & EApBearerTypeGPRS ) ||
       
   420                  ( iExt->iCdma && ( iBearer & EApBearerTypeCDMA ) ) )
       
   421                 {
       
   422                 ipbearert = GetFilteredSortedIpBearerTableViewLC();
       
   423                 if ( ipbearert )
       
   424                     {
       
   425                     err = ipbearert->GotoFirstRecord();
       
   426                     if ( err == KErrNone )
       
   427                         {
       
   428                         if ( ( iBearer & EApBearerTypeCSD ) ||
       
   429                              ( iBearer & EApBearerTypeHSCSD ) )
       
   430                             {
       
   431                             isptables[KDIALOUT] =
       
   432                                 GetFilteredSortedIspOutTableViewLC();
       
   433                             }
       
   434                         if ( ( iBearer & EApBearerTypeGPRS ) )
       
   435                             {
       
   436                             isptables[KGPRSIN] =
       
   437                                 GetFilteredSortedGprsTableViewLC( ETrue );
       
   438                             isptables[KGPRSOUT] =
       
   439                                 GetFilteredSortedGprsTableViewLC( EFalse );
       
   440                             }
       
   441                         }
       
   442                     else
       
   443                         {
       
   444                         if ( err != KErrNotFound )
       
   445                             {
       
   446                             User::LeaveIfError( err );
       
   447                             }
       
   448                         }
       
   449                     }
       
   450                 }
       
   451             // get wapapids
       
   452                // get smsapids, if defined
       
   453             // get ipapids with iap ids
       
   454             // get only those iap ids from filtered database
       
   455             CArrayFixFlat<TUint32>* wapapid =
       
   456                     new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   457             CleanupStack::PushL( wapapid );
       
   458             GetUintValuesL( wapt, TPtrC(COMMDB_ID), *wapapid );
       
   459 
       
   460             // read up access point names, too, just to be as fast as we can...
       
   461             CArrayPtrFlat<HBufC>* wapapname =
       
   462                     new ( ELeave ) CArrayPtrFlat<HBufC>( 10 );
       
   463             CleanupStack::PushL( wapapname );
       
   464             GetTextValuesL( wapt, TPtrC(COMMDB_NAME), *wapapname );
       
   465 
       
   466 
       
   467             // read up start page, too, just to be as fast as we can...
       
   468             CArrayPtrFlat<HBufC>* wapstartpage =
       
   469                     new ( ELeave ) CArrayPtrFlat<HBufC>( 10 );
       
   470             CleanupStack::PushL( wapstartpage );
       
   471             // as it is LONG text...
       
   472             GetLongTextValuesL( wapt, TPtrC(WAP_START_PAGE), *wapstartpage );
       
   473 
       
   474             //read up Read-only flags
       
   475             CArrayFixFlat<TUint32>* protflags =
       
   476                     new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   477             CleanupStack::PushL( protflags );
       
   478             GetProtValuesL( wapt, *protflags );
       
   479 
       
   480 
       
   481             CArrayFixFlat<TUint32>* ipapid =
       
   482                     new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   483             CleanupStack::PushL( ipapid );
       
   484             GetUintValuesL( ipbearert, TPtrC(WAP_ACCESS_POINT_ID), *ipapid );
       
   485 
       
   486             CArrayFixFlat<TUint32>* ipiapid =
       
   487                     new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   488             CleanupStack::PushL( ipiapid );
       
   489             GetUintValuesL( ipbearert, TPtrC(WAP_IAP), *ipiapid );
       
   490 
       
   491 
       
   492 
       
   493 
       
   494             // What comes next:::::
       
   495             // for each table:
       
   496             // filter separately for different bearers ->
       
   497             // we know the bearer type...
       
   498             // filter separately for different ISP types ->
       
   499             // we know the ISP type...
       
   500             // now all we have to do is to 'simply' check filtered IAP with
       
   501             // the separate arrays, leave only those that present in
       
   502             // both bearer & isp array
       
   503             // fill up an array of id & an array of bearer type &
       
   504             // an array of isp type
       
   505             // after it, narrow down wap with wapbearer,
       
   506             // create items in order,
       
   507             // check items against remained iap array
       
   508             // fill up values in list.
       
   509             // bearer arrays : 0: csd, 1:hscsd, 2: gprs, 3: cdma
       
   510 
       
   511             TInt i( 0 );
       
   512 
       
   513             // an array Isp[CSDOut/GPRSIn/GPRSOut/CDMA/VPN]
       
   514             //             [COMMDB_ID, ISP_TYPE, Bearer_type]
       
   515             CArrayFixFlat<TUint32[3]>* ispArray[5];
       
   516             for (i=0; i<5; i++)
       
   517                 {
       
   518                 ispArray[i] = new ( ELeave ) CArrayFixFlat<TUint32[3]>( 10 );
       
   519                 CleanupStack::PushL( ispArray[i] );
       
   520                 }
       
   521 
       
   522             if ( isptables[KDIALOUT] )
       
   523                 {
       
   524                 GetIspValuesL( isptables[KDIALOUT], ispArray[KDIALOUT],
       
   525                                TPtrC(ISP_TYPE) );
       
   526                 }
       
   527             if ( isptables[KGPRSIN] )
       
   528                 {
       
   529                 GetIspValuesL( isptables[KGPRSIN], ispArray[KGPRSIN],
       
   530                                TPtrC(GPRS_AP_TYPE) );
       
   531                 }
       
   532             if ( isptables[KGPRSOUT] )
       
   533                 {
       
   534                 GetIspValuesL( isptables[KGPRSOUT], ispArray[KGPRSOUT],
       
   535                                TPtrC(GPRS_AP_TYPE) );
       
   536                 }
       
   537             if ( isptables[KCDMA_ISP] )  // NULL if iExt->iCdma==EFalse.
       
   538                 {
       
   539                 GetIspValuesL( isptables[KCDMA_ISP], ispArray[KCDMA_ISP], 
       
   540                                TPtrC(CDMA_AP_TYPE) );
       
   541                 }
       
   542 
       
   543 
       
   544             // iap arrays, 5 table, needs UID & linked ID for both
       
   545             CArrayFixFlat<TUint32>* iapArrays[5][2];
       
   546             for (i=0; i<5; i++)
       
   547                 {
       
   548                 iapArrays[i][0] = new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   549                 CleanupStack::PushL( iapArrays[i][0] );
       
   550 
       
   551                 iapArrays[i][1] = new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
   552                 CleanupStack::PushL( iapArrays[i][1] );
       
   553                 }
       
   554             // get iap table data...
       
   555             // needs IAP UID & Iap_service
       
   556             if ( ( iBearer & EApBearerTypeCSD ) ||
       
   557                  ( iBearer & EApBearerTypeHSCSD ) )
       
   558                 {
       
   559                 iapt = OpenViewMatchingTextL( TPtrC(IAP),
       
   560                                               TPtrC(IAP_SERVICE_TYPE),
       
   561                                               TPtrC(DIAL_OUT_ISP) );
       
   562                 CleanupStack::PushL( iapt );
       
   563                 GetUintValuesL( iapt, TPtrC(COMMDB_ID),
       
   564                                 *iapArrays[KDIALOUT][0] );
       
   565                 GetUintValuesL( iapt, TPtrC(IAP_SERVICE),
       
   566                                 *iapArrays[KDIALOUT][1] );
       
   567                 CleanupStack::PopAndDestroy( iapt ); // iapt;
       
   568                 iapt = NULL;
       
   569                 }
       
   570 
       
   571 
       
   572             if ( iBearer & EApBearerTypeGPRS )
       
   573                 {
       
   574                 iapt = OpenViewMatchingTextL( TPtrC(IAP),
       
   575                                               TPtrC(IAP_SERVICE_TYPE),
       
   576                                               TPtrC(INCOMING_WCDMA) );
       
   577                 CleanupStack::PushL( iapt );
       
   578                 GetUintValuesL( iapt, TPtrC(COMMDB_ID),
       
   579                                 *iapArrays[KGPRSIN][0] );
       
   580                 GetUintValuesL( iapt, TPtrC(IAP_SERVICE),
       
   581                                 *iapArrays[KGPRSIN][1] );
       
   582                 CleanupStack::PopAndDestroy( iapt ); // iapt;
       
   583                 iapt = NULL;
       
   584 
       
   585                 iapt = OpenViewMatchingTextL( TPtrC(IAP),
       
   586                                               TPtrC(IAP_SERVICE_TYPE),
       
   587                                               TPtrC(OUTGOING_WCDMA) );
       
   588                 CleanupStack::PushL( iapt );
       
   589                 GetUintValuesL( iapt, TPtrC(COMMDB_ID),
       
   590                                 *iapArrays[KGPRSOUT][0] );
       
   591                 GetUintValuesL( iapt, TPtrC(IAP_SERVICE),
       
   592                                 *iapArrays[KGPRSOUT][1] );
       
   593                 CleanupStack::PopAndDestroy( iapt ); // iapt;
       
   594                 iapt = NULL;
       
   595                 }
       
   596 
       
   597             if ( ( iExt->iVpnFilterType == EVpnFilterVpnOnly ) ||
       
   598                 ( iExt->iVpnFilterType == EVpnFilterBoth ) )
       
   599                 {
       
   600                 iapt = OpenViewMatchingTextL( TPtrC(IAP),
       
   601                                               TPtrC(IAP_SERVICE_TYPE),
       
   602                                               TPtrC(VPN_SERVICE) );
       
   603                 CleanupStack::PushL( iapt );
       
   604                 GetUintValuesL( iapt, TPtrC(COMMDB_ID),
       
   605                                 *iapArrays[KVPN][0] );
       
   606                 GetUintValuesL( iapt, TPtrC(IAP_SERVICE),
       
   607                                 *iapArrays[KVPN][1] );
       
   608                 CleanupStack::PopAndDestroy( iapt ); // iapt;
       
   609                 iapt = NULL;
       
   610                 }
       
   611 
       
   612 
       
   613 
       
   614             CArrayFixFlat<TVpnData>* vpnArray = NULL;
       
   615 
       
   616             if ( ( iExt->iVpnFilterType == EVpnFilterVpnOnly ) ||
       
   617                 ( iExt->iVpnFilterType == EVpnFilterBoth ) )
       
   618                 { // get VPN related data, namely Home IAP and name
       
   619                 isptables[KVPN] = GetVpnTableViewLC();
       
   620 
       
   621                 if ( isptables[KVPN] )
       
   622                     {
       
   623 
       
   624                     vpnArray = new ( ELeave ) CArrayFixFlat<TVpnData>( 10 );
       
   625                     CleanupStack::PushL( vpnArray );
       
   626 
       
   627                     GetVpnValuesL( isptables[KVPN], vpnArray );
       
   628                     }
       
   629                 }
       
   630 
       
   631 
       
   632 
       
   633 
       
   634             // till this point, we have done what we can.
       
   635             // now we narrow down arrays.
       
   636             // start with iap vs isp arrays, leave what we can in iap array.
       
   637 
       
   638             CApListItem* item = NULL;
       
   639             CApListItemList* tmpApList = new( ELeave )CApListItemList();
       
   640             CleanupStack::PushL( tmpApList );
       
   641             TApBearerType bearer (EApBearerTypeAllBearers);
       
   642 
       
   643             // iapArrays[5][2]:
       
   644             // 5 table (DialOut, GprsIn, Out, Cdma, VPN),2 id's(Uid,ServiceId)
       
   645             // iapArrays[0] : Dial In service
       
   646             // ispinbearerArrays: 0: csd, 1:hscsd, 2: gprs. 3: cdma
       
   647 
       
   648             // 'Merge' iap with isp, create temp. items with bearer types
       
   649             // iap/DialIn/ServiceID : iapArrays[0][1]
       
   650 
       
   651             // check all iap/DialIn/ServiceID if it is in isparray ->
       
   652             // array Gives bearer type & isp type
       
   653             TInt j, iappos;
       
   654             // check all iap/DialOut/ServiceID if it is
       
   655             // in ispoutbearerarray[0,1]
       
   656             if ( iapArrays[KDIALOUT][1] )
       
   657                 {
       
   658                 for (j=0; j<iapArrays[KDIALOUT][1]->Count(); j++)
       
   659                     {
       
   660                     bearer = EApBearerTypeAllBearers;
       
   661                     // check all iap/DialOut/ServiceID if it is in isparray
       
   662                     // check if it is in ispArray[UID, ISP, Bearer]
       
   663                     // & return pos.
       
   664                     iappos = GetIapPos( ispArray[KDIALOUT],
       
   665                                         iapArrays[KDIALOUT][1]->At( j ) );
       
   666                     if ( iappos != KErrNotFound )
       
   667                         { // DialOut, Isp, Bearer...
       
   668                         // create temp. item WITH IAP ID, Bearer type
       
   669                         if ( ispArray[KDIALOUT]->At( iappos )[KBEARERTYPE] ==
       
   670                              EBearerTypeCSD )
       
   671                             {
       
   672                             bearer = EApBearerTypeCSD;
       
   673                             }
       
   674                         else
       
   675                             { // HSCSD bearer
       
   676                             bearer = EApBearerTypeHSCSD;
       
   677                             }
       
   678                         // create temp. item WITH IAP ID, Bearer type
       
   679                         item = CApListItem::NewLC
       
   680                             (
       
   681                             (TCommsDbIspType)
       
   682                                 ispArray[KDIALOUT]->At( iappos )[KISPTYPE],
       
   683                             iapArrays[KDIALOUT][0]->At( j ),
       
   684                             KEmpty,
       
   685                             bearer
       
   686                             );
       
   687                         tmpApList->AppendL( item );
       
   688                         CleanupStack::Pop( item ); // item owned by list !
       
   689                         }
       
   690                     }
       
   691                 }
       
   692 
       
   693 
       
   694 
       
   695             // check all iap/GprsIn/ServiceID if it is in ispinbearerarray[2]
       
   696             if ( iapArrays[KGPRSIN][1] )
       
   697                 {
       
   698                 bearer = EApBearerTypeGPRS;
       
   699                 for (j=0; j<iapArrays[KGPRSIN][1]->Count(); j++)
       
   700                     {
       
   701                     iappos = GetIapPos( ispArray[KGPRSIN],
       
   702                                         iapArrays[KGPRSIN][1]->At( j ) );
       
   703                     if ( iappos != KErrNotFound )
       
   704                         { // GprsIn, Isp, Bearer...
       
   705                         // create temp. item WITH IAP ID, Bearer type
       
   706                         item = CApListItem::NewLC
       
   707                             (
       
   708                             (TCommsDbIspType)
       
   709                                 ispArray[KGPRSIN]->At( iappos )[KISPTYPE],
       
   710                             iapArrays[KGPRSIN][0]->At( j ),
       
   711                             KEmpty,
       
   712                             bearer
       
   713                             );
       
   714                         tmpApList->AppendL( item );
       
   715                         CleanupStack::Pop( item ); // item owned by list !
       
   716                         }
       
   717                     }
       
   718                 }
       
   719 
       
   720 
       
   721             // check all iap/GprsOut/ServiceID if it is in isparray
       
   722             if ( iapArrays[KGPRSOUT][1] )
       
   723                 {
       
   724                 bearer = EApBearerTypeGPRS;
       
   725                 for (j=0; j<iapArrays[KGPRSOUT][1]->Count(); j++)
       
   726                     {
       
   727                     iappos = GetIapPos( ispArray[KGPRSOUT],
       
   728                                         iapArrays[KGPRSOUT][1]->At( j ) );
       
   729                     if ( iappos != KErrNotFound )
       
   730                         { // GprsIn, Isp, Bearer...
       
   731                         // create temp. item WITH IAP ID, Bearer type
       
   732                         item = CApListItem::NewLC
       
   733                             (
       
   734                             (TCommsDbIspType)
       
   735                                 ispArray[KGPRSOUT]->At( iappos )[KISPTYPE],
       
   736                             iapArrays[KGPRSOUT][0]->At( j ),
       
   737                             KEmpty,
       
   738                             bearer
       
   739                             );
       
   740                         tmpApList->AppendL( item );
       
   741                         CleanupStack::Pop( item ); // item owned by list !
       
   742                         }
       
   743                     }
       
   744                 }
       
   745 
       
   746 
       
   747             // check all iap/cdma/ServiceID if it is in ispinbearerarray[2]
       
   748             if ( iapArrays[KCDMA_ISP][1] )  // NULL if iExt->iCdma==EFalse.
       
   749                 {
       
   750                 bearer = EApBearerTypeCDMA;
       
   751                 for (j=0; j<iapArrays[KCDMA_ISP][1]->Count(); j++)
       
   752                     {
       
   753                     iappos = GetIapPos( ispArray[KCDMA_ISP],
       
   754                                         iapArrays[KCDMA_ISP][1]->At( j ) );
       
   755                     if ( iappos != KErrNotFound )
       
   756                         { // Cdma, Isp, Bearer...
       
   757                         // create temp. item WITH IAP ID, Bearer type
       
   758                         item = CApListItem::NewLC
       
   759                             (
       
   760                             (TCommsDbIspType)
       
   761                                 ispArray[KCDMA_ISP]->At( iappos )[KISPTYPE],
       
   762                             iapArrays[KCDMA_ISP][0]->At( j ),
       
   763                             KEmpty,
       
   764                             bearer
       
   765                             );
       
   766                         tmpApList->AppendL( item );
       
   767                         CleanupStack::Pop( item ); // item owned by list !
       
   768                         }
       
   769                     }
       
   770                 }
       
   771 
       
   772 
       
   773             // Now we have the temporary list filled with
       
   774             // IAP UID, bearer type, ISP type,
       
   775             // So compare it to WAP part and create the REAL list...
       
   776             TInt pos( KErrNotFound );
       
   777             TInt itempos( KErrNotFound );
       
   778             TBool protsupported = FeatureManager::FeatureSupported(
       
   779                                          KFeatureIdSettingsProtection );
       
   780             for (i=0; i< wapapid->Count(); i++)
       
   781                 { // as wapapid is sorted, resulting list will be sorted, too !
       
   782                 // is it in IP bearer ?
       
   783                 if ( IsInArray( ipapid, wapapid->At( i ) ) )
       
   784                     {
       
   785                     // now need to get bearer type & isp type
       
   786                     //
       
   787                     pos = PosInArray(ipapid, wapapid->At( i ) );
       
   788                     if (pos!= KErrNotFound )
       
   789                         { // now we have the index in the
       
   790                         // ipiapid as they are synchronized...
       
   791                         // iapUid = ipiapid[ pos ];
       
   792                         // now have to find a CApListItem in tmpApList
       
   793                         itempos = GetItemPos( tmpApList,
       
   794                                               ipiapid->At( pos ) );
       
   795                         if (itempos != KErrNotFound )
       
   796                             {
       
   797                             TBool prot(EFalse);
       
   798                             if (protsupported)
       
   799                                 {
       
   800                                 prot = protflags->At( i );
       
   801                                 }
       
   802                             item = CApListItem::NewLC
       
   803                                 (
       
   804                                 (TCommsDbIspType)
       
   805                                     tmpApList->At( itempos )->Type(),
       
   806                                 wapapid->At( i ),
       
   807                                 *wapapname->At( i ),
       
   808                                 tmpApList->At( itempos )->BearerType(),
       
   809                                 *wapstartpage->At( i ),
       
   810                                 prot );
       
   811                                 
       
   812                             iApList->AppendL( item );
       
   813                             CleanupStack::Pop( item ); // item owned by aList !
       
   814                             }
       
   815                         }
       
   816                     }
       
   817                 }
       
   818 
       
   819             #ifdef __TEST_LAN_BEARER
       
   820                 // enable LAN:
       
   821                 // ADD THEM AFTER NORMAL QUERYING...
       
   822                 if ( ( iBearer & EApBearerTypeLAN ) 
       
   823                     || ( iBearer & EApBearerTypeLANModem ) )
       
   824                     {
       
   825                     AddLanL( EFalse );
       
   826                     }
       
   827             #else
       
   828                 // enable LAN:
       
   829                 // ADD THEM AFTER NORMAL QUERYING...
       
   830                 if ( iBearer & EApBearerTypeLANModem ) 
       
   831                     {
       
   832                     AddLanL( EFalse );
       
   833                     }            
       
   834             #endif // __TEST_LAN_BEARER
       
   835                 if ( iBearer & EApBearerTypeWLAN ) 
       
   836                     {
       
   837                     if ( iExt->iWlanSupported )
       
   838                         {
       
   839                         // enable WLAN:
       
   840                         // ADD THEM AFTER NORMAL QUERYING...
       
   841                         AddLanL( ETrue );
       
   842                         }
       
   843                     }
       
   844                 
       
   845             // now it has only elements which are OK.
       
   846             // from ALL CSD/GPRS/CDMA tables, still in sorted order...
       
   847             // now it is time to check VPN related stuff, if any
       
   848                 if ( ( iExt->iVpnFilterType == EVpnFilterVpnOnly ) ||
       
   849                     ( iExt->iVpnFilterType == EVpnFilterBoth ) )
       
   850                     { // Add VPN access points if needed
       
   851                     // Add ALL VPN access points if needed as requested by
       
   852                     // Nokia, thus incomplete access points to be listed.
       
   853                     TUint32 wapid( 0 );
       
   854                     TInt count = vpnArray->Count();
       
   855                     
       
   856                     CApUtils* util = CApUtils::NewLC( *iDb );
       
   857                     for ( i = 0; i < count; i++ )
       
   858                         {
       
   859                         // get home wap id first
       
   860                         pos = PosInArray( ipiapid, 
       
   861                                           vpnArray->At( i ).iHomeIapId );
       
   862                         TInt foundpos( KErrNotFound );
       
   863                         if ( pos!= KErrNotFound )
       
   864                             { // now we have the index in the
       
   865                             // ipiapid and as they are synchronized...
       
   866                             wapid = ipapid->At( pos );
       
   867                             // now check if we do have it in array...
       
   868                             TInt jcount = iApList->Count();
       
   869                             for ( j = 0; j < jcount; j++ )
       
   870                                 {
       
   871                                 if ( iApList->At( j )->Uid() == wapid )
       
   872                                     {
       
   873                                     foundpos = j;
       
   874                                     break;
       
   875                                     }
       
   876                                 }
       
   877                             }
       
   878                         // should add VPN
       
   879                         // check if VPN-table COMMDB_ID is 
       
   880                         // in iapArrays[VPN][1]
       
   881                         pos = PosInArray( 
       
   882                                 iapArrays[KVPN][1], 
       
   883                                 vpnArray->At( i ).iVpnIapId );
       
   884                         if ( pos != KErrNotFound )
       
   885                             { // now get VPN IAP ID
       
   886                             TUint32 tempvpniapid = 
       
   887                                 iapArrays[KVPN][0]->At( pos );
       
   888                             TUint32 tempvpnwapid ( 0 );
       
   889                             TRAP( err, tempvpnwapid = 
       
   890                                     util->WapIdFromIapIdL( 
       
   891                                            tempvpniapid ) );
       
   892 
       
   893                             if ( err == KErrNone )
       
   894                                 {
       
   895                                 if ( foundpos != KErrNotFound )
       
   896                                     {
       
   897                                     // if not found, it is either an unknown 
       
   898                                     // bearer type, for which we can nto show
       
   899                                     // icon and UI at all, or it does not 
       
   900                                     // fulfill the filtering criteria, so we 
       
   901                                     // ignore them.
       
   902                                     item = CApListItem::NewLC
       
   903                                         (
       
   904                                         iApList->At( foundpos )->Type(),
       
   905                                         tempvpnwapid,
       
   906                                         *vpnArray->At( i ).iName,
       
   907                                         iApList->At( foundpos )
       
   908                                                 ->BearerType()
       
   909                                         );
       
   910                                     item->SetVpnFlag( ETrue );
       
   911                                     iApList->AppendL( item );
       
   912                                     // item owned by aList !
       
   913                                     CleanupStack::Pop( item ); 
       
   914                                     }
       
   915                                 }
       
   916                             }
       
   917                         }
       
   918                     CleanupStack::PopAndDestroy( util );
       
   919                     }
       
   920 
       
   921                 if ( iExt->iVpnFilterType == EVpnFilterVpnOnly )
       
   922                     { // remove non-vpn access points if needed
       
   923                     TInt count = iApList->Count();
       
   924                     for ( i = 0; i < count; i++ )
       
   925                         {
       
   926                         if ( !iApList->At( i )->IsVpnAp() )
       
   927                             {
       
   928                             delete iApList->At( i );
       
   929                             iApList->Delete( i );
       
   930                             count--;
       
   931                             i--; // 'cause it is cycled...
       
   932                             }
       
   933                         }
       
   934                     }
       
   935 
       
   936 
       
   937 /*
       
   938 #ifdef __WINS__
       
   939                 //=============================================================
       
   940                 // Support for ethernet in emulator, change 1/2
       
   941                 //
       
   942 
       
   943                 iapt = OpenViewMatchingTextL( TPtrC(IAP),
       
   944                     TPtrC(IAP_SERVICE_TYPE),
       
   945                     TPtrC(LAN_SERVICE) );
       
   946                 CleanupStack::PushL( iapt );
       
   947                 
       
   948                 
       
   949                 TBuf<40> name;
       
   950                 TUint32 id;
       
   951                 TInt err = iapt->GotoFirstRecord();
       
   952                 TInt err2;
       
   953                 CCommsDbTableView* tmpView = NULL;
       
   954 
       
   955                 while(err == KErrNone)
       
   956                     {
       
   957                     iapt->ReadTextL(TPtrC(COMMDB_NAME), name);
       
   958                     iapt->ReadUintL(TPtrC(COMMDB_ID), id);
       
   959                     
       
   960                     tmpView = iDb->OpenViewMatchingUintLC(
       
   961                                     TPtrC(WAP_IP_BEARER), TPtrC(WAP_IAP), id);
       
   962                     err2 = tmpView->GotoFirstRecord();
       
   963                     if(err2 == KErrNone)
       
   964                         {
       
   965                         tmpView->ReadUintL(TPtrC(WAP_ACCESS_POINT_ID), id);
       
   966                         CleanupStack::PopAndDestroy( tmpView );
       
   967 
       
   968                         tmpView = iDb->OpenViewMatchingUintLC(
       
   969                                 TPtrC(WAP_ACCESS_POINT), TPtrC(COMMDB_ID), id);
       
   970                         err2 = tmpView->GotoFirstRecord();
       
   971                         if ( err2 == KErrNone )
       
   972                             {
       
   973                             item = CApListItem::NewLC
       
   974                                 (
       
   975                                 EIspTypeInternetAndWAP,
       
   976                                 id,
       
   977                                 name,
       
   978                                 EApBearerTypeGPRS
       
   979                                 );
       
   980                             iApList->AppendL( item );
       
   981                     
       
   982                             CleanupStack::Pop( item );
       
   983                             }                        
       
   984                         }
       
   985 
       
   986                     CleanupStack::PopAndDestroy( tmpView );
       
   987 
       
   988                     err = iapt->GotoNextRecord();
       
   989                     }
       
   990                 
       
   991                 
       
   992                 CleanupStack::PopAndDestroy( iapt ); // iapt;
       
   993                 iapt = NULL;
       
   994                 
       
   995                 // End of change 1/2
       
   996                 //=============================================================
       
   997                 
       
   998 #endif // __WINS__
       
   999 */                
       
  1000                 
       
  1001                 
       
  1002                 iCount = iApList->Count();
       
  1003                 
       
  1004             CleanupStack::PopAndDestroy( tmpApList ); // tmpApList
       
  1005             
       
  1006             if ( vpnArray )
       
  1007                 {	                
       
  1008                 CleanupStack::PopAndDestroy( vpnArray->Count() ); 
       
  1009                 CleanupStack::PopAndDestroy( vpnArray );                 
       
  1010                 }
       
  1011             if ( isptables[KVPN] )
       
  1012                 {	                
       
  1013                 CleanupStack::PopAndDestroy( isptables[KVPN] ); 
       
  1014                 }
       
  1015 
       
  1016             CleanupStack::PopAndDestroy( 10, iapArrays[0][0] ); // iap arrays
       
  1017             
       
  1018             CleanupStack::PopAndDestroy( 5, ispArray[0] ); // isp arrays
       
  1019 
       
  1020             CleanupStack::Pop( 2, ipapid ); // ipiapid, ipapid
       
  1021             CleanupStack::Pop( protflags ); // protflags
       
  1022             delete protflags;
       
  1023             delete ipiapid;
       
  1024             delete ipapid;
       
  1025 
       
  1026 // Note: SMS bearer had been dropped.
       
  1027             CleanupStack::PopAndDestroy( wapstartpage->Count() );//wapstartpage
       
  1028             CleanupStack::PopAndDestroy( wapstartpage ); // wapstartpage
       
  1029             CleanupStack::PopAndDestroy( wapapname->Count() ); // wapapname
       
  1030             CleanupStack::PopAndDestroy( wapapname ); // wapapname
       
  1031             CleanupStack::Pop(); // wapapid
       
  1032             delete wapapid;
       
  1033 
       
  1034             if ( isptables[KCDMA_ISP] )
       
  1035                 {
       
  1036                 CleanupStack::PopAndDestroy( isptables[KCDMA_ISP] );
       
  1037                 }
       
  1038 
       
  1039             if ( isptables[KGPRSOUT] )
       
  1040                 {
       
  1041                 CleanupStack::PopAndDestroy( isptables[KGPRSOUT] );
       
  1042                 }
       
  1043 
       
  1044             if ( isptables[KGPRSIN] )
       
  1045                 {
       
  1046                 CleanupStack::PopAndDestroy( isptables[KGPRSIN] );
       
  1047                 }
       
  1048 
       
  1049             if ( isptables[KDIALOUT] )
       
  1050                 {
       
  1051                 CleanupStack::PopAndDestroy( isptables[KDIALOUT] );
       
  1052                 }
       
  1053 
       
  1054             if ( ipbearert )
       
  1055                 {
       
  1056                 CleanupStack::PopAndDestroy( ipbearert );
       
  1057                 }
       
  1058             }
       
  1059         else
       
  1060             {
       
  1061             if ( err != KErrNotFound )
       
  1062                 {
       
  1063                 User::LeaveIfError( err );
       
  1064                 }
       
  1065             }
       
  1066         }
       
  1067     else
       
  1068         {
       
  1069         if ( err != KErrNotFound )
       
  1070             {
       
  1071             User::Leave( err );
       
  1072             }
       
  1073         }
       
  1074     CleanupStack::PopAndDestroy( wapt );  // wapt
       
  1075     iExt->iMaxIndex = iCount-1;
       
  1076     if ( OwnTransaction )
       
  1077         {
       
  1078         ApCommons::RollbackTransactionOnLeave( iDb );
       
  1079         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
  1080         }
       
  1081     CLOG( ( ESelect, 1, _L( "<- CApSelect::DoUpdateL" ) ) );
       
  1082 
       
  1083     return err;
       
  1084     }
       
  1085 
       
  1086 
       
  1087 
       
  1088 
       
  1089 
       
  1090 // ---------------------------------------------------------
       
  1091 // CApSelect::GetFilteredSortedWapTableViewLC
       
  1092 // ---------------------------------------------------------
       
  1093 //
       
  1094 CCommsDbTableView* CApSelect::GetFilteredSortedWapTableViewLC()
       
  1095     {
       
  1096     CLOG( ( ESelect, 0, 
       
  1097         _L( "-> CApSelect::GetFilteredSortedWapTableViewLC" ) ) );
       
  1098 
       
  1099     CCommsDbTableView* wapt = NULL;
       
  1100     // Select * from WAP Access Point Table Where
       
  1101     // WAP_CURRENT_BEARER=WAP_IP_BEARER
       
  1102     if ( ( iBearer & EApBearerTypeCSD ) ||
       
  1103          ( iBearer & EApBearerTypeHSCSD ) ||
       
  1104          ( iBearer & EApBearerTypeGPRS ) ||
       
  1105          ( iExt->iCdma && ( iBearer & EApBearerTypeCDMA ) ) )
       
  1106         {
       
  1107         wapt = iDb->OpenViewMatchingTextLC( TPtrC(WAP_ACCESS_POINT), 
       
  1108                                             TPtrC(WAP_CURRENT_BEARER), 
       
  1109                                             TPtrC(WAP_IP_BEARER));
       
  1110         }
       
  1111     else
       
  1112         {
       
  1113         wapt = iDb->OpenTableLC( TPtrC(WAP_ACCESS_POINT) );
       
  1114         }
       
  1115     
       
  1116     TInt err;
       
  1117     err = wapt->GotoFirstRecord();
       
  1118     if ( err != KErrNotFound )
       
  1119         {
       
  1120         User::LeaveIfError( err );
       
  1121         }
       
  1122 
       
  1123     if ( err != KErrNotFound )
       
  1124         {
       
  1125         // here may come additional AND-ed parts
       
  1126         if ( ( iIsp & KEApIspTypeWAPMandatory ) ||
       
  1127              ( iIsp & KEApIspTypeMMSMandatory ) )
       
  1128             { // add AND ( Hasmandatory..)
       
  1129             if ( ( iBearer & EApBearerTypeCSD ) ||
       
  1130                  ( iBearer & EApBearerTypeHSCSD ) ||
       
  1131                  ( iBearer & EApBearerTypeGPRS ) ||
       
  1132                  ( iExt->iCdma && ( iBearer & EApBearerTypeCDMA ) ) )
       
  1133                 { // Needs IP bearer
       
  1134                 // ( WAP_CURRENT_BEARER = WAP_IP_BEARER AND
       
  1135                 //      WAP_START_PAGE != ""
       
  1136                 //      AND WAP_START_PAGE != "http://"
       
  1137                 // Filter out unneded records
       
  1138                 HBufC* buf;
       
  1139                 do
       
  1140                     {
       
  1141                     // Add test cases covering this route
       
  1142                     buf = wapt->ReadLongTextLC( TPtrC(WAP_START_PAGE) );
       
  1143                     if ( ( buf->Compare( KEmpty ) == 0 ) 
       
  1144                        || ( buf->Compare( KInvStartPage ) == 0 ) )
       
  1145                         {
       
  1146                         err = wapt->DeleteRecord();
       
  1147                         }
       
  1148                     CleanupStack::PopAndDestroy( buf );
       
  1149                     err = wapt->GotoNextRecord();
       
  1150                     } 
       
  1151                     while ( !err );
       
  1152                 }
       
  1153             }
       
  1154         }
       
  1155     CLOG( ( ESelect, 1, 
       
  1156         _L( "<- CApSelect::GetFilteredSortedWapTableViewLC" ) ) );
       
  1157 
       
  1158     return wapt;
       
  1159     }
       
  1160 
       
  1161 
       
  1162 
       
  1163 
       
  1164 
       
  1165 // ---------------------------------------------------------
       
  1166 // CApSelect::GetFilteredSortedIpBearerTableViewLC()
       
  1167 // ---------------------------------------------------------
       
  1168 //
       
  1169 CCommsDbTableView* CApSelect::GetFilteredSortedIpBearerTableViewLC()
       
  1170     {
       
  1171     CLOG( ( ESelect, 0, 
       
  1172         _L( "-> CApSelect::GetFilteredSortedIpBearerTableViewLC" ) ) );
       
  1173 
       
  1174     CCommsDbTableView* table = NULL;
       
  1175 
       
  1176     table = iDb->OpenTableLC( TPtrC(WAP_IP_BEARER) );
       
  1177     TInt err;
       
  1178     err = table->GotoFirstRecord();
       
  1179 
       
  1180     if ( ( iBearer & EApBearerTypeCSD ) ||
       
  1181          ( iBearer & EApBearerTypeHSCSD ) ||
       
  1182          ( iBearer & EApBearerTypeGPRS ) ||
       
  1183          ( iExt->iCdma && ( iBearer & EApBearerTypeCDMA ) ) )
       
  1184         { 
       
  1185         // needs ipbearer table
       
  1186         // only filtering we can do is about Mandatory
       
  1187         // because Isptype & Bearertype are up to
       
  1188         // ISP & GPRS tables...
       
  1189         if ( iIsp & KEApIspTypeWAPMandatory )
       
  1190             { // Hasmandatory..
       
  1191             // SELECT * from WAP_IP_BEARER WHERE
       
  1192             // WAP_GATEWAY_ADDRESS <> ''
       
  1193             //      AND WAP_GATEWAY_ADDRESS != "0.0.0.0" )
       
  1194             // AND HIDDEN...
       
  1195 
       
  1196             if ( err != KErrNotFound )
       
  1197                 {
       
  1198                 User::LeaveIfError( err );
       
  1199 
       
  1200                 HBufC* buf;
       
  1201                 do
       
  1202                     {
       
  1203                     buf = table->ReadLongTextLC( TPtrC(WAP_GATEWAY_ADDRESS) );
       
  1204                     if ( ( buf->Compare( KEmpty ) == 0 ) 
       
  1205                        || ( buf->Compare( KDynIpAddress ) == 0 ) )
       
  1206                         {
       
  1207                         err = table->DeleteRecord();
       
  1208                         }
       
  1209                     CleanupStack::PopAndDestroy( buf );
       
  1210                     err = table->GotoNextRecord();
       
  1211                     } while ( !err );
       
  1212                 }
       
  1213             }
       
  1214         }
       
  1215 
       
  1216     CLOG( ( ESelect, 1, 
       
  1217         _L( "<- CApSelect::GetFilteredSortedIpBearerTableViewLC" ) ) );
       
  1218 
       
  1219     return table;
       
  1220     }
       
  1221 
       
  1222 
       
  1223 
       
  1224 // ---------------------------------------------------------
       
  1225 // CApSelect::GetFilteredSortedIspOutTableViewLC()
       
  1226 // ---------------------------------------------------------
       
  1227 //
       
  1228 CCommsDbTableView* CApSelect::GetFilteredSortedIspOutTableViewLC()
       
  1229     {
       
  1230     CLOG( ( ESelect, 0, 
       
  1231         _L( "-> CApSelect::GetFilteredSortedIspOutTableViewLC" ) ) );
       
  1232     
       
  1233     CCommsDbTableView* table = NULL;
       
  1234     // ISP-type & bearer type...
       
  1235     if ( ( iBearer & EApBearerTypeCSD ) ||
       
  1236          ( iBearer & EApBearerTypeHSCSD ) )
       
  1237         {
       
  1238         // only needed if CSD or HSCSD
       
  1239         if ( ( iBearer & EApBearerTypeCSD ) &&
       
  1240              (!( iBearer & EApBearerTypeHSCSD )) )
       
  1241             { // needs only CSD
       
  1242             // WHERE ISP_BEARER_TYPE = EBearerTypeCSD
       
  1243             table = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_OUT_ISP),
       
  1244                                                  TPtrC(ISP_BEARER_TYPE),
       
  1245                                                  EBearerTypeCSD
       
  1246                                                  );
       
  1247             }
       
  1248         else
       
  1249             {
       
  1250             if ( ( iBearer & EApBearerTypeHSCSD ) &&
       
  1251                  (!( iBearer & EApBearerTypeCSD )) )
       
  1252                 { // needs only HSCSD
       
  1253                 // WHERE ISP_BEARER_TYPE = EBearerTypeHSCSD
       
  1254                 table = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_OUT_ISP),
       
  1255                                                      TPtrC(ISP_BEARER_TYPE),
       
  1256                                                      EBearerTypeHSCSD
       
  1257                                                      );
       
  1258                 }
       
  1259             else
       
  1260                 {
       
  1261                 table = iDb->OpenTableLC( TPtrC(DIAL_OUT_ISP) );
       
  1262                 }
       
  1263             }
       
  1264         TInt err;
       
  1265         err = table->GotoFirstRecord();
       
  1266         
       
  1267         if ( err != KErrNotFound )
       
  1268             {
       
  1269             User::LeaveIfError( err );
       
  1270             // now add isp-type filtering
       
  1271             // if Added = ETrue : AND ( ), else : WHERE
       
  1272             // KEApIspTypeInternetOnly,
       
  1273             // KEApIspTypeWAPOnly,
       
  1274             // KEApIspTypeInternetAndWAP,
       
  1275             // KEApIspTypeWAPMandatory, KEApIspTypeAll
       
  1276             TUint32 isp( 0 );
       
  1277             do
       
  1278                 {
       
  1279                 table->ReadUintL( TPtrC(ISP_TYPE), isp );
       
  1280                 if ( ( iIsp & KEApIspTypeInternetOnly ) 
       
  1281                      && ( !( iIsp & KEApIspTypeAll ) )
       
  1282                      )
       
  1283                     {// ( ( ISP_TYPE == EIspTypeInternetOnly )
       
  1284                     if ( isp != EIspTypeInternetOnly )
       
  1285                         {
       
  1286                         err = table->DeleteRecord();
       
  1287                         }
       
  1288                     }
       
  1289                 if ( ( iIsp & KEApIspTypeWAPOnly ) 
       
  1290                      && ( !( iIsp & KEApIspTypeAll ) )
       
  1291                      )
       
  1292                     {
       
  1293                     if ( isp != EIspTypeWAPOnly )
       
  1294                         {
       
  1295                         err = table->DeleteRecord();
       
  1296                         }
       
  1297                     }
       
  1298                 if ( ( iIsp & KEApIspTypeInternetAndWAP ) 
       
  1299                      && ( !( iIsp & KEApIspTypeAll ) )
       
  1300                      )
       
  1301                     {
       
  1302                     if ( isp != EIspTypeInternetAndWAP )
       
  1303                         {
       
  1304                         err = table->DeleteRecord();
       
  1305                         }
       
  1306                     }
       
  1307                 err = table->GotoNextRecord();
       
  1308                 } while ( !err );
       
  1309             }
       
  1310         }
       
  1311 
       
  1312     CLOG( ( ESelect, 1, 
       
  1313         _L( "<- CApSelect::GetFilteredSortedIspOutTableViewLC" ) ) );
       
  1314 
       
  1315     return table;
       
  1316     }
       
  1317 
       
  1318 
       
  1319 
       
  1320 // ---------------------------------------------------------
       
  1321 // CApSelect::GetFilteredSortedGprsTableViewLC()
       
  1322 // ---------------------------------------------------------
       
  1323 //
       
  1324 CCommsDbTableView* CApSelect::GetFilteredSortedGprsTableViewLC( TBool aIn )
       
  1325     {
       
  1326     CLOG( ( ESelect, 0, 
       
  1327         _L( "-> CApSelect::GetFilteredSortedGprsTableViewLC" ) ) );
       
  1328 
       
  1329     CCommsDbTableView* table = NULL;
       
  1330     // ISP-type & bearer type...
       
  1331     if ( iBearer & EApBearerTypeGPRS )
       
  1332         {
       
  1333         // as all other criteria has more than 2 possible values
       
  1334         // and all their combinations should be taken into account,
       
  1335         // I ask the whole table and then narrow it down
       
  1336         // myself with removing the unneded records temporarily
       
  1337         if ( aIn )
       
  1338             {
       
  1339             table = iDb->OpenTableLC( TPtrC( INCOMING_WCDMA ) );
       
  1340             }
       
  1341         else
       
  1342             {
       
  1343             table = iDb->OpenTableLC( TPtrC( OUTGOING_WCDMA ) );
       
  1344             }
       
  1345         TInt err;
       
  1346         err = table->GotoFirstRecord();
       
  1347         
       
  1348         if ( err != KErrNotFound )
       
  1349             {
       
  1350             User::LeaveIfError( err );
       
  1351             // only needed if GPRS
       
  1352             // now add isp-type filtering
       
  1353             // KEApIspTypeInternetOnly,
       
  1354             // KEApIspTypeWAPOnly,
       
  1355             // KEApIspTypeInternetAndWAP,
       
  1356             // KEApIspTypeWAPMandatory, KEApIspTypeAll
       
  1357             TUint32 isp( 0 );
       
  1358             TUint32 pdptype( 0 );
       
  1359             TBool deleted(EFalse);
       
  1360             do
       
  1361                 {
       
  1362                 deleted = EFalse;
       
  1363                 // first check if it fits our isp type criteria
       
  1364                 TRAPD( res, table->ReadUintL( TPtrC(GPRS_AP_TYPE), isp ) );
       
  1365                 if ( res != KErrUnknown )
       
  1366                     {
       
  1367                     if ( ( iIsp & KEApIspTypeInternetOnly ) 
       
  1368                          && ( !( iIsp & KEApIspTypeAll ) )
       
  1369                          )
       
  1370                         {// ( ( ISP_TYPE == EIspTypeInternetOnly )
       
  1371                         if ( isp != EIspTypeInternetOnly )
       
  1372                             {
       
  1373                             err = table->DeleteRecord();
       
  1374                             deleted = ETrue;
       
  1375                             }
       
  1376                         }
       
  1377                     if ( ( iIsp & KEApIspTypeWAPOnly ) 
       
  1378                          && ( !( iIsp & KEApIspTypeAll ) )
       
  1379                          )
       
  1380                         {
       
  1381                         if ( isp != EIspTypeWAPOnly )
       
  1382                             {
       
  1383                             err = table->DeleteRecord();
       
  1384                             deleted = ETrue;
       
  1385                             }
       
  1386                         }
       
  1387                     if ( ( iIsp & KEApIspTypeInternetAndWAP ) 
       
  1388                          && ( !( iIsp & KEApIspTypeAll ) )
       
  1389                          )
       
  1390                         {
       
  1391                         if ( isp != EIspTypeInternetAndWAP )
       
  1392                             {
       
  1393                             err = table->DeleteRecord();
       
  1394                             deleted = ETrue;
       
  1395                             }
       
  1396                         }
       
  1397                     }
       
  1398                 // now check if it fits IPv4 or IPv6 criteria
       
  1399                 // Add IPv4 or IPv6 query ONLY if it is supported!!!
       
  1400                 if ( ( !deleted ) && ( iExt->iIsIpv6Supported ) )
       
  1401                     {
       
  1402                     // if ONLY IPv4 is requested, 
       
  1403                     // filter out where PDP_type IS IPv6
       
  1404                     // if both is requested, do nothing
       
  1405                     // if IPv6 only is requested, filter IN 
       
  1406                     // where PDP_type IS IPv6
       
  1407                     if ( ( iExt->iReqIpvType == EIPv4 ) ||
       
  1408                          ( iExt->iReqIpvType == EIPv6 ) )
       
  1409                         { // not both, needs filtering
       
  1410                         table->ReadUintL( TPtrC(GPRS_PDP_TYPE), pdptype );
       
  1411                         if ( ( iExt->iReqIpvType == EIPv4 ) 
       
  1412                              && ( pdptype == RPacketContext::EPdpTypeIPv6 )
       
  1413                              )
       
  1414                             {
       
  1415                             err = table->DeleteRecord();
       
  1416                             deleted = ETrue;
       
  1417                             }
       
  1418                         if ( ( iExt->iReqIpvType == EIPv6 ) 
       
  1419                              && ( pdptype == RPacketContext::EPdpTypeIPv4 )
       
  1420                              )
       
  1421                             {
       
  1422                             err = table->DeleteRecord();
       
  1423                             deleted = ETrue;
       
  1424                             }
       
  1425                         }
       
  1426                     }
       
  1427                 err = table->GotoNextRecord();
       
  1428                 } while ( !err );
       
  1429             }
       
  1430         }
       
  1431     CLOG( ( ESelect, 1, 
       
  1432         _L( "<- CApSelect::GetFilteredSortedGprsTableViewLC" ) ) );
       
  1433 
       
  1434     return table;
       
  1435     }
       
  1436 
       
  1437 
       
  1438 
       
  1439 // ---------------------------------------------------------
       
  1440 // CApSelect::GetUintValuesL
       
  1441 // ---------------------------------------------------------
       
  1442 //
       
  1443 void CApSelect::GetUintValuesL( CCommsDbTableView* aTable,
       
  1444                                 const TDesC& aField,
       
  1445                                 CArrayFixFlat<TUint32>& aArray )
       
  1446     {
       
  1447     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetUintValuesL" ) ) );
       
  1448 
       
  1449     if ( aTable )
       
  1450         {
       
  1451         TInt err = aTable->GotoFirstRecord();
       
  1452         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  1453             {
       
  1454             User::Leave( err );
       
  1455             }
       
  1456         if ( err != KErrNotFound )
       
  1457             {
       
  1458             TUint32 temp( 0 );
       
  1459             TBool goon( ETrue );
       
  1460             do
       
  1461                 {
       
  1462                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), temp );
       
  1463                 if ( ( err == KErrNone ) && ( temp ) )
       
  1464                     {
       
  1465                     // Here I need to TRAP to be able to use 'old'
       
  1466                     // database which has no such field !
       
  1467                     // Also assigns a 'default' for it in that case
       
  1468                     TRAP(err, ApCommons::ReadUintL( aTable, aField, temp ) );
       
  1469                     aArray.AppendL( temp );
       
  1470                     }
       
  1471                 err = aTable->GotoNextRecord();
       
  1472                 if ( err == KErrNotFound )
       
  1473                     {
       
  1474                     goon = EFalse;
       
  1475                     }
       
  1476                 else
       
  1477                     {
       
  1478                     User::LeaveIfError( err );
       
  1479                     }
       
  1480                 }
       
  1481                 while ( goon );
       
  1482             }
       
  1483         }
       
  1484     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetUintValuesL" ) ) );
       
  1485 
       
  1486     }
       
  1487 
       
  1488 
       
  1489 
       
  1490 // ---------------------------------------------------------
       
  1491 // CApSelect::GetProtValuesL
       
  1492 // ---------------------------------------------------------
       
  1493 //
       
  1494 void CApSelect::GetProtValuesL( CCommsDbTableView* aTable,
       
  1495                                 CArrayFixFlat<TUint32>& aArray )
       
  1496     {    
       
  1497     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetProtValuesL" ) ) );
       
  1498 
       
  1499     CCommsDbProtectTableView* view =
       
  1500         (CCommsDbProtectTableView*)aTable;
       
  1501     if ( aTable )
       
  1502         {
       
  1503         TInt err = aTable->GotoFirstRecord();
       
  1504         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  1505             {
       
  1506             User::Leave( err );
       
  1507             }
       
  1508         if ( err != KErrNotFound )
       
  1509             {
       
  1510             TBool goon( ETrue );
       
  1511             TInt prot( EFalse );
       
  1512             do
       
  1513                 {
       
  1514                 err = view->GetRecordAccess( prot );
       
  1515                 if ( ( err == KErrNone ) )
       
  1516                     {
       
  1517                     aArray.AppendL( prot );
       
  1518                     }
       
  1519                 err = aTable->GotoNextRecord();
       
  1520                 if ( err == KErrNotFound )
       
  1521                     {
       
  1522                     goon = EFalse;
       
  1523                     }
       
  1524                 else
       
  1525                     {
       
  1526                     User::LeaveIfError( err );
       
  1527                     }
       
  1528                 }
       
  1529                 while ( goon );
       
  1530             }
       
  1531         }
       
  1532     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetProtValuesL" ) ) );
       
  1533 
       
  1534     }
       
  1535 
       
  1536 
       
  1537 
       
  1538 
       
  1539 // ---------------------------------------------------------
       
  1540 // CApSelect::GetTextValuesL
       
  1541 // ---------------------------------------------------------
       
  1542 //
       
  1543 void CApSelect::GetTextValuesL( CCommsDbTableView* aTable,
       
  1544                                 const TDesC& aField,
       
  1545                                 CArrayPtrFlat<HBufC>& aArray )
       
  1546     {
       
  1547     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetTextValuesL" ) ) );
       
  1548 
       
  1549     if ( aTable )
       
  1550         {
       
  1551         TInt err = aTable->GotoFirstRecord();
       
  1552         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  1553             {
       
  1554             User::Leave( err );
       
  1555             }
       
  1556         if ( err != KErrNotFound )
       
  1557             {
       
  1558             TBool goon( ETrue );
       
  1559             TInt l;
       
  1560             TUint32 temp( 0 );
       
  1561             HBufC* tmp = NULL;
       
  1562             do
       
  1563                 {
       
  1564                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), temp );
       
  1565                 if ( ( err == KErrNone ) && ( temp ) )
       
  1566                     {
       
  1567                     aTable->ReadColumnLengthL( aField, l );
       
  1568                     tmp = HBufC::NewLC( l );
       
  1569                     TPtr tmpptr( tmp->Des() );
       
  1570                     aTable->ReadTextL( aField, tmpptr );
       
  1571                     aArray.AppendL( tmp );
       
  1572                     }
       
  1573                 err = aTable->GotoNextRecord();
       
  1574                 if ( err == KErrNotFound )
       
  1575                     {
       
  1576                     goon = EFalse;
       
  1577                     }
       
  1578                 else
       
  1579                     {
       
  1580                     User::LeaveIfError( err );
       
  1581                     }
       
  1582                 }
       
  1583                 while ( goon );
       
  1584             }
       
  1585         }
       
  1586     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetTextValuesL" ) ) );
       
  1587 
       
  1588     }
       
  1589 
       
  1590 
       
  1591 
       
  1592 // ---------------------------------------------------------
       
  1593 // CApSelect::GetLongTextValuesL
       
  1594 // ---------------------------------------------------------
       
  1595 //
       
  1596 void CApSelect::GetLongTextValuesL( CCommsDbTableView* aTable,
       
  1597                                     const TDesC& aField,
       
  1598                                     CArrayPtrFlat<HBufC>& aArray )
       
  1599     {
       
  1600     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetLongTextValuesL" ) ) );
       
  1601 
       
  1602     if ( aTable )
       
  1603         {
       
  1604         TInt err = aTable->GotoFirstRecord();
       
  1605         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  1606             {
       
  1607             User::Leave( err );
       
  1608             }
       
  1609         if ( err != KErrNotFound )
       
  1610             {
       
  1611             TBool goon( ETrue );
       
  1612             TInt l;
       
  1613             TUint32 temp( 0 );
       
  1614             HBufC* tmp = NULL;
       
  1615             do
       
  1616                 {
       
  1617                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), temp );
       
  1618                 if ( ( err == KErrNone ) && ( temp ) )
       
  1619                     {
       
  1620                     aTable->ReadColumnLengthL( aField, l );
       
  1621                     tmp = aTable->ReadLongTextLC( aField );
       
  1622                     aArray.AppendL( tmp );
       
  1623                     }
       
  1624                 err = aTable->GotoNextRecord();
       
  1625                 if ( err == KErrNotFound )
       
  1626                     {
       
  1627                     goon = EFalse;
       
  1628                     }
       
  1629                 else
       
  1630                     {
       
  1631                     User::LeaveIfError( err );
       
  1632                     }
       
  1633                 }
       
  1634                 while ( goon );
       
  1635             }
       
  1636         }
       
  1637     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetLongTextValuesL" ) ) );
       
  1638 
       
  1639     }
       
  1640 
       
  1641 
       
  1642 
       
  1643 // ---------------------------------------------------------
       
  1644 // CApSelect::IsInArray
       
  1645 // ---------------------------------------------------------
       
  1646 //
       
  1647 TBool CApSelect::IsInArray( CArrayFixFlat<TUint32>* aArray, TUint32 aValue )
       
  1648     {
       
  1649     CLOG( ( ESelect, 0, _L( "<-> CApSelect::IsInArray" ) ) );
       
  1650 
       
  1651     return ( PosInArray( aArray, aValue ) >= 0);
       
  1652     }
       
  1653 
       
  1654 
       
  1655 
       
  1656 // ---------------------------------------------------------
       
  1657 // CApSelect::PosInArray
       
  1658 // ---------------------------------------------------------
       
  1659 //
       
  1660 TInt CApSelect::PosInArray( CArrayFixFlat<TUint32>* aArray, TUint32 aValue )
       
  1661     {
       
  1662     CLOG( ( ESelect, 0, _L( "-> CApSelect::PosInArray" ) ) );
       
  1663 
       
  1664     TInt retval( KErrNotFound );
       
  1665     if ( aArray )
       
  1666         {
       
  1667         TInt count = aArray->Count();
       
  1668         for( TInt i=0; ( ( i<count) && ( retval == KErrNotFound ) ); i++ )
       
  1669             {
       
  1670             if ( aArray->At( i ) == aValue )
       
  1671                 {
       
  1672                 retval = i;
       
  1673                 }
       
  1674             }
       
  1675         }
       
  1676     CLOG( ( ESelect, 1, _L( "<- CApSelect::PosInArray" ) ) );
       
  1677 
       
  1678     return retval;
       
  1679     }
       
  1680 
       
  1681 
       
  1682 // ---------------------------------------------------------
       
  1683 // CApSelect::GetItemPos
       
  1684 // ---------------------------------------------------------
       
  1685 //
       
  1686 TInt CApSelect::GetItemPos( CApListItemList* aList, TUint32 aId )
       
  1687     {
       
  1688     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetItemPos" ) ) );
       
  1689 
       
  1690     TInt retval( KErrNotFound );
       
  1691     if ( aList )
       
  1692         {
       
  1693         TInt count = aList->Count();
       
  1694         for( TInt i=0; ( ( i<count) && ( retval == KErrNotFound ) ); i++ )
       
  1695             {
       
  1696             if ( aList->At( i )->Uid() == aId )
       
  1697                 {
       
  1698                 retval = i;
       
  1699                 }
       
  1700             }
       
  1701         }
       
  1702     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetItemPos" ) ) );
       
  1703 
       
  1704     return retval;
       
  1705     }
       
  1706 
       
  1707 
       
  1708 
       
  1709 // ---------------------------------------------------------
       
  1710 // CApSelect::OpenViewMatchingTextL
       
  1711 // ---------------------------------------------------------
       
  1712 //
       
  1713 CCommsDbTableView* CApSelect::OpenViewMatchingTextL(
       
  1714                                              const TDesC& aTableName,
       
  1715                                              const TDesC& aColumnToMatch,
       
  1716                                              const TDesC16& aValueToMatch )
       
  1717     {
       
  1718     CLOG( ( ESelect, 0, _L( "-> CApSelect::OpenViewMatchingTextL" ) ) );
       
  1719 
       
  1720     CCommsDbTableView* table = NULL;
       
  1721     TRAPD( err, { // this leaves if the table is empty....
       
  1722                 table = iDb->OpenViewMatchingTextLC( aTableName,
       
  1723                                                      aColumnToMatch,
       
  1724                                                      aValueToMatch );
       
  1725                 CleanupStack::Pop( table ); // table
       
  1726                 }
       
  1727         );
       
  1728     if ( err != KErrNotFound )
       
  1729         {
       
  1730         User::LeaveIfError( err );
       
  1731         }
       
  1732     CLOG( ( ESelect, 1, _L( "<- CApSelect::OpenViewMatchingTextL" ) ) );
       
  1733 
       
  1734     return table;
       
  1735     }
       
  1736 
       
  1737 
       
  1738 
       
  1739 // ---------------------------------------------------------
       
  1740 // CApSelect::GetIspValuesL
       
  1741 // ---------------------------------------------------------
       
  1742 //
       
  1743 void CApSelect::GetIspValuesL( CCommsDbTableView* aTable,
       
  1744                                CArrayFixFlat<TUint32[3]>* aArray,
       
  1745                                const TDesC& aColName )
       
  1746     {
       
  1747     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetIspValuesL" ) ) );
       
  1748 
       
  1749     if ( aTable )
       
  1750         {
       
  1751         TInt err = aTable->GotoFirstRecord();
       
  1752         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  1753             {
       
  1754             User::Leave( err );
       
  1755             }
       
  1756         if ( err != KErrNotFound )
       
  1757             {
       
  1758             TUint32 temp[3];
       
  1759             TBool goon( ETrue );
       
  1760             do
       
  1761                 {
       
  1762                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID),
       
  1763                                              temp[KUID] );
       
  1764                 if ( ( err == KErrNone ) && ( temp[KUID] ) )
       
  1765                     {
       
  1766                     // Here I need to TRAP to be able to use 'old'
       
  1767                     // database which has no such field !
       
  1768                     // Also assigns a 'default' for it in that case
       
  1769                     TRAP( err, ApCommons::ReadUintL
       
  1770                                         (
       
  1771                                         aTable,
       
  1772                                         aColName,
       
  1773                                         temp[KISPTYPE]
       
  1774                                         ) );
       
  1775                     if ( err == KErrNotFound )
       
  1776                         {
       
  1777                         temp[KISPTYPE] = EIspTypeInternetAndWAP;
       
  1778                         }
       
  1779                     else
       
  1780                         {
       
  1781                         User::LeaveIfError( err );
       
  1782                         }
       
  1783                     // if it is CSD/HSCSD, now decide which one
       
  1784                     if( !aColName.Compare( TPtrC(ISP_TYPE) ) )
       
  1785                         {
       
  1786                         err = ApCommons::ReadUintL
       
  1787                                             (
       
  1788                                             aTable,
       
  1789                                             TPtrC(ISP_BEARER_TYPE),
       
  1790                                             temp[KBEARERTYPE]
       
  1791                                             );
       
  1792                         if ( err != KErrNone )
       
  1793                             { // only possible if it is NULL,
       
  1794                             // for other errors, it leaves...
       
  1795                             temp[KBEARERTYPE] = EBearerTypeCSD;
       
  1796                             }
       
  1797                         }
       
  1798                     else
       
  1799                         {
       
  1800                         temp[KBEARERTYPE] = 0;
       
  1801                         }
       
  1802                     aArray->AppendL( temp );
       
  1803                     }
       
  1804                 err = aTable->GotoNextRecord();
       
  1805                 if ( err == KErrNotFound )
       
  1806                     {
       
  1807                     goon = EFalse;
       
  1808                     }
       
  1809                 else
       
  1810                     {
       
  1811                     User::LeaveIfError( err );
       
  1812                     }
       
  1813                 }
       
  1814                 while ( goon );
       
  1815             }
       
  1816         }
       
  1817     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetIspValuesL" ) ) );
       
  1818 
       
  1819     }
       
  1820 
       
  1821 
       
  1822 
       
  1823 
       
  1824 // ---------------------------------------------------------
       
  1825 // CApSelect::GetIapPos
       
  1826 // ---------------------------------------------------------
       
  1827 //
       
  1828 TInt CApSelect::GetIapPos( CArrayFixFlat<TUint32[3]>* aArray, TUint32 aValue )
       
  1829     {
       
  1830     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetIapPos" ) ) );
       
  1831 
       
  1832     TInt retval( KErrNotFound );
       
  1833     if ( aArray )
       
  1834         {
       
  1835         TInt count = aArray->Count();
       
  1836         for( TInt i=0; ( ( i<count) && ( retval == KErrNotFound ) ); i++ )
       
  1837             {
       
  1838             if ( aArray->At( i )[KUID] == aValue )
       
  1839                 {
       
  1840                 retval = i;
       
  1841                 }
       
  1842             }
       
  1843         }
       
  1844     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetIapPos" ) ) );
       
  1845 
       
  1846     return retval;
       
  1847     }
       
  1848 
       
  1849 
       
  1850 
       
  1851 // ---------------------------------------------------------
       
  1852 // CApSelect::SortLocalisedNameL()
       
  1853 // ---------------------------------------------------------
       
  1854 //
       
  1855 void CApSelect::SortLocalisedNameL( TBool aAscending )
       
  1856     {
       
  1857     CLOG( ( ESelect, 0, _L( "-> CApSelect::SortLocalisedNameL" ) ) );
       
  1858 
       
  1859     TApListItemNameKey Key( aAscending );
       
  1860     Key.SetPtr( iApList );
       
  1861     // Sort returns KErrGeneral if stack overflow, otherwise, returns
       
  1862     // KErrNone. So we will Leave only if stack overflow,
       
  1863     // but then that really does not matter...
       
  1864     User::LeaveIfError( iApList->Sort( Key ) );
       
  1865     CLOG( ( ESelect, 1, _L( "<- CApSelect::SortLocalisedNameL" ) ) );
       
  1866 
       
  1867     }
       
  1868 
       
  1869 
       
  1870 
       
  1871 
       
  1872 // ---------------------------------------------------------
       
  1873 // CApSelect::SortUidL()
       
  1874 // ---------------------------------------------------------
       
  1875 //
       
  1876 void CApSelect::SortUidL( TBool aAscending )
       
  1877     {
       
  1878     CLOG( ( ESelect, 0, _L( "-> CApSelect::SortUidL" ) ) );
       
  1879 
       
  1880     TApListItemUidKey Key( aAscending );
       
  1881     Key.SetPtr( iApList );
       
  1882     // Sort returns KErrGeneral if stack overflow, otherwise, returns
       
  1883     // KErrNone. So we will Leave only if stack overflow,
       
  1884     // but then that really does not matter...
       
  1885     User::LeaveIfError( iApList->Sort( Key ) );
       
  1886     CLOG( ( ESelect, 1, _L( "<- CApSelect::SortUidL" ) ) );
       
  1887 
       
  1888     }
       
  1889 
       
  1890 // ---------------------------------------------------------
       
  1891 // CApSelect::NewLC()
       
  1892 // ---------------------------------------------------------
       
  1893 //
       
  1894 EXPORT_C CApSelect* CApSelect::NewLC( CCommsDatabase& aDb,
       
  1895                                       TInt aIspFilter,
       
  1896                                       TInt aBearerFilter,
       
  1897                                       TInt aSortType,
       
  1898                                       TInt aReqIpvType
       
  1899                                       )
       
  1900     {
       
  1901     CLOG( ( ESelect, 0, _L( "-> CApSelect::NewLC" ) ) );
       
  1902 
       
  1903     CApSelect* db = new( ELeave ) CApSelect;
       
  1904     CleanupStack::PushL( db );
       
  1905     db->ConstructL( aDb, aIspFilter, aBearerFilter, 
       
  1906                     aSortType, aReqIpvType, EVpnFilterBoth );
       
  1907 
       
  1908     CLOG( ( ESelect, 1, _L( "<- CApSelect::NewLC" ) ) );
       
  1909     return db;
       
  1910     }
       
  1911 
       
  1912 
       
  1913 
       
  1914 // ---------------------------------------------------------
       
  1915 // CApSelect::ConstructL
       
  1916 // ---------------------------------------------------------
       
  1917 //
       
  1918 EXPORT_C void CApSelect::ConstructL( CCommsDatabase& aDb,
       
  1919                                  TInt aIspFilter,
       
  1920                                  TInt aBearerFilter,
       
  1921                                  TInt aSortType,
       
  1922                                  TInt aReqIpvType )
       
  1923 
       
  1924     {
       
  1925     CLOG( ( ESelect, 0, _L( "-> CApSelect::ConstructL" ) ) );
       
  1926     
       
  1927     ConstructL( aDb, aIspFilter, aBearerFilter, 
       
  1928                 aSortType, aReqIpvType, EVpnFilterBoth );
       
  1929 
       
  1930     CLOG( ( ESelect, 1, _L( "<- CApSelect::ConstructL" ) ) );
       
  1931     }
       
  1932 
       
  1933 
       
  1934 
       
  1935 
       
  1936 // ---------------------------------------------------------
       
  1937 // CApSelect::NewLC()
       
  1938 // ---------------------------------------------------------
       
  1939 //
       
  1940 EXPORT_C CApSelect* CApSelect::NewLC( CCommsDatabase& aDb,
       
  1941                                       TInt aIspFilter,
       
  1942                                       TInt aBearerFilter,
       
  1943                                       TInt aSortType,
       
  1944                                       TInt aReqIpvType,
       
  1945                                       TVpnFilterType aVpnFilterType
       
  1946                                       )
       
  1947     {
       
  1948     CLOG( ( ESelect, 0, _L( "-> CApSelect::NewLC" ) ) );
       
  1949 
       
  1950     CApSelect* db = new( ELeave ) CApSelect;
       
  1951     CleanupStack::PushL( db );
       
  1952     db->ConstructL( aDb, aIspFilter, aBearerFilter, 
       
  1953                     aSortType, aReqIpvType, aVpnFilterType );
       
  1954 
       
  1955     CLOG( ( ESelect, 1, _L( "<- CApSelect::NewLC" ) ) );
       
  1956     return db;
       
  1957     }
       
  1958 
       
  1959 
       
  1960 
       
  1961 // ---------------------------------------------------------
       
  1962 // CApSelect::NewLC()
       
  1963 // ---------------------------------------------------------
       
  1964 //
       
  1965 EXPORT_C CApSelect* CApSelect::NewLC( CCommsDatabase& aDb,
       
  1966                                       TInt aIspFilter,
       
  1967                                       TInt aBearerFilter,
       
  1968                                       TInt aSortType,
       
  1969                                       TInt aReqIpvType,
       
  1970                                       TVpnFilterType aVpnFilterType,
       
  1971                                       TBool aIncludeEasyWlan )
       
  1972     {
       
  1973     CLOG( ( ESelect, 0, _L( "-> CApSelect::NewLC" ) ) );
       
  1974 
       
  1975     CApSelect* db = new( ELeave ) CApSelect;
       
  1976     CleanupStack::PushL( db );
       
  1977     db->ConstructL( aDb, aIspFilter, aBearerFilter, 
       
  1978                     aSortType, aReqIpvType, aVpnFilterType,
       
  1979                     aIncludeEasyWlan );
       
  1980 
       
  1981     CLOG( ( ESelect, 1, _L( "<- CApSelect::NewLC" ) ) );
       
  1982     return db;    
       
  1983     }
       
  1984 
       
  1985 
       
  1986 // ---------------------------------------------------------
       
  1987 // CApSelect::ConstructL
       
  1988 // ---------------------------------------------------------
       
  1989 //
       
  1990 EXPORT_C void CApSelect::ConstructL( CCommsDatabase& aDb,
       
  1991                                  TInt aIspFilter,
       
  1992                                  TInt aBearerFilter,
       
  1993                                  TInt aSortType,
       
  1994                                  TInt aReqIpvType,
       
  1995                                  TVpnFilterType aVpnFilterType )
       
  1996     {
       
  1997     CLOG( ( ESelect, 0, _L( "-> CApSelect::ConstructL" ) ) );
       
  1998     
       
  1999     ConstructL( aDb, aIspFilter, aBearerFilter, aSortType, 
       
  2000                 aReqIpvType, aVpnFilterType, EFalse );
       
  2001 
       
  2002     CLOG( ( ESelect, 1, _L( "<- CApSelect::ConstructL" ) ) );
       
  2003     }
       
  2004 
       
  2005 
       
  2006 
       
  2007 
       
  2008 
       
  2009 // ---------------------------------------------------------
       
  2010 // CApSelect::ConstructL
       
  2011 // ---------------------------------------------------------
       
  2012 //
       
  2013 EXPORT_C void CApSelect::ConstructL( CCommsDatabase& aDb,
       
  2014                                  TInt aIspFilter,
       
  2015                                  TInt aBearerFilter,
       
  2016                                  TInt aSortType,
       
  2017                                  TInt aReqIpvType,
       
  2018                                  TVpnFilterType aVpnFilterType,
       
  2019                                  TBool aIncludeEasyWlan )
       
  2020     {
       
  2021     CLOG( ( ESelect, 0, _L( "-> CApSelect::ConstructL" ) ) );
       
  2022     
       
  2023     iExt = new ( ELeave )TSelectExtra;
       
  2024     iExt->iExtra = 0;
       
  2025     iExt->iIsIpv6Supported = EFalse;
       
  2026     iExt->iMaxIndex = 0;
       
  2027     iExt->iReqIpvType = EIPv4;
       
  2028     iExt->iIsFeatureManagerInitialised = EFalse;
       
  2029     iExt->iCdma = EFalse;
       
  2030     iExt->iWlanSupported = EFalse;
       
  2031     iExt->iIncludeEasyWlan = aIncludeEasyWlan;
       
  2032 
       
  2033     FeatureManager::InitializeLibL();
       
  2034     iExt->iIsFeatureManagerInitialised = ETrue;
       
  2035 
       
  2036     iApList = new( ELeave )CApListItemList();
       
  2037     iExt->iIsIpv6Supported = 
       
  2038             FeatureManager::FeatureSupported( KFeatureIdIPv6 );
       
  2039 #ifdef __TEST_IPV6_SUPPORT    
       
  2040     iExt->iIsIpv6Supported = ETrue;
       
  2041 #endif //  __TEST_IPV6_SUPPORT    
       
  2042     iExt->iCdma = FeatureManager::FeatureSupported( KFeatureIdProtocolCdma );
       
  2043 #ifdef __TEST_CDMA_SUPPORT
       
  2044     iExt->iCdma = ETrue;
       
  2045 #endif // __TEST_CDMA_SUPPORT
       
  2046 
       
  2047     iExt->iWlanSupported = 
       
  2048             FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
  2049 #ifdef __TEST_WLAN_SUPPORT
       
  2050     iExt->iWlanSupported = ETrue;
       
  2051 #endif // __TEST_WLAN_SUPPORT
       
  2052     
       
  2053     iDb = &aDb;
       
  2054 
       
  2055     SetFiltersL( aIspFilter, aBearerFilter, aSortType, 
       
  2056                  aReqIpvType, aVpnFilterType );
       
  2057 
       
  2058     CLOG( ( ESelect, 1, _L( "<- CApSelect::ConstructL" ) ) );
       
  2059     }
       
  2060 
       
  2061 
       
  2062 
       
  2063 // ---------------------------------------------------------
       
  2064 // CApSelect::SetFiltersL
       
  2065 // ---------------------------------------------------------
       
  2066 //
       
  2067 void CApSelect::SetFiltersL( TInt aIspFilter, TInt aBearerFilter,
       
  2068                              TInt aSortType, TInt aReqIpvType,
       
  2069                              TInt aVpnFilterType )
       
  2070     {
       
  2071     CLOG( ( ESelect, 0, _L( "-> CApSelect::SetFilters" ) ) );
       
  2072 
       
  2073     TInt lcode( KErrNone );
       
  2074     // as bearer filter might be EApBearerTypeAllBearers, 
       
  2075     // there is no point to check bearer filter validity
       
  2076     // but we can still check ISP...
       
  2077     if ( aIspFilter >= 2*KEApIspTypeMMSMandatory )
       
  2078         {
       
  2079         lcode = KErrInvalidIspRequest;
       
  2080         }
       
  2081 
       
  2082     User::LeaveIfError( lcode );
       
  2083 
       
  2084     if ( !( ( aSortType == KEApSortUidAscending )
       
  2085         || ( aSortType == KEApSortUidDescending )
       
  2086         || ( aSortType == KEApSortNameAscending )
       
  2087         || ( aSortType == KEApSortNameDescending ) )
       
  2088         )
       
  2089         {
       
  2090         // no sorting order specified,
       
  2091         // assuming KEApSortUidAscending
       
  2092         aSortType = KEApSortUidAscending;
       
  2093         }
       
  2094 
       
  2095     if ( !( aBearerFilter & ( EApBearerTypeCSD
       
  2096                         + EApBearerTypeCDMA
       
  2097                         + EApBearerTypeGPRS
       
  2098                         + EApBearerTypeHSCSD
       
  2099                         + EApBearerTypeWLAN
       
  2100                     #ifdef __TEST_LAN_BEARER
       
  2101                         + EApBearerTypeLAN
       
  2102                     #endif // __TEST_LAN_BEARER
       
  2103                         + EApBearerTypeLANModem
       
  2104                     // Check bearertype all case!!!
       
  2105                         + EApBearerTypeAll ) )
       
  2106         )
       
  2107         {
       
  2108         // no bearer type specified,
       
  2109         // assuming EApBearerTypeAll
       
  2110         if ( aBearerFilter != EApBearerTypeAllBearers )
       
  2111             {
       
  2112             // unknown bearer, Leave
       
  2113 	        User::Leave( KErrInvalidBearerType );            
       
  2114             }
       
  2115         }
       
  2116 
       
  2117     if ( !( aIspFilter & ( KEApIspTypeAll
       
  2118                          + KEApIspTypeInternetAndWAP
       
  2119                          + KEApIspTypeInternetOnly
       
  2120                          + KEApIspTypeWAPOnly
       
  2121                          + KEApIspTypeMMSMandatory ) )
       
  2122         )
       
  2123         {
       
  2124         // erroneous use, no ISP type specified,
       
  2125         // or only KEApIspTypeWAPMandatory,
       
  2126         // both cases assuming KEApIspTypeAll
       
  2127         aIspFilter += KEApIspTypeAll;
       
  2128         }
       
  2129 
       
  2130     iIsp = aIspFilter;
       
  2131     iSort = aSortType;
       
  2132 
       
  2133     if ( aBearerFilter & EApBearerTypeAll )
       
  2134         {
       
  2135         aBearerFilter = EApBearerTypeAllBearers;
       
  2136         }
       
  2137 
       
  2138 	iBearer = GetSupportedBearerSet( aBearerFilter );
       
  2139 	
       
  2140 	if ( !iBearer )
       
  2141 	    {
       
  2142 	    User::Leave( KErrInvalidBearerType );
       
  2143 	    }
       
  2144 
       
  2145     iExt->iReqIpvType = aReqIpvType;
       
  2146 
       
  2147     iExt->iVpnFilterType = aVpnFilterType;
       
  2148 
       
  2149     DoUpdateL();
       
  2150 
       
  2151     if ( iSort == KEApSortNameAscending )
       
  2152         {
       
  2153         SortLocalisedNameL( ETrue ); // ascending
       
  2154         }
       
  2155     else
       
  2156         {
       
  2157         if ( iSort == KEApSortNameDescending )
       
  2158             {
       
  2159             SortLocalisedNameL( EFalse ); // descending
       
  2160             }
       
  2161         else
       
  2162             {
       
  2163             if ( iSort == KEApSortUidAscending )
       
  2164                 {
       
  2165                 SortUidL( ETrue );
       
  2166                 }
       
  2167             else
       
  2168                 {
       
  2169                 if ( iSort == KEApSortUidDescending )
       
  2170                     {
       
  2171                     SortUidL( EFalse );
       
  2172                     }
       
  2173                 }
       
  2174             }
       
  2175         }
       
  2176 
       
  2177     CLOG( ( ESelect, 1, _L( "<- CApSelect::SetFilters" ) ) );
       
  2178     }
       
  2179 
       
  2180 
       
  2181 
       
  2182 // ---------------------------------------------------------
       
  2183 // CApSelect::GetVpnTableViewLC()
       
  2184 // ---------------------------------------------------------
       
  2185 //
       
  2186 CCommsDbTableView* CApSelect::GetVpnTableViewLC( )
       
  2187     {
       
  2188     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetVpnTableViewLC" ) ) );
       
  2189 
       
  2190     CCommsDbTableView* table = NULL;
       
  2191     table = iDb->OpenTableLC( TPtrC(VPN_SERVICE) );
       
  2192     
       
  2193     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetVpnTableViewLC" ) ) );
       
  2194 
       
  2195     return table;
       
  2196     }
       
  2197 
       
  2198 
       
  2199 
       
  2200 // ---------------------------------------------------------
       
  2201 // CApSelect::GetVpnValuesL
       
  2202 // ---------------------------------------------------------
       
  2203 //
       
  2204 void CApSelect::GetVpnValuesL( CCommsDbTableView* aTable,
       
  2205                                CArrayFixFlat<TVpnData>* aVpnArray )
       
  2206     { // get the VPN values
       
  2207     CLOG( ( ESelect, 0, _L( "-> CApSelect::GetVpnValuesL" ) ) );
       
  2208 
       
  2209     if ( aTable )
       
  2210         {
       
  2211         TInt err = aTable->GotoFirstRecord();
       
  2212         if ( ( err != KErrNone ) && ( err != KErrNotFound ) )
       
  2213             {
       
  2214             User::Leave( err );
       
  2215             }
       
  2216         if ( err != KErrNotFound )
       
  2217             {
       
  2218             TUint32 tempvpn( 0 );
       
  2219             TUint32 temphome( 0 );
       
  2220             HBufC*  tempname = NULL;
       
  2221             TVpnData data;
       
  2222             TBool goon( ETrue );
       
  2223             do
       
  2224                 {
       
  2225                 err = ApCommons::ReadUintL( aTable, TPtrC(COMMDB_ID), 
       
  2226                                             tempvpn );
       
  2227                 if ( ( err == KErrNone ) && ( tempvpn ) )
       
  2228                     {
       
  2229                     err = ApCommons::ReadUintL( aTable, 
       
  2230                                                 TPtrC(VPN_SERVICE_IAP),
       
  2231                                                 temphome );
       
  2232                     if ( ( err == KErrNone ) && ( temphome ) )
       
  2233                         {
       
  2234                         // now get the name
       
  2235 
       
  2236                         tempname = 
       
  2237                             ApCommons::ReadText16ValueLC( aTable, 
       
  2238                                                           TPtrC(COMMDB_NAME) );
       
  2239                         
       
  2240                         // everything is O.K., we can add the item
       
  2241                         data.iHomeIapId = temphome;
       
  2242                         data.iVpnIapId = tempvpn;
       
  2243                         data.iName = tempname;
       
  2244                         aVpnArray->AppendL( data ); // array owns it...
       
  2245                         }
       
  2246                     // Only VPN iaps which point to a real IAP are added to list.
       
  2247                     }
       
  2248                 else
       
  2249                     {
       
  2250                     User::LeaveIfError( err );
       
  2251                     }
       
  2252                 err = aTable->GotoNextRecord();
       
  2253                 if ( err == KErrNotFound )
       
  2254                     {
       
  2255                     goon = EFalse;
       
  2256                     }
       
  2257                 else
       
  2258                     {
       
  2259                     User::LeaveIfError( err );
       
  2260                     }
       
  2261                 }
       
  2262                 while ( goon );
       
  2263             }
       
  2264         }
       
  2265     CLOG( ( ESelect, 1, _L( "<- CApSelect::GetVpnValuesL" ) ) );
       
  2266 
       
  2267     }
       
  2268 
       
  2269 
       
  2270 
       
  2271 
       
  2272 
       
  2273 // ---------------------------------------------------------
       
  2274 // CApSelect::AddLanL
       
  2275 // ---------------------------------------------------------
       
  2276 //
       
  2277 void CApSelect::AddLanL( TBool aWlan )
       
  2278     {
       
  2279     CLOG( ( ESelect, 0, _L( "-> CApSelect::AddLanL" ) ) );
       
  2280 
       
  2281     // First get the list of all VPN-s
       
  2282     // get their WAP-ID, IAPID,  
       
  2283     // Also ask their RealIApID, bearertype and filter for it...
       
  2284 
       
  2285     CCommsDbTableView* lant = NULL;
       
  2286 
       
  2287     lant = iDb->OpenViewMatchingTextLC( TPtrC(IAP), 
       
  2288                                         TPtrC(IAP_SERVICE_TYPE), 
       
  2289                                         TPtrC(LAN_SERVICE) );
       
  2290     TInt err = lant->GotoFirstRecord();
       
  2291     if ( err != KErrNotFound)
       
  2292         {
       
  2293         User::LeaveIfError( err );
       
  2294 
       
  2295         CArrayFixFlat<TUint32>* laniapid =
       
  2296                 new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
  2297         CleanupStack::PushL( laniapid );
       
  2298         GetUintValuesL( lant, TPtrC(COMMDB_ID), *laniapid );
       
  2299 
       
  2300         CArrayFixFlat<TUint32>* lanserviceid =
       
  2301                 new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
  2302         CleanupStack::PushL( lanserviceid );
       
  2303         GetUintValuesL( lant, TPtrC(IAP_SERVICE), *lanserviceid );
       
  2304 
       
  2305         CArrayFixFlat<TUint32>* iapbearerid =
       
  2306                 new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
  2307         CleanupStack::PushL( iapbearerid );
       
  2308         GetUintValuesL( lant, TPtrC(IAP_BEARER), *iapbearerid );
       
  2309 
       
  2310         // read up access point names, too, just to be as fast as we can...
       
  2311         CArrayPtrFlat<HBufC>* lanapname =
       
  2312                 new ( ELeave ) CArrayPtrFlat<HBufC>( 10 );
       
  2313         CleanupStack::PushL( lanapname );
       
  2314         GetTextValuesL( lant, TPtrC(COMMDB_NAME), *lanapname );
       
  2315 
       
  2316         // now get WAP ID's
       
  2317 //        CArrayFixFlat<TUint32>* lanwapapid =
       
  2318 //                new ( ELeave ) CArrayFixFlat<TUint32>( 10 );
       
  2319 //        CleanupStack::PushL( lanwapapid );
       
  2320         CApUtils* utils = CApUtils::NewLC( *iDb );
       
  2321 
       
  2322         TUint32 count( laniapid->Count() );
       
  2323         TUint32 currlaniapid;
       
  2324         TUint32 currwapapid( 0 );
       
  2325         CApListItem* item = NULL;
       
  2326 
       
  2327         for ( TUint32 i = 0; i < count; i++)
       
  2328             {
       
  2329             currlaniapid = laniapid->At( i ); 
       
  2330             TRAP( err, currwapapid = utils->WapIdFromIapIdL( currlaniapid ));
       
  2331             if ( !err )
       
  2332                 { // get protection for the given record
       
  2333                 TInt prot( EFalse );
       
  2334                 CCommsDbTableView* wt = NULL;
       
  2335 
       
  2336                 wt = iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT), 
       
  2337                                                 TPtrC(COMMDB_ID), 
       
  2338                                                 currwapapid );
       
  2339                 CCommsDbProtectTableView* protview =
       
  2340                     (CCommsDbProtectTableView*)wt;
       
  2341                                                 
       
  2342                 User::LeaveIfError( wt->GotoFirstRecord() );
       
  2343                 err = protview->GetRecordAccess( prot );
       
  2344                 HBufC* wspage = wt->ReadLongTextLC( TPtrC(WAP_START_PAGE) );
       
  2345                 if ( aWlan )
       
  2346                     {
       
  2347                     if ( iExt->iWlanSupported )
       
  2348                         {
       
  2349                         // check if it is a WLAN, add ONLY if it IS
       
  2350                         TUint32 lanid = lanserviceid->At( i );
       
  2351                         TBool iswlan( EFalse );
       
  2352                         TRAP( err, iswlan = utils->IsWlanL( lanid ) );
       
  2353                         if ( !err && iswlan )
       
  2354                             {
       
  2355                             TBool hasssid( EFalse );
       
  2356                             err = KErrNone;
       
  2357                             TRAP( err, 
       
  2358                                    hasssid = utils->HasWlanSSIDL( lanid ));
       
  2359                             if ( iExt->iIncludeEasyWlan )
       
  2360                                 {
       
  2361                                 hasssid = ETrue;
       
  2362                                 }
       
  2363                             if ( (err == KErrNone) && hasssid )
       
  2364                                 {                                
       
  2365                                 item = CApListItem::NewLC( 
       
  2366                                        EIspTypeInternetAndWAP,
       
  2367                                        currwapapid,
       
  2368                                        *lanapname->At( i ),
       
  2369                                        EApBearerTypeWLAN,
       
  2370                                        *wspage,
       
  2371                                        prot );
       
  2372                                 iApList->AppendL( item );
       
  2373                                 CleanupStack::Pop( item ); // owned by list
       
  2374                                 }
       
  2375                             }
       
  2376                         }
       
  2377                     }
       
  2378                 else
       
  2379                     {
       
  2380                     // first check if it is a WLAN, add ONLY if it IS NOT
       
  2381                     // then check if it is LANModem, 
       
  2382                     // then check for LAN, if supported
       
  2383                     // check if it is a WLAN, add ONLY if it IS NOT
       
  2384                     TUint32 lanid = lanserviceid->At( i );
       
  2385                     TBool iswlan( EFalse );
       
  2386                     TRAP( err, iswlan = utils->IsWlanL( lanid ) );                    
       
  2387                     if ( !err && !iswlan )
       
  2388                         {
       
  2389                         // then check if it is LANModem, 
       
  2390                         CCommsDbTableView* lanbearer;
       
  2391                         lanbearer = 
       
  2392                             iDb->OpenViewMatchingUintLC( 
       
  2393                                         TPtrC(LAN_BEARER),
       
  2394                                         TPtrC(COMMDB_ID), 
       
  2395                                         iapbearerid->At(i ) );
       
  2396                         User::LeaveIfError( 
       
  2397                                 lanbearer->GotoFirstRecord() );
       
  2398                         // LANMODEM? check commdb_name
       
  2399                         HBufC* lbuf;
       
  2400                         lbuf = ApCommons::ReadText16ValueLC( lanbearer,
       
  2401                                                      TPtrC(COMMDB_NAME) );
       
  2402                         // if it is KModemBearerLanModem, it is LANModem
       
  2403                         if ( *lbuf == KModemBearerLANModem )
       
  2404                             {
       
  2405                             item = CApListItem::NewLC( EIspTypeInternetAndWAP,
       
  2406                                                        currwapapid,
       
  2407                                                        *lanapname->At( i ),
       
  2408                                                        EApBearerTypeLANModem );
       
  2409                             iApList->AppendL( item );
       
  2410                             CleanupStack::Pop( item ); // item owned by list !
       
  2411                             }
       
  2412                         else
       
  2413                             {
       
  2414 
       
  2415 #ifdef __TEST_LAN_BEARER
       
  2416                             // Check for sure it is LAN
       
  2417                             // we now it is not WLAN, say it is LAN
       
  2418                             item = CApListItem::NewLC( EIspTypeInternetAndWAP,
       
  2419                                                        currwapapid,
       
  2420                                                        *lanapname->At( i ),
       
  2421                                                        EApBearerTypeLAN,
       
  2422                                                        *wspage,
       
  2423                                                        prot );
       
  2424                             iApList->AppendL( item );
       
  2425                             CleanupStack::Pop( item ); // item owned by list !
       
  2426 #endif // __TEST_LAN_BEARER
       
  2427                             }
       
  2428                         CleanupStack::PopAndDestroy( lbuf );
       
  2429                         CleanupStack::PopAndDestroy( lanbearer );
       
  2430                         }
       
  2431                     }
       
  2432                 CleanupStack::PopAndDestroy( wspage );
       
  2433                 CleanupStack::PopAndDestroy( wt );
       
  2434                 }
       
  2435             }
       
  2436 
       
  2437         iCount = iApList->Count();
       
  2438         iExt->iMaxIndex = iCount-1;
       
  2439 
       
  2440         CleanupStack::PopAndDestroy( utils );
       
  2441 //        CleanupStack::PopAndDestroy( lanwapapid );
       
  2442         // ResetAndDestroy the array:
       
  2443         CleanupStack::PopAndDestroy( lanapname->Count() ); // lanapname
       
  2444         CleanupStack::PopAndDestroy( lanapname ); // lanapname
       
  2445 		CleanupStack::PopAndDestroy( iapbearerid );        
       
  2446         CleanupStack::PopAndDestroy( lanserviceid );
       
  2447         CleanupStack::PopAndDestroy( laniapid );
       
  2448         }
       
  2449 
       
  2450     CleanupStack::PopAndDestroy( lant );
       
  2451     CLOG( ( ESelect, 1, _L( "<- CApSelect::AddLanL" ) ) );
       
  2452     }
       
  2453 
       
  2454 
       
  2455 // ---------------------------------------------------------
       
  2456 // CApSelect::GetSupportedBearerSet
       
  2457 // ---------------------------------------------------------
       
  2458 //
       
  2459 TInt CApSelect::GetSupportedBearerSet( TInt aBearerFilter )
       
  2460     {
       
  2461     TInt retval = aBearerFilter;
       
  2462 
       
  2463     TBool isCsdSupported = 
       
  2464           FeatureManager::FeatureSupported( KFeatureIdAppCsdSupport );
       
  2465 #ifdef __TEST_CSD_SUPPORT
       
  2466     isCsdSupported = ETrue;
       
  2467 #endif // __TEST_CSD_SUPPORT
       
  2468 
       
  2469 
       
  2470 #ifdef __TEST_USE_SHARED_DATA
       
  2471     TInt isHscsdSupported = ETrue;
       
  2472         /*
       
  2473         ApCommons::IsGivenSharedDataSupportL( KGeneralSettingsUid, 
       
  2474                                               KGSHSCSDAccessPoints );
       
  2475                                              */
       
  2476 #else
       
  2477     TInt isHscsdSupported = ETrue;
       
  2478 #endif // __TEST_USE_SHARED_DATA
       
  2479 
       
  2480 #ifdef __TEST_HSCSD_SUPPORT
       
  2481     isHscsdSupported = ETrue;
       
  2482 #endif // __TEST_HSCSD_SUPPORT
       
  2483 
       
  2484     if ( !isCsdSupported )
       
  2485         { // remove CSD, HSCSD, do not allow ALL
       
  2486         if ( aBearerFilter & EApBearerTypeAll )
       
  2487             {
       
  2488             retval &= ~EApBearerTypeCSD;
       
  2489             retval &= ~EApBearerTypeHSCSD;            
       
  2490             }
       
  2491         else
       
  2492             {
       
  2493             if ( aBearerFilter & EApBearerTypeCSD )
       
  2494                 {
       
  2495                 retval &= ~EApBearerTypeCSD;
       
  2496                 }
       
  2497             if ( aBearerFilter & EApBearerTypeHSCSD )
       
  2498                 {
       
  2499                 retval &= ~EApBearerTypeHSCSD;
       
  2500                 }
       
  2501             }
       
  2502         }
       
  2503 
       
  2504     if ( !isHscsdSupported )
       
  2505         { // HSCSD
       
  2506         if ( ( aBearerFilter & EApBearerTypeAll )
       
  2507         	 || ( aBearerFilter & EApBearerTypeHSCSD ) )
       
  2508             {
       
  2509 			retval &= ~EApBearerTypeHSCSD;
       
  2510             }
       
  2511         }
       
  2512     return retval;
       
  2513     }
       
  2514 
       
  2515 
       
  2516 // End of File