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