apengine/apeng/src/APDataHandler.cpp
changeset 66 ed07dcc72692
parent 23 7ec726f93df1
equal deleted inserted replaced
64:84c6623982f6 66:ed07dcc72692
    98 // CApDataHandler::NewLC
    98 // CApDataHandler::NewLC
    99 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
   100 //
   100 //
   101 EXPORT_C CApDataHandler* CApDataHandler::NewLC( CCommsDatabase& aDb )
   101 EXPORT_C CApDataHandler* CApDataHandler::NewLC( CCommsDatabase& aDb )
   102     {
   102     {
   103     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::NewLC" ) ) );
   103     return NULL;
   104 
       
   105     CApDataHandler* db = new( ELeave ) CApDataHandler;
       
   106     CleanupStack::PushL( db );
       
   107     db->ConstructL( aDb );
       
   108     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::NewLC" ) ) );
       
   109 
       
   110     return db;
       
   111     }
   104     }
   112 
   105 
   113 
   106 
   114 
   107 
   115 // ---------------------------------------------------------
   108 // ---------------------------------------------------------
   116 // CApDataHandler::~CApDataHandler
   109 // CApDataHandler::~CApDataHandler
   117 // ---------------------------------------------------------
   110 // ---------------------------------------------------------
   118 //
   111 //
   119 EXPORT_C CApDataHandler::~CApDataHandler()
   112 EXPORT_C CApDataHandler::~CApDataHandler()
   120     {
   113     {
   121     if ( iExt )
       
   122         {
       
   123         if ( iExt->iIsFeatureManagerInitialised )
       
   124             {
       
   125             FeatureManager::UnInitializeLib();
       
   126             }
       
   127         }
       
   128     delete iExt;
       
   129     }
   114     }
   130 
   115 
   131 
   116 
   132 // ---------------------------------------------------------
   117 // ---------------------------------------------------------
   133 // CApDataHandler::CApDataHandler
   118 // CApDataHandler::CApDataHandler
   134 // ---------------------------------------------------------
   119 // ---------------------------------------------------------
   135 //
   120 //
   136 EXPORT_C CApDataHandler::CApDataHandler( )
   121 EXPORT_C CApDataHandler::CApDataHandler( )
   137     {
   122     {
   138     iDb = NULL;
       
   139     }
   123     }
   140 
   124 
   141 
   125 
   142 // ---------------------------------------------------------
   126 // ---------------------------------------------------------
   143 // CApDataHandler::ConstructL
   127 // CApDataHandler::ConstructL
   144 // ---------------------------------------------------------
   128 // ---------------------------------------------------------
   145 //
   129 //
   146 EXPORT_C void CApDataHandler::ConstructL( CCommsDatabase& aDb )
   130 EXPORT_C void CApDataHandler::ConstructL( CCommsDatabase& aDb )
   147     {
   131     {
   148     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ConstructL" ) ) );
       
   149 
       
   150     iExt = new ( ELeave )THandlerExtra;
       
   151     iExt->iIsFeatureManagerInitialised = EFalse;
       
   152     iExt->iIsIpv6Supported = EFalse;
       
   153     
       
   154     FeatureManager::InitializeLibL();
       
   155     iExt->iIsFeatureManagerInitialised = ETrue;
       
   156 
       
   157     iExt->iIsIpv6Supported = 
       
   158                             FeatureManager::FeatureSupported( KFeatureIdIPv6 );
       
   159 #ifdef __TEST_IPV6_SUPPORT    
       
   160     iExt->iIsIpv6Supported = ETrue;
       
   161 #endif //  __TEST_IPV6_SUPPORT    
       
   162     
       
   163     iDb = &aDb;
       
   164 
       
   165 #ifdef __TEST_USE_SHARED_DATA
       
   166     iExt->iIsAppHscsdSupport = 
       
   167         ApCommons::IsGivenSharedDataSupportL( KGeneralSettingsUid, 
       
   168                                               KGSHSCSDAccessPoints );
       
   169 #else
       
   170     iExt->iIsAppHscsdSupport = ETrue;
       
   171 #endif // __TEST_USE_SHARED_DATA
       
   172 
       
   173 
       
   174 #ifdef __TEST_HSCSD_SUPPORT
       
   175     iExt->iIsAppHscsdSupport = ETrue;
       
   176 #endif // __TEST_HSCSD_SUPPORT
       
   177 
       
   178     iExt->iVariant = ApCommons::GetVariantL();
       
   179 
       
   180 #ifdef __TEST_CDMA_WRITE_PROTECT
       
   181     iExt->iVariant |= KApUiEditOnlyVPNs;
       
   182 #endif // __TEST_CDMA_WRITE_PROTECT
       
   183 
       
   184 
       
   185     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ConstructL" ) ) );
       
   186     }
   132     }
   187 
   133 
   188 
   134 
   189 // query
   135 // query
   190 // ---------------------------------------------------------
   136 // ---------------------------------------------------------
   192 // ---------------------------------------------------------
   138 // ---------------------------------------------------------
   193 //
   139 //
   194 EXPORT_C void CApDataHandler::AccessPointDataL( TUint32 aUid,
   140 EXPORT_C void CApDataHandler::AccessPointDataL( TUint32 aUid,
   195                                               CApAccessPointItem& aApItem )
   141                                               CApAccessPointItem& aApItem )
   196     {
   142     {
   197     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::AccessPointDataL" ) ) );
       
   198 
       
   199     // returns the AP data of the record with the UID aUid
       
   200     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   201     DoAccessPointDataL( aUid, aApItem );
       
   202     if ( ownTransaction )
       
   203         {
       
   204         ApCommons::CommitTransaction( *iDb );
       
   205         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   206         }
       
   207     aApItem.SanityCheckOk();
       
   208 
       
   209     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::AccessPointDataL" ) ) );
       
   210     }
   143     }
   211 
   144 
   212 
   145 
   213 
   146 
   214 // update
   147 // update
   220                                                 (
   153                                                 (
   221                                                 CApAccessPointItem& aApItem,
   154                                                 CApAccessPointItem& aApItem,
   222                                                 TBool& aNameChanged
   155                                                 TBool& aNameChanged
   223                                                 )
   156                                                 )
   224     {
   157     {
   225     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::UpdateAccessPointDataL" ) ) );
       
   226 
       
   227     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   228         {
       
   229         User::Leave( KErrNotSupported );
       
   230         }
       
   231 
       
   232     // update access point data.
       
   233     aApItem.SanityCheckOk();
       
   234 
       
   235     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   236     DoUpdateAccessPointDataL( aApItem, EFalse, aNameChanged );
       
   237     if ( ownTransaction )
       
   238         {
       
   239         ApCommons::CommitTransaction( *iDb );
       
   240         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   241         }
       
   242 
       
   243     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::UpdateAccessPointDataL" ) ) );
       
   244     }
   158     }
   245 
   159 
   246 
   160 
   247 
   161 
   248 // Creating new AP
   162 // Creating new AP
   250 // CApDataHandler::CreateCopyFromL
   164 // CApDataHandler::CreateCopyFromL
   251 // ---------------------------------------------------------
   165 // ---------------------------------------------------------
   252 //
   166 //
   253 EXPORT_C TUint32 CApDataHandler::CreateCopyFromL( TUint32 aBaseId )
   167 EXPORT_C TUint32 CApDataHandler::CreateCopyFromL( TUint32 aBaseId )
   254     {
   168     {
   255     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::CreateCopyFromL - ERROR: not suported" ) ) );
       
   256     User::Leave( KErrNotSupported );
   169     User::Leave( KErrNotSupported );
   257     }
   170     }
   258 
   171 
   259 
   172 
   260 
   173 
   262 // CApDataHandler::CreateFromDataL
   175 // CApDataHandler::CreateFromDataL
   263 // ---------------------------------------------------------
   176 // ---------------------------------------------------------
   264 //
   177 //
   265 EXPORT_C TUint32 CApDataHandler::CreateFromDataL( CApAccessPointItem& aApItem )
   178 EXPORT_C TUint32 CApDataHandler::CreateFromDataL( CApAccessPointItem& aApItem )
   266     {
   179     {
   267     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::CreateFromDataL" ) ) );
   180     User::Leave( KErrNotSupported );
   268 
       
   269     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   270         {
       
   271         User::Leave( KErrNotSupported );
       
   272         }
       
   273 
       
   274     aApItem.SanityCheckOk();
       
   275 
       
   276     TBool aNameChanged( EFalse );
       
   277     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   278     TUint32 retval = DoUpdateAccessPointDataL( aApItem, ETrue, aNameChanged );
       
   279     if ( ownTransaction )
       
   280         {
       
   281         ApCommons::CommitTransaction( *iDb );
       
   282         CleanupStack::Pop(); // RollbackTransaction
       
   283         }
       
   284 
       
   285     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::CreateFromDataL" ) ) );
       
   286     return retval;
       
   287     }
   181     }
   288 
   182 
   289 
   183 
   290 
   184 
   291 // Remove
   185 // Remove
   293 // CApDataHandler::RemoveAP
   187 // CApDataHandler::RemoveAP
   294 // ---------------------------------------------------------
   188 // ---------------------------------------------------------
   295 //
   189 //
   296 EXPORT_C void CApDataHandler::RemoveAPL( TUint32 aUid )
   190 EXPORT_C void CApDataHandler::RemoveAPL( TUint32 aUid )
   297     {
   191     {
   298     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveAPL" ) ) );
   192     User::Leave( KErrNotSupported );
   299 
       
   300     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   301         {
       
   302         User::Leave( KErrNotSupported );
       
   303         }
       
   304 
       
   305     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   306     DoRemoveAPL( aUid );
       
   307     if ( ownTransaction )
       
   308         {
       
   309         ApCommons::CommitTransaction( *iDb );
       
   310         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   311         }
       
   312 
       
   313     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveAPL" ) ) );
       
   314     }
   193     }
   315 
   194 
   316 
   195 
   317 // Getting default access point
   196 // Getting default access point
   318 // ---------------------------------------------------------
   197 // ---------------------------------------------------------
   319 // CApDataHandler::DefaultL
   198 // CApDataHandler::DefaultL
   320 // ---------------------------------------------------------
   199 // ---------------------------------------------------------
   321 //
   200 //
   322 EXPORT_C TUint32 CApDataHandler::DefaultL( TBool aIsWap ) const
   201 EXPORT_C TUint32 CApDataHandler::DefaultL( TBool aIsWap ) const
   323     {
   202     {
   324     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DefaultL" ) ) );
   203     return 0;
   325 
       
   326     // get default AP...
       
   327     // first get global settings...
       
   328     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   329     TUint32 value = DoGetDefaultL( aIsWap, NULL );
       
   330     if ( ownTransaction )
       
   331         {
       
   332         ApCommons::CommitTransaction( *iDb );
       
   333         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   334         }
       
   335 
       
   336     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DefaultL" ) ) );
       
   337     return value;
       
   338     }
   204     }
   339 
   205 
   340 
   206 
   341 
   207 
   342 // Setting as default
   208 // Setting as default
   345 // ---------------------------------------------------------
   211 // ---------------------------------------------------------
   346 //
   212 //
   347 EXPORT_C void CApDataHandler::SetAsDefaultL( TUint32 aUid,
   213 EXPORT_C void CApDataHandler::SetAsDefaultL( TUint32 aUid,
   348                                             TCommsDbIspType aIntendedType )
   214                                             TCommsDbIspType aIntendedType )
   349     {
   215     {
   350     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::SetAsDefaultL" ) ) );
   216     User::Leave( KErrNotSupported );
   351 
       
   352     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   353         {
       
   354         User::Leave( KErrNotSupported );
       
   355         }
       
   356 
       
   357     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   358     DoSetAsDefaultL( aUid, aIntendedType );
       
   359     if ( ownTransaction )
       
   360         {
       
   361         ApCommons::CommitTransaction( *iDb );
       
   362         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   363         }
       
   364 
       
   365     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::SetAsDefaultL" ) ) );
       
   366     }
   217     }
   367 
   218 
   368 
   219 
   369 // ---------------------------------------------------------
   220 // ---------------------------------------------------------
   370 // ---------------------------------------------------------
   221 // ---------------------------------------------------------
   385                                     TCommDbDialogPref aPrompt,
   236                                     TCommDbDialogPref aPrompt,
   386                                     TUint32 aIAP,
   237                                     TUint32 aIAP,
   387                                     TBool aOverwrite
   238                                     TBool aOverwrite
   388                                     )
   239                                     )
   389     {
   240     {
   390     CLOG( ( EHandler, 0, 
   241     User::Leave( KErrNotSupported );
   391         _L( "-> CApDataHandler::SetPreferredIfDbIapTypeL" ) ) );
   242     }
   392 
       
   393     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   394         {
       
   395         User::Leave( KErrNotSupported );
       
   396         }
       
   397 
       
   398     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   399     DoSetPreferredIfDbIapTypeL( aRank, aDirection, aBearers,
       
   400                                            aPrompt, aIAP, aOverwrite);
       
   401     if ( ownTransaction )
       
   402         {
       
   403         ApCommons::CommitTransaction( *iDb );
       
   404         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   405         }
       
   406 
       
   407     CLOG( ( EHandler, 1, 
       
   408         _L( "<- CApDataHandler::SetPreferredIfDbIapTypeL" ) ) );
       
   409     }
       
   410 
       
   411 
       
   412 
   243 
   413 
   244 
   414 // ---------------------------------------------------------
   245 // ---------------------------------------------------------
   415 // CApDataHandler::SetPreferredIfDbIspTypeL
   246 // CApDataHandler::SetPreferredIfDbIspTypeL
   416 // ---------------------------------------------------------
   247 // ---------------------------------------------------------
   425                                     TUint32 aChargeCard,
   256                                     TUint32 aChargeCard,
   426                                     const TDesC& aServiceType,
   257                                     const TDesC& aServiceType,
   427                                     TBool aOverwrite
   258                                     TBool aOverwrite
   428                                     )
   259                                     )
   429     {
   260     {
   430     CLOG( ( EHandler, 0, 
   261     User::Leave( KErrNotSupported );
   431         _L( "-> CApDataHandler::SetPreferredIfDbIspTypeL" ) ) );
   262     }
   432 
       
   433     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   434         {
       
   435         User::Leave( KErrNotSupported );
       
   436         }
       
   437 
       
   438     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   439     DoSetPreferredIfDbIspTypeL( aRank, aDirection, aBearers, aPrompt,
       
   440                                 aISP, aChargeCard, aServiceType, aOverwrite);
       
   441     if ( ownTransaction )
       
   442         {
       
   443         ApCommons::CommitTransaction( *iDb );
       
   444         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   445         }
       
   446 
       
   447     CLOG( ( EHandler, 1, 
       
   448         _L( "<- CApDataHandler::SetPreferredIfDbIspTypeL" ) ) );
       
   449     }
       
   450 
       
   451 
   263 
   452 
   264 
   453 // ---------------------------------------------------------
   265 // ---------------------------------------------------------
   454 // CApDataHandler::GetPreferredIfDbIapTypeL
   266 // CApDataHandler::GetPreferredIfDbIapTypeL
   455 // ---------------------------------------------------------
   267 // ---------------------------------------------------------
   461                                     TUint32& aBearers,
   273                                     TUint32& aBearers,
   462                                     TUint32& aPrompt,
   274                                     TUint32& aPrompt,
   463                                     TUint32& aIAP
   275                                     TUint32& aIAP
   464                                     )
   276                                     )
   465     {
   277     {
   466     CLOG( ( EHandler, 0, 
       
   467         _L( "-> CApDataHandler::GetPreferredIfDbIapTypeL" ) ) );
       
   468 
       
   469     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   470     CCommsDbConnectionPrefTableView* preft =
       
   471            iDb->OpenConnectionPrefTableViewOnRankLC( aDirection, aRank );
       
   472     TInt err = preft->GotoFirstRecord(); // OK.
       
   473     if ( err == KErrNone )
       
   474         { // record has been found
       
   475         CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
       
   476         preft->ReadConnectionPreferenceL( pref );
       
   477         aBearers = pref.iBearer.iBearerSet;
       
   478         aPrompt = pref.iDialogPref;
       
   479         aIAP = pref.iBearer.iIapId;
       
   480         }
       
   481     else
       
   482         {
       
   483         User::Leave( err );
       
   484         }
       
   485     CleanupStack::PopAndDestroy( preft ); // preft
       
   486 
       
   487     if ( ownTransaction )
       
   488         {
       
   489         ApCommons::CommitTransaction( *iDb );
       
   490         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   491         }
       
   492 
       
   493     CLOG( ( EHandler, 1, 
       
   494         _L( "<- CApDataHandler::GetPreferredIfDbIapTypeL" ) ) );
       
   495     }
   278     }
   496 
   279 
   497 
   280 
   498 
   281 
   499 // ---------------------------------------------------------
   282 // ---------------------------------------------------------
   508                                     TUint32& /*aPrompt*/,
   291                                     TUint32& /*aPrompt*/,
   509                                     TUint32& /*aISP*/,
   292                                     TUint32& /*aISP*/,
   510                                     TUint32& /*aChargeCard*/
   293                                     TUint32& /*aChargeCard*/
   511                                     )
   294                                     )
   512     {
   295     {
   513     CLOG( ( EHandler, 0, 
   296     User::Leave( KErrNotSupported );
   514         _L( "<-> CApDataHandler::GetPreferredIfDbIspTypeL" ) ) );
       
   515 
       
   516     User::Leave( KErrNotSupported );
       
   517 
       
   518     return KErrNoSuchCase;
       
   519 
       
   520     }
   297     }
   521 
   298 
   522 
   299 
   523 
   300 
   524 // ---------------------------------------------------------
   301 // ---------------------------------------------------------
   526 // ---------------------------------------------------------
   303 // ---------------------------------------------------------
   527 //
   304 //
   528 EXPORT_C TUint32 CApDataHandler::DefaultL( TBool aIsWap,
   305 EXPORT_C TUint32 CApDataHandler::DefaultL( TBool aIsWap,
   529                                                  TBool& aReadOnly ) const
   306                                                  TBool& aReadOnly ) const
   530     {
   307     {
   531     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DefaultL" ) ) );
   308     return 0;
   532 
       
   533     // get default AP...
       
   534     // first get global settings...
       
   535     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   536     TUint32 value = DoGetDefaultL( aIsWap, &aReadOnly );
       
   537     if ( ownTransaction )
       
   538         {
       
   539         ApCommons::CommitTransaction( *iDb );
       
   540         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   541         }
       
   542 
       
   543     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DefaultL" ) ) );
       
   544     return value;
       
   545     }
   309     }
   546 
   310 
   547 
   311 
   548 
   312 
   549 
   313 
   551 // CApDataHandler::RemoveNetworkL
   315 // CApDataHandler::RemoveNetworkL
   552 // ---------------------------------------------------------
   316 // ---------------------------------------------------------
   553 //
   317 //
   554 EXPORT_C void CApDataHandler::RemoveNetworkL( TUint32 aUid )
   318 EXPORT_C void CApDataHandler::RemoveNetworkL( TUint32 aUid )
   555     {
   319     {
   556     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveNetworkL" ) ) );
   320     User::Leave( KErrNotSupported );
   557 
       
   558     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   559         {
       
   560         User::Leave( KErrNotSupported );
       
   561         }
       
   562 
       
   563     TBool ownTransaction = ApCommons::StartPushedTransactionLC( *iDb );
       
   564     CCommsDbTableView* nettable =
       
   565         iDb->OpenViewMatchingUintLC( TPtrC(NETWORK), 
       
   566                                      TPtrC(COMMDB_ID), 
       
   567                                      aUid );
       
   568     TInt err = nettable->GotoFirstRecord();
       
   569     if ( err == KErrNone )
       
   570         {
       
   571         nettable->DeleteRecord();
       
   572         }
       
   573     else
       
   574         {
       
   575         if ( err != KErrNotFound )
       
   576             {
       
   577             User::Leave( err );
       
   578             }
       
   579         }
       
   580     CleanupStack::PopAndDestroy( nettable ); // RollbackTransactionOnLeave
       
   581     if ( ownTransaction )
       
   582         {
       
   583         ApCommons::CommitTransaction( *iDb );
       
   584         CleanupStack::Pop(); // RollbackTransactionOnLeave
       
   585         }
       
   586 
       
   587     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveNetworkL" ) ) );
       
   588     }
   321     }
   589 
   322 
   590 
   323 
   591 // ---------------------------------------------------------
   324 // ---------------------------------------------------------
   592 // CApDataHandler::CreateNetworkL
   325 // CApDataHandler::CreateNetworkL
   593 // ---------------------------------------------------------
   326 // ---------------------------------------------------------
   594 //
   327 //
   595 EXPORT_C void CApDataHandler::CreateNetworkL( CApNetworkItem& aNetwork )
   328 EXPORT_C void CApDataHandler::CreateNetworkL( CApNetworkItem& aNetwork )
   596     {
   329     {
   597     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::CreateNetworkL" ) ) );
   330     User::Leave( KErrNotSupported );
   598 
       
   599     if ( iExt->iVariant & KApUiEditOnlyVPNs )
       
   600         {
       
   601         User::Leave( KErrNotSupported );
       
   602         }
       
   603 
       
   604     CApAccessPointItem* aApItem = CApAccessPointItem::NewLC();
       
   605     aApItem->WriteTextL( EApNetworkName, aNetwork.Name() );
       
   606     WriteNetworkDataL( ETrue, *aApItem );
       
   607     TUint32 tempuint( 0 );
       
   608     aApItem->ReadUint( EApNetworkID, tempuint );
       
   609     aNetwork.SetUid( tempuint );
       
   610     CleanupStack::PopAndDestroy( aApItem );
       
   611 
       
   612     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::CreateNetworkL" ) ) );
       
   613     }
   331     }
   614 
   332 
   615 
   333 
   616 // ---------------------------------------------------------
   334 // ---------------------------------------------------------
   617 // CApDataHandler::ReadNetworkPartL
   335 // CApDataHandler::ReadNetworkPartL
   618 // ---------------------------------------------------------
   336 // ---------------------------------------------------------
   619 //
   337 //
   620 EXPORT_C void CApDataHandler::ReadNetworkPartL( CApAccessPointItem& aItem )
   338 EXPORT_C void CApDataHandler::ReadNetworkPartL( CApAccessPointItem& aItem )
   621     {
   339     {
   622     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadNetworkPartL" ) ) );
       
   623 
       
   624     ReadNetworkDataL( aItem );
       
   625 
       
   626     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadNetworkPartL" ) ) );
       
   627     }
   340     }
   628 
   341 
   629 
   342 
   630 // ---------------------------------------------------------
   343 // ---------------------------------------------------------
   631 // CApDataHandler::ReadNetworkL
   344 // CApDataHandler::ReadNetworkL
   632 // ---------------------------------------------------------
   345 // ---------------------------------------------------------
   633 //
   346 //
   634 EXPORT_C void CApDataHandler::ReadNetworkL( TUint32 aUid, 
   347 EXPORT_C void CApDataHandler::ReadNetworkL( TUint32 aUid, 
   635                                             CApNetworkItem& aNetwork )
   348                                             CApNetworkItem& aNetwork )
   636     {
   349     {
   637     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadNetworkL" ) ) );
       
   638 
       
   639     CApAccessPointItem* aItem = CApAccessPointItem::NewLC();
       
   640     aItem->WriteUint( EApNetworkID, aUid );
       
   641     ReadNetworkDataL( *aItem );
       
   642     TUint32 length = aItem->ReadTextLengthL( EApNetworkName );
       
   643     HBufC* buf = HBufC::NewLC( length );
       
   644     TPtr16 ptr = buf->Des();
       
   645     aItem->ReadTextL( EApNetworkName, ptr );
       
   646     aNetwork.SetUid( aUid );
       
   647     aNetwork.SetNameL( ptr );
       
   648     CleanupStack::PopAndDestroy( buf );
       
   649     CleanupStack::PopAndDestroy( aItem );
       
   650 
       
   651     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadNetworkL" ) ) );
       
   652     }
   350     }
   653 
   351 
   654 
   352 
   655 // ================= OTHER EXPORTED FUNCTIONS ==============
   353 // ================= OTHER EXPORTED FUNCTIONS ==============
   656 
   354 
   662 // ---------------------------------------------------------
   360 // ---------------------------------------------------------
   663 //
   361 //
   664 void CApDataHandler::ReadWapDataL( TUint32 aWapId,
   362 void CApDataHandler::ReadWapDataL( TUint32 aWapId,
   665                                   CApAccessPointItem& aApItem )
   363                                   CApAccessPointItem& aApItem )
   666     {
   364     {
   667     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadWapDataL" ) ) );
       
   668 
       
   669     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
   670     CCommsDbTableView* wapt;
       
   671     wapt = iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
       
   672                                        TPtrC(COMMDB_ID), aWapId );
       
   673 
       
   674 
       
   675     User::LeaveIfError( wapt->GotoFirstRecord() );
       
   676 
       
   677     aApItem.WriteUint( EApWapAccessPointID, aWapId );
       
   678 
       
   679     TInt err;
       
   680     HBufC* buf = ApCommons::ReadLongTextLC( wapt,
       
   681                                              TPtrC(WAP_START_PAGE),
       
   682                                              err );
       
   683     if ( err != KErrUnknown )
       
   684         {
       
   685         aApItem.WriteLongTextL( EApWapStartPage, *buf );
       
   686         CleanupStack::PopAndDestroy( buf ); 
       
   687         }
       
   688 
       
   689     buf = ApCommons::ReadText16ValueLC( wapt, TPtrC(WAP_CURRENT_BEARER) );
       
   690     aApItem.WriteTextL( EApWapCurrentBearer, *buf );
       
   691     CleanupStack::PopAndDestroy( buf );
       
   692 
       
   693     buf = ApCommons::ReadText16ValueLC( wapt, TPtrC(COMMDB_NAME) );
       
   694     aApItem.WriteTextL( EApWapAccessPointName, *buf );
       
   695     CleanupStack::PopAndDestroy( buf );
       
   696 
       
   697 
       
   698     TBool readonly = ApCommons::DoGetReadOnlyL( *wapt );
       
   699     // not WriteBool, as it is 'write protected'...
       
   700     aApItem.iIsReadOnly = readonly;
       
   701 
       
   702     CCommsDbTableView* bearert;
       
   703     bearert = iDb->OpenViewMatchingUintLC( *aApItem.iWapBearer,
       
   704                                           TPtrC(WAP_ACCESS_POINT_ID), aWapId );
       
   705 
       
   706     User::LeaveIfError( bearert->GotoFirstRecord() );
       
   707     // now we can read common data
       
   708     buf = ApCommons::ReadText16ValueLC( bearert,
       
   709                                          TPtrC( WAP_GATEWAY_ADDRESS ) );
       
   710     aApItem.WriteTextL( EApWapGatewayAddress, *buf );
       
   711     CleanupStack::PopAndDestroy( buf );
       
   712 
       
   713 
       
   714     TUint32 tempint( 0 );
       
   715     TBool tempbool( EFalse );
       
   716 
       
   717     ApCommons::ReadUintL( bearert, TPtrC(WAP_WSP_OPTION), tempint );
       
   718     aApItem.WriteUint( EApWapWspOption, tempint );
       
   719 
       
   720     ApCommons::ReadBoolL( bearert, TPtrC(WAP_SECURITY), tempbool );
       
   721     aApItem.WriteBool( EApWapSecurity, tempbool );
       
   722 
       
   723     aApItem.SpecifyWap( ETrue );
       
   724     // decide which bearer, read bearer spec. data.
       
   725     if ( *aApItem.iWapBearer == TPtrC(WAP_IP_BEARER) )
       
   726         {
       
   727         // init it, if it is specified in IAP, will override this...
       
   728         aApItem.WriteUint( EApIapServiceId, tempint );
       
   729 
       
   730         ApCommons::ReadUintL( bearert, TPtrC(WAP_IAP), tempint );
       
   731         aApItem.WriteUint( EApWapIap, tempint );
       
   732 
       
   733         ApCommons::ReadUintL( bearert, TPtrC(WAP_PROXY_PORT), tempint );
       
   734         aApItem.WriteUint( EApWapProxyPort, tempint );
       
   735 
       
   736         buf = ApCommons::ReadText16ValueLC( bearert, 
       
   737                                             TPtrC(WAP_PROXY_LOGIN_NAME) );
       
   738         aApItem.WriteTextL( EApProxyLoginName, *buf );
       
   739         CleanupStack::PopAndDestroy( buf );
       
   740 
       
   741 
       
   742         buf = ApCommons::ReadText16ValueLC( bearert, 
       
   743                                             TPtrC(WAP_PROXY_LOGIN_PASS) );
       
   744         aApItem.WriteTextL( EApProxyLoginPass, *buf );
       
   745         CleanupStack::PopAndDestroy( buf );
       
   746 
       
   747 
       
   748 
       
   749         aApItem.SpecifyIpBearer( ETrue );
       
   750         }
       
   751     else
       
   752         {
       
   753         User::Leave( KErrInvalidBearer );
       
   754         }
       
   755     CleanupStack::PopAndDestroy( 2, wapt );    // bearert, wapt
       
   756 
       
   757     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadWapDataL" ) ) );
       
   758     }
   365     }
   759 
   366 
   760 
   367 
   761 // ---------------------------------------------------------
   368 // ---------------------------------------------------------
   762 // CApDataHandler::ReadIapDataL
   369 // CApDataHandler::ReadIapDataL
   763 // ---------------------------------------------------------
   370 // ---------------------------------------------------------
   764 //
   371 //
   765 void CApDataHandler::ReadIapDataL( TUint32 aIapId,
   372 void CApDataHandler::ReadIapDataL( TUint32 aIapId,
   766                                    CApAccessPointItem& aApItem )
   373                                    CApAccessPointItem& aApItem )
   767     {
   374     {
   768     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadIapDataL" ) ) );
       
   769 
       
   770     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
   771     CCommsDbTableView* iapt = iDb->OpenViewMatchingUintLC( TPtrC(IAP),
       
   772                                            TPtrC(COMMDB_ID), aIapId );
       
   773 
       
   774     User::LeaveIfError( iapt->GotoFirstRecord() );
       
   775     // can not be more than one record,
       
   776     // because we are looking up about UID!
       
   777     aApItem.WriteUint( EApWapIap, aIapId );
       
   778 
       
   779     HBufC* buf = ApCommons::ReadText16ValueLC( iapt, TPtrC(COMMDB_NAME) );
       
   780     aApItem.WriteTextL( EApIapName, *buf );
       
   781     CleanupStack::PopAndDestroy( buf );
       
   782 
       
   783     TUint32 tempint;
       
   784 
       
   785     ApCommons::ReadUintL( iapt, TPtrC(IAP_SERVICE), tempint );
       
   786     aApItem.WriteUint( EApIapServiceId, tempint );
       
   787 
       
   788 
       
   789     buf = ApCommons::ReadText16ValueLC( iapt, TPtrC(IAP_SERVICE_TYPE) );
       
   790     aApItem.WriteTextL( EApIapServiceType, *buf );
       
   791     CleanupStack::PopAndDestroy( buf );
       
   792 
       
   793 
       
   794     ApCommons::ReadUintL( iapt, TPtrC(IAP_BEARER), tempint );
       
   795     aApItem.WriteUint( EApIapBearerID, tempint );
       
   796 
       
   797     buf = ApCommons::ReadText16ValueLC( iapt, TPtrC(IAP_BEARER_TYPE) );
       
   798     aApItem.WriteTextL( EApIapBearerType, *buf );
       
   799     CleanupStack::PopAndDestroy( buf );
       
   800 
       
   801     ReadModemBearerNameL( aApItem );
       
   802 
       
   803     ApCommons::ReadUintL( iapt, TPtrC(IAP_NETWORK), tempint );
       
   804     aApItem.iNetworkId = tempint;
       
   805 
       
   806     // Network weighting!
       
   807     ApCommons::ReadUintL( iapt, TPtrC(IAP_NETWORK_WEIGHTING), tempint );
       
   808     
       
   809 /*
       
   810     // seems that location is fixed so no read...
       
   811     ApCommons::ReadUintL( iapt, TPtrC(IAP_LOCATION), tempint );
       
   812     aApItem.i = tempint;
       
   813 */
       
   814 
       
   815 
       
   816     aApItem.SpecifyIAP( ETrue );
       
   817     CleanupStack::PopAndDestroy( iapt );  // iapt
       
   818 
       
   819     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadIapDataL" ) ) );
       
   820     }
   375     }
   821 
   376 
   822 
   377 
   823 
   378 
   824 
   379 
   828 // ---------------------------------------------------------
   383 // ---------------------------------------------------------
   829 //
   384 //
   830 void CApDataHandler::ReadIspDataL( TUint32 aIspId, 
   385 void CApDataHandler::ReadIspDataL( TUint32 aIspId, 
   831                                    CApAccessPointItem& aApItem )
   386                                    CApAccessPointItem& aApItem )
   832     {
   387     {
   833     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadIspDataL" ) ) );
       
   834 
       
   835     /*****************************************************
       
   836     *   Series 60 Customer / ETel
       
   837     *   Series 60  ETel API
       
   838     *****************************************************/
       
   839     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
   840     HBufC* buf = HBufC::NewLC( KModifiableTextLength );
       
   841     TPtr16 ptr = buf->Des();
       
   842     aApItem.ReadTextL( EApIapServiceType, ptr );
       
   843 
       
   844     if ( ( buf->Compare( TPtrC(OUTGOING_WCDMA ) ) == 0 ) ||
       
   845         ( buf->Compare( TPtrC(INCOMING_WCDMA ) ) == 0 ) )
       
   846         {
       
   847         ReadGprsDataL( aIspId, aApItem );
       
   848         }
       
   849     else
       
   850         {
       
   851         if ( ( buf->Compare( TPtrC(DIAL_OUT_ISP ) ) == 0 ) ||
       
   852             ( buf->Compare( TPtrC(DIAL_IN_ISP ) ) == 0 ) )
       
   853             {
       
   854             ReadDialInOutDataL( aIspId, aApItem );
       
   855             }
       
   856         else
       
   857             { // e.g. vpn...
       
   858             if ( buf->Compare( TPtrC(VPN_SERVICE) ) == 0 )
       
   859                 { // VPN
       
   860                 aApItem.iExt->iIsVpnAp = ETrue;
       
   861                 // get vpn bearer type
       
   862                 ReadVpnInfoL( aIspId, aApItem );
       
   863                 }
       
   864             else
       
   865                 {
       
   866                 if ( buf->Compare( TPtrC(LAN_SERVICE) ) == 0 )
       
   867                     { // LAN
       
   868                     // get LAN data (WLAN)
       
   869                     ReadLanDataL( aIspId, aApItem );
       
   870                     }
       
   871                 else
       
   872                     {
       
   873                     User::Leave( KErrInvalidBearer );
       
   874                     }
       
   875                 }
       
   876             }
       
   877         }
       
   878     CleanupStack::PopAndDestroy( buf );   // buf
       
   879 
       
   880     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadIspDataL" ) ) );
       
   881     }
   388     }
   882 
   389 
   883 
   390 
   884 
   391 
   885 // ---------------------------------------------------------
   392 // ---------------------------------------------------------
   887 // ---------------------------------------------------------
   394 // ---------------------------------------------------------
   888 //
   395 //
   889 void CApDataHandler::ReadGprsDataL( TUint32 aIspId,
   396 void CApDataHandler::ReadGprsDataL( TUint32 aIspId,
   890                                     CApAccessPointItem& aApItem )
   397                                     CApAccessPointItem& aApItem )
   891     {
   398     {
   892     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadGprsDataL" ) ) );
       
   893 
       
   894     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
   895     CCommsDbTableView* ispt = NULL;
       
   896 
       
   897     HBufC* servtype = HBufC::NewLC( KModifiableTextLength );
       
   898     TPtr16 ptr = servtype->Des();
       
   899     aApItem.ReadTextL( EApIapServiceType, ptr );
       
   900 
       
   901     if ( servtype->Compare( TPtrC(OUTGOING_WCDMA ) ) == 0 )
       
   902         {
       
   903         ispt = iDb->OpenViewMatchingUintLC( TPtrC(OUTGOING_WCDMA),
       
   904                                            TPtrC(COMMDB_ID),
       
   905                                            aIspId );
       
   906         }
       
   907     else
       
   908         {
       
   909         if ( servtype->Compare( TPtrC(INCOMING_WCDMA ) ) == 0 )
       
   910             {
       
   911             ispt = iDb->OpenViewMatchingUintLC( TPtrC(INCOMING_WCDMA),
       
   912                                                TPtrC(COMMDB_ID),
       
   913                                                aIspId );
       
   914             }
       
   915         else
       
   916             {
       
   917             User::Leave( KErrInvalidBearer );
       
   918             }
       
   919         }
       
   920 
       
   921 
       
   922     User::LeaveIfError( ispt->GotoFirstRecord() );
       
   923 
       
   924     // now read record data
       
   925     HBufC* buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(COMMDB_NAME) );
       
   926     aApItem.WriteTextL( EApIspName, *buf );
       
   927     CleanupStack::PopAndDestroy( buf );
       
   928 
       
   929     TInt err( KErrNone );
       
   930     buf = ApCommons::ReadLongTextLC( ispt, TPtrC(GPRS_APN), err );
       
   931     if ( err != KErrUnknown )
       
   932         {
       
   933         aApItem.WriteLongTextL( EApGprsAccessPointName, *buf );
       
   934         CleanupStack::PopAndDestroy( buf );
       
   935         }
       
   936 
       
   937     TUint32 tempint( 0 );
       
   938     TBool   tempbool( EFalse );
       
   939 
       
   940     ApCommons::ReadUintL( ispt, TPtrC(GPRS_PDP_TYPE), tempint );
       
   941     if ( tempint == RPacketContext::EPdpTypeIPv6 )
       
   942         {
       
   943         aApItem.WriteUint( EApGprsPdpType, EIPv6 );
       
   944         }
       
   945     else
       
   946         {
       
   947         aApItem.WriteUint( EApGprsPdpType, EIPv4 );
       
   948         }
       
   949 
       
   950     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_PDP_ADDRESS) );
       
   951     aApItem.WriteTextL( EApGprsPdpAddress, *buf );
       
   952     CleanupStack::PopAndDestroy( buf );
       
   953 
       
   954     ApCommons::ReadUintL( ispt, TPtrC(GPRS_REQ_PRECEDENCE), tempint );
       
   955     aApItem.WriteUint( EApGprsReqPrecedence, tempint);
       
   956 
       
   957     ApCommons::ReadUintL( ispt, TPtrC(GPRS_REQ_DELAY), tempint );
       
   958     aApItem.WriteUint( EApGprsReqDelay, tempint);
       
   959 
       
   960     ApCommons::ReadUintL( ispt, TPtrC(GPRS_REQ_RELIABILITY), tempint );
       
   961     aApItem.WriteUint( EApGprsReqReliability, tempint);
       
   962 
       
   963     ApCommons::ReadUintL( ispt, TPtrC(GPRS_REQ_PEAK_THROUGHPUT), tempint );
       
   964     aApItem.WriteUint( EApGprsReqPeakThroughput, tempint);
       
   965 
       
   966     ApCommons::ReadUintL( ispt, TPtrC(GPRS_REQ_MEAN_THROUGHPUT), tempint );
       
   967     aApItem.WriteUint( EApGprsReqMeanPeakThroughput, tempint);
       
   968 
       
   969     ApCommons::ReadUintL( ispt, TPtrC(GPRS_MIN_PRECEDENCE), tempint );
       
   970     aApItem.WriteUint( EApGprsMinPrecedence, tempint);
       
   971 
       
   972     ApCommons::ReadUintL( ispt, TPtrC(GPRS_MIN_DELAY), tempint );
       
   973     aApItem.WriteUint( EApGprsMinDelay, tempint);
       
   974 
       
   975     ApCommons::ReadUintL( ispt, TPtrC(GPRS_MIN_RELIABILITY), tempint );
       
   976     aApItem.WriteUint( EApGprsMinReliability, tempint);
       
   977 
       
   978     ApCommons::ReadUintL( ispt, TPtrC(GPRS_MIN_PEAK_THROUGHPUT), tempint );
       
   979     aApItem.WriteUint( EApGprsMinPeakThroughput, tempint);
       
   980 
       
   981     ApCommons::ReadUintL( ispt, TPtrC(GPRS_MIN_MEAN_THROUGHPUT), tempint );
       
   982     aApItem.WriteUint( EApGprsMinMeanThroughput, tempint);
       
   983 
       
   984     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_DATA_COMPRESSION), tempbool );
       
   985     aApItem.WriteBool( EApGprsDataCompression, tempbool );
       
   986 
       
   987     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_HEADER_COMPRESSION), tempbool );
       
   988     aApItem.WriteBool( EApGprsHeaderCompression, tempbool );
       
   989 
       
   990     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_ANONYMOUS_ACCESS), tempbool );
       
   991     aApItem.WriteBool( EApGprsUseAnonymAccess, tempbool );
       
   992 
       
   993 
       
   994     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IF_PARAMS) );
       
   995     aApItem.WriteTextL( EApGprsIfParams, *buf );
       
   996     CleanupStack::PopAndDestroy( buf );
       
   997 
       
   998     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IF_NETWORKS) );
       
   999     aApItem.WriteTextL( EApGprsIfNetworks, *buf );
       
  1000     CleanupStack::PopAndDestroy( buf );
       
  1001 
       
  1002     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_IF_PROMPT_FOR_AUTH), tempbool );
       
  1003     aApItem.WriteBool( EApGprsIfPromptForAuth, tempbool );
       
  1004 
       
  1005 
       
  1006     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IF_AUTH_NAME) );
       
  1007     aApItem.WriteTextL( EApGprsIfAuthName, *buf );
       
  1008     CleanupStack::PopAndDestroy( buf );
       
  1009 
       
  1010     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IF_AUTH_PASS) );
       
  1011     aApItem.WriteTextL( EApGprsIfAuthPassword, *buf );
       
  1012     CleanupStack::PopAndDestroy( buf ); 
       
  1013 
       
  1014     ApCommons::ReadUintL( ispt, TPtrC(GPRS_IF_AUTH_RETRIES), tempint );
       
  1015     aApItem.WriteUint( EApGprsIfAuthRetries, tempint );
       
  1016 
       
  1017     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IP_NETMASK) );
       
  1018     aApItem.WriteTextL( EApGprsIpNetMask, *buf );
       
  1019     CleanupStack::PopAndDestroy( buf );
       
  1020 
       
  1021     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IP_GATEWAY) );
       
  1022     aApItem.WriteTextL( EApGprsIpGateway, *buf );
       
  1023     CleanupStack::PopAndDestroy( buf );
       
  1024 
       
  1025     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_IP_ADDR_FROM_SERVER), tempbool );
       
  1026     aApItem.WriteBool( EApGprsIpAddrFromServer, tempbool );
       
  1027 
       
  1028     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IP_ADDR) );
       
  1029     aApItem.WriteTextL( EApGprsIpAddr, *buf );
       
  1030     CleanupStack::PopAndDestroy( buf );
       
  1031 
       
  1032     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER),
       
  1033                            tempbool );
       
  1034     aApItem.WriteBool( EApGprsIpDnsAddrFromServer, tempbool );
       
  1035 
       
  1036     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IP_NAME_SERVER1) );
       
  1037     aApItem.WriteTextL( EApGprsIPNameServer1, *buf );
       
  1038     CleanupStack::PopAndDestroy( buf );
       
  1039 
       
  1040     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(GPRS_IP_NAME_SERVER2) );
       
  1041     aApItem.WriteTextL( EApGprsIPNameServer2, *buf );
       
  1042     CleanupStack::PopAndDestroy( buf ); 
       
  1043 
       
  1044     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), tempbool );
       
  1045     aApItem.WriteBool( EApGprsEnableLCPExtensions, tempbool );
       
  1046 
       
  1047 
       
  1048     ApCommons::ReadBoolL( ispt, TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH),
       
  1049                            tempbool );
       
  1050     aApItem.WriteBool( EApGprsDisablePlainTextAuth, tempbool );
       
  1051 
       
  1052     ApCommons::ReadUintL( ispt, TPtrC(GPRS_AP_TYPE), tempint );
       
  1053     aApItem.WriteUint( EApIspIspType, TCommsDbIspType( tempint ) );
       
  1054 
       
  1055     if ( iExt->iIsIpv6Supported )
       
  1056         {
       
  1057         ReadServiceIp6L( *ispt, aApItem );
       
  1058         }
       
  1059 
       
  1060     aApItem.SpecifyGPRS( ETrue );
       
  1061     CleanupStack::PopAndDestroy( 2, servtype );  // ispt, servtype
       
  1062 
       
  1063     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadGprsDataL" ) ) );
       
  1064     }
   399     }
  1065 
   400 
  1066 
   401 
  1067 
   402 
  1068 // ---------------------------------------------------------
   403 // ---------------------------------------------------------
  1070 // ---------------------------------------------------------
   405 // ---------------------------------------------------------
  1071 //
   406 //
  1072 void CApDataHandler::ReadLanDataL( TUint32 aIspId,
   407 void CApDataHandler::ReadLanDataL( TUint32 aIspId,
  1073                                    CApAccessPointItem& aApItem )
   408                                    CApAccessPointItem& aApItem )
  1074     {
   409     {
  1075     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadLanDataL" ) ) );
       
  1076 
       
  1077     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1078     CCommsDbTableView* ispt = NULL;
       
  1079 
       
  1080     ispt = iDb->OpenViewMatchingUintLC( TPtrC(LAN_SERVICE),
       
  1081                                            TPtrC(COMMDB_ID),
       
  1082                                            aIspId );
       
  1083     User::LeaveIfError( ispt->GotoFirstRecord() );
       
  1084 
       
  1085     // now read record data
       
  1086     ReadServiceL( *ispt, aApItem );
       
  1087 
       
  1088     CCommsDbTableView* lant = NULL;
       
  1089     // now see if it is WLAN
       
  1090     
       
  1091     if ( aApItem.iExt->iWlanData )
       
  1092         { // WLAN is supported
       
  1093         lant = iDb->OpenViewMatchingUintLC( TPtrC(WLAN_SERVICE ),
       
  1094                                             TPtrC(WLAN_SERVICE_ID),
       
  1095                                             aIspId );
       
  1096     
       
  1097         TInt err = lant->GotoFirstRecord();
       
  1098         // it can be Ethernet Lan, WLAN and LanModem, 
       
  1099         // from those, only WLAN has these fields,
       
  1100         // so if we can read them, it is wlan. If not, it is something else...
       
  1101         if ( err == KErrNone )
       
  1102             {
       
  1103             // now read record data
       
  1104             ReadWlanL( *lant, aApItem );
       
  1105             aApItem.iExt->iWlanData->iIsWlan = ETrue;
       
  1106             }
       
  1107         else
       
  1108             { 
       
  1109             if ( err != KErrNotFound )
       
  1110                 {
       
  1111                 User::LeaveIfError( err );
       
  1112                 }
       
  1113             // can not leave on not found error, as it still might be 
       
  1114             // a valid bearer after all...
       
  1115             aApItem.iExt->iWlanData->iIsWlan = EFalse;
       
  1116             }
       
  1117         aApItem.SpecifyWLAN( ETrue );
       
  1118         CleanupStack::PopAndDestroy( lant ); 
       
  1119         }
       
  1120         
       
  1121     if ( iExt->iIsIpv6Supported )
       
  1122         {
       
  1123         ReadServiceIp6L( *ispt, aApItem );
       
  1124         }
       
  1125 
       
  1126 
       
  1127 
       
  1128     CleanupStack::PopAndDestroy( ispt ); 
       
  1129 
       
  1130     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadLanDataL" ) ) );
       
  1131     }
   410     }
  1132 
   411 
  1133 
   412 
  1134 
   413 
  1135 // ---------------------------------------------------------
   414 // ---------------------------------------------------------
  1137 // ---------------------------------------------------------
   416 // ---------------------------------------------------------
  1138 //
   417 //
  1139 void CApDataHandler::ReadDialInOutDataL( TUint32 aIspId,
   418 void CApDataHandler::ReadDialInOutDataL( TUint32 aIspId,
  1140                                          CApAccessPointItem& aApItem )
   419                                          CApAccessPointItem& aApItem )
  1141     {
   420     {
  1142     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadDialInOutDataL" ) ) );
       
  1143     /*****************************************************
       
  1144     *   Series 60 Customer / ETel
       
  1145     *   Series 60  ETel API
       
  1146     *****************************************************/
       
  1147 
       
  1148     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1149     CCommsDbTableView* ispt = NULL;
       
  1150 
       
  1151     HBufC* servtype = HBufC::NewLC( KModifiableTextLength );
       
  1152     TPtr16 ptr = servtype->Des();
       
  1153     aApItem.ReadTextL( EApIapServiceType, ptr );
       
  1154 
       
  1155     if ( servtype->Compare( TPtrC(DIAL_OUT_ISP) ) == 0 )    
       
  1156         {
       
  1157         ispt = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_OUT_ISP),
       
  1158                                             TPtrC(COMMDB_ID), aIspId );
       
  1159         }
       
  1160     else
       
  1161         {
       
  1162         ispt = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_IN_ISP),
       
  1163                                             TPtrC(COMMDB_ID), aIspId );
       
  1164         }
       
  1165 
       
  1166     User::LeaveIfError( ispt->GotoFirstRecord() );
       
  1167 
       
  1168     TUint32 tempint( 0 );
       
  1169     TBool   tempbool( EFalse );
       
  1170 
       
  1171     HBufC* buf = NULL;
       
  1172 
       
  1173     aApItem.WriteUint( EApIapServiceId, aIspId );
       
  1174 
       
  1175 
       
  1176     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(COMMDB_NAME) );
       
  1177     aApItem.WriteTextL( EApIspName, *buf );
       
  1178     CleanupStack::PopAndDestroy( buf ); 
       
  1179 
       
  1180     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_DESCRIPTION) );
       
  1181     aApItem.WriteTextL( EApIspDescription, *buf );
       
  1182     CleanupStack::PopAndDestroy( buf );
       
  1183 
       
  1184 
       
  1185     ApCommons::ReadUintL( ispt, TPtrC(ISP_TYPE), tempint );
       
  1186     aApItem.WriteUint( EApIspIspType, TCommsDbIspType( tempint ) );
       
  1187 
       
  1188     buf = ApCommons::ReadText16ValueLC( ispt,
       
  1189                                          TPtrC(ISP_DEFAULT_TEL_NUM) );
       
  1190     aApItem.WriteTextL( EApIspDefaultTelNumber, *buf );
       
  1191     CleanupStack::PopAndDestroy( buf );
       
  1192 
       
  1193 
       
  1194     ApCommons::ReadBoolL( ispt, TPtrC(ISP_DIAL_RESOLUTION), tempbool );
       
  1195     aApItem.WriteBool( EApIspDialResolution, tempbool );
       
  1196 
       
  1197     ApCommons::ReadBoolL( ispt, TPtrC(ISP_USE_LOGIN_SCRIPT), tempbool );
       
  1198     aApItem.WriteBool( EApIspUseLoginScript, tempbool );
       
  1199 
       
  1200     TInt err;
       
  1201     buf = ApCommons::ReadLongTextLC( ispt, TPtrC(ISP_LOGIN_SCRIPT), err );
       
  1202     aApItem.WriteLongTextL( EApIspLoginScript, *buf );
       
  1203     CleanupStack::PopAndDestroy( buf );
       
  1204 
       
  1205 
       
  1206     ApCommons::ReadBoolL( ispt, TPtrC(ISP_PROMPT_FOR_LOGIN), tempbool );
       
  1207     aApItem.WriteBool( EApIspPromptForLogin, tempbool );
       
  1208 
       
  1209     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_LOGIN_NAME) );
       
  1210     // as same UserName & AuthName is required, it is readed from username
       
  1211     aApItem.WriteTextL( EApIspLoginName, *buf );
       
  1212     aApItem.WriteTextL( EApIspIfAuthName, *buf );
       
  1213     CleanupStack::PopAndDestroy( buf );
       
  1214 
       
  1215 
       
  1216     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_LOGIN_PASS) );
       
  1217     // as same Login_pass & AuthPassword is required,
       
  1218     // it is readed from login_pass
       
  1219     aApItem.WriteTextL( EApIspLoginPass, *buf );
       
  1220     aApItem.WriteTextL( EApIspIfAuthPass, *buf );
       
  1221     CleanupStack::PopAndDestroy( buf );
       
  1222 
       
  1223 
       
  1224     ApCommons::ReadBoolL( ispt, TPtrC(ISP_DISPLAY_PCT), tempbool );
       
  1225     aApItem.WriteBool( EApIspDisplayPCT, tempbool );
       
  1226 
       
  1227 
       
  1228     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_IF_PARAMS) );
       
  1229     aApItem.WriteTextL( EApIspIfParams, *buf );
       
  1230     CleanupStack::PopAndDestroy( buf );
       
  1231 
       
  1232     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_IF_NETWORKS) );
       
  1233     aApItem.WriteTextL( EApIspIfNetworks, *buf );
       
  1234     CleanupStack::PopAndDestroy( buf );
       
  1235 
       
  1236     ApCommons::ReadBoolL( ispt, TPtrC(ISP_IF_PROMPT_FOR_AUTH), tempbool );
       
  1237     aApItem.WriteBool( EApIspIfPromptForAuth, tempbool );
       
  1238 
       
  1239 
       
  1240     ApCommons::ReadUintL( ispt, TPtrC(ISP_IF_AUTH_RETRIES), tempint );
       
  1241     aApItem.WriteUint( EApIspAuthRetries, tempint );
       
  1242 
       
  1243     ApCommons::ReadBoolL( ispt,
       
  1244                            TPtrC(ISP_IF_CALLBACK_ENABLED), tempbool );
       
  1245 
       
  1246     aApItem.WriteBool( EApIspIfCallbackEnabled, tempbool );
       
  1247 
       
  1248 
       
  1249     ApCommons::ReadUintL( ispt, TPtrC(ISP_IF_CALLBACK_TYPE), tempint );
       
  1250     aApItem.WriteUint( EApIspIfCallbackType, ( TCallbackAction )tempint );
       
  1251 
       
  1252 
       
  1253     HBufC8* buf8 = ApCommons::ReadText8ValueLC
       
  1254                                     (
       
  1255                                     ispt,
       
  1256                                     TPtrC(ISP_IF_CALLBACK_INFO)
       
  1257                                     );
       
  1258     aApItem.WriteTextL( EApIspIfCallbackInfo, *buf8 );
       
  1259     CleanupStack::PopAndDestroy( buf8 ); 
       
  1260 
       
  1261     ApCommons::ReadUintL( ispt, TPtrC(ISP_CALLBACK_TIMEOUT), tempint );
       
  1262     aApItem.WriteUint( EApIspCallBackTimeOut, tempint );
       
  1263 
       
  1264 
       
  1265     ApCommons::ReadBoolL( ispt,
       
  1266                            TPtrC(ISP_IP_ADDR_FROM_SERVER), tempbool );
       
  1267 
       
  1268     aApItem.WriteBool( EApIspIPAddrFromServer, tempbool );
       
  1269 
       
  1270     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_IP_ADDR) );
       
  1271     aApItem.WriteTextL( EApIspIPAddr, *buf );
       
  1272     CleanupStack::PopAndDestroy( buf );
       
  1273 
       
  1274     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_IP_NETMASK) );
       
  1275     aApItem.WriteTextL( EApIspIPNetMask, *buf );
       
  1276     CleanupStack::PopAndDestroy( buf );
       
  1277 
       
  1278     buf = ApCommons::ReadText16ValueLC( ispt, TPtrC(ISP_IP_GATEWAY) );
       
  1279     aApItem.WriteTextL( EApIspIPGateway, *buf );
       
  1280     CleanupStack::PopAndDestroy( buf );
       
  1281 
       
  1282     ApCommons::ReadBoolL( ispt, TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),
       
  1283                            tempbool );
       
  1284 
       
  1285     aApItem.WriteBool( EApIspIPDnsAddrFromServer, tempbool );
       
  1286 
       
  1287     buf = ApCommons::ReadText16ValueLC( ispt,
       
  1288                                          TPtrC(ISP_IP_NAME_SERVER1) );
       
  1289 
       
  1290     aApItem.WriteTextL( EApIspIPNameServer1, *buf );
       
  1291     CleanupStack::PopAndDestroy( buf ); 
       
  1292 
       
  1293     buf = ApCommons::ReadText16ValueLC( ispt,
       
  1294                                          TPtrC(ISP_IP_NAME_SERVER2) );
       
  1295 
       
  1296     aApItem.WriteTextL( EApIspIPNameServer2, *buf );
       
  1297     CleanupStack::PopAndDestroy( buf );
       
  1298 
       
  1299 
       
  1300     ApCommons::ReadBoolL( ispt, TPtrC(ISP_ENABLE_IP_HEADER_COMP),
       
  1301                            tempbool );
       
  1302 
       
  1303     aApItem.WriteBool( EApIspEnableIpHeaderComp, tempbool );
       
  1304 
       
  1305 
       
  1306     ApCommons::ReadBoolL( ispt, TPtrC(ISP_ENABLE_LCP_EXTENSIONS),
       
  1307                            tempbool );
       
  1308 
       
  1309     aApItem.WriteBool( EApIspEnableLCPExtensions, tempbool );
       
  1310 
       
  1311 
       
  1312     ApCommons::ReadBoolL( ispt, TPtrC(ISP_DISABLE_PLAIN_TEXT_AUTH),
       
  1313                            tempbool );
       
  1314 
       
  1315     aApItem.WriteBool( EApIspDisablePlainTextAuth, tempbool );
       
  1316 
       
  1317 
       
  1318     ApCommons::ReadBoolL( ispt, TPtrC(ISP_ENABLE_SW_COMP), tempbool );
       
  1319 
       
  1320     aApItem.WriteBool( EApIspEnableSWCompression, tempbool );
       
  1321 
       
  1322 
       
  1323     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_NAME), tempint );
       
  1324     aApItem.WriteUint( EApIspBearerName,
       
  1325                        (RMobileCall::TMobileCallDataServiceCaps)tempint );
       
  1326 
       
  1327     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_SPEED), tempint );
       
  1328     aApItem.iExt->iBearerSpeed = tempint;
       
  1329 
       
  1330     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_PROTOCOL), tempint );
       
  1331     aApItem.iExt->iBearerProtocol = tempint;
       
  1332 
       
  1333     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_CE), tempint );
       
  1334     aApItem.WriteUint( EApIspBearerCE, 
       
  1335                       (RMobileCall::TMobileCallDataQoSCaps) tempint );
       
  1336 
       
  1337     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_SERVICE), tempint );
       
  1338     aApItem.WriteUint( EApIapBearerService, tempint );
       
  1339 
       
  1340 
       
  1341 
       
  1342     buf8 = ApCommons::ReadText8ValueLC( ispt,
       
  1343                                          TPtrC(ISP_INIT_STRING) );
       
  1344 
       
  1345     aApItem.WriteTextL( EApIspInitString, *buf8 );
       
  1346     CleanupStack::PopAndDestroy( buf8 );
       
  1347 
       
  1348     ApCommons::ReadUintL( ispt, TPtrC(ISP_BEARER_TYPE), tempint );
       
  1349     aApItem.WriteUint( EApIspBearerType, tempint);
       
  1350 
       
  1351     ApCommons::ReadUintL( ispt, TPtrC(ISP_CHANNEL_CODING), tempint );
       
  1352     aApItem.WriteUint( EApIspChannelCoding, tempint);
       
  1353 
       
  1354     ApCommons::ReadUintL( ispt, TPtrC(ISP_AIUR), tempint );
       
  1355     aApItem.WriteUint( EApIspAIUR, tempint);
       
  1356 
       
  1357     ApCommons::ReadUintL( ispt,
       
  1358                            TPtrC(ISP_REQUESTED_TIME_SLOTS),
       
  1359                            tempint );
       
  1360     aApItem.WriteUint( EApIspRequestedTimeSlots, tempint);
       
  1361 
       
  1362     ApCommons::ReadUintL( ispt, TPtrC(ISP_MAXIMUM_TIME_SLOTS), tempint );
       
  1363     aApItem.WriteUint( EApIspMaximumTimeSlots, tempint);
       
  1364 
       
  1365 
       
  1366     if ( iExt->iIsIpv6Supported )
       
  1367         {
       
  1368         ReadServiceIp6L( *ispt, aApItem );
       
  1369         }
       
  1370 
       
  1371     EtelSpeed2ApL( aApItem );
       
  1372 
       
  1373     aApItem.SpecifyISP( ETrue );
       
  1374     CleanupStack::PopAndDestroy( 2, servtype );   // ispt, servtype
       
  1375 
       
  1376     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadDialInOutDataL" ) ) );
       
  1377     }
   421     }
  1378 
   422 
  1379 
   423 
  1380 
   424 
  1381 // ---------------------------------------------------------
   425 // ---------------------------------------------------------
  1383 // ---------------------------------------------------------
   427 // ---------------------------------------------------------
  1384 //
   428 //
  1385 void CApDataHandler::ReadVpnInfoL( TUint32 aIspId, 
   429 void CApDataHandler::ReadVpnInfoL( TUint32 aIspId, 
  1386                                    CApAccessPointItem& aApItem)
   430                                    CApAccessPointItem& aApItem)
  1387     {
   431     {
  1388     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadVpnInfoL" ) ) );
       
  1389 
       
  1390     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1391     CCommsDbTableView* ispt = NULL;
       
  1392 
       
  1393     ispt = iDb->OpenViewMatchingUintLC( TPtrC(VPN_SERVICE),
       
  1394                                         TPtrC(COMMDB_ID), aIspId );
       
  1395     User::LeaveIfError( ispt->GotoFirstRecord() );
       
  1396 
       
  1397     TUint32 tempint;
       
  1398 
       
  1399     HBufC* buf = NULL;
       
  1400     // get the real iap
       
  1401     ApCommons::ReadUintL( ispt, TPtrC(VPN_SERVICE_IAP), tempint );
       
  1402 
       
  1403     CCommsDbTableView* iapt = NULL;
       
  1404     iapt = iDb->OpenViewMatchingUintLC( TPtrC(IAP),
       
  1405                                         TPtrC(COMMDB_ID), tempint );
       
  1406 
       
  1407     User::LeaveIfError( iapt->GotoFirstRecord() );
       
  1408 
       
  1409     TUint32 iapservice;
       
  1410     ApCommons::ReadUintL( iapt, TPtrC(IAP_SERVICE), iapservice );
       
  1411     
       
  1412     buf = ApCommons::ReadText16ValueLC( iapt, TPtrC(IAP_SERVICE_TYPE) );
       
  1413     
       
  1414     if ( ( buf->Compare( TPtrC(OUTGOING_WCDMA ) ) == 0 ) ||
       
  1415         ( buf->Compare( TPtrC(INCOMING_WCDMA ) ) == 0 ) )
       
  1416         {
       
  1417         aApItem.iExt->iVPnRealIapBearerType = EApBearerTypeGPRS;
       
  1418         }
       
  1419     else
       
  1420         {
       
  1421         if ( ( buf->Compare( TPtrC(DIAL_OUT_ISP ) ) == 0 ) ||
       
  1422             ( buf->Compare( TPtrC(DIAL_IN_ISP ) ) == 0 ) )
       
  1423             {
       
  1424             // need to get ISP,
       
  1425             CCommsDbTableView* doutt = NULL;
       
  1426             doutt = iDb->OpenViewMatchingUintLC( *buf,
       
  1427                                                  TPtrC(COMMDB_ID), 
       
  1428                                                  iapservice );
       
  1429             User::LeaveIfError( doutt->GotoFirstRecord() );
       
  1430             ApCommons::ReadUintL( doutt , TPtrC(ISP_BEARER_TYPE), tempint );
       
  1431             if ( tempint == EBearerTypeCSD )
       
  1432                 {
       
  1433                 aApItem.iExt->iVPnRealIapBearerType = EApBearerTypeCSD;
       
  1434                 }
       
  1435             else
       
  1436                 {
       
  1437                 aApItem.iExt->iVPnRealIapBearerType = EApBearerTypeHSCSD;
       
  1438                 }
       
  1439             CleanupStack::PopAndDestroy( doutt ); // doutt
       
  1440             }
       
  1441         else
       
  1442             {
       
  1443             // VPN, having a bearer something else than CSD, HSCSD,
       
  1444             // GPRS & CDMA?
       
  1445             if ( buf->Compare( TPtrC(LAN_SERVICE) ) == 0 )
       
  1446                 { // LAN
       
  1447                 ReadLanDataL( aIspId, aApItem );
       
  1448                 }
       
  1449             else
       
  1450                 { // otherwise, error
       
  1451                 User::Leave( KErrInvalidBearer );
       
  1452                 }
       
  1453             }
       
  1454         }
       
  1455 
       
  1456     CleanupStack::PopAndDestroy( 3, ispt ); // buf, iapt, ispt
       
  1457 
       
  1458     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadVpnInfoL" ) ) );
       
  1459     }
   432     }
  1460 
   433 
  1461 
   434 
  1462 
   435 
  1463 // ---------------------------------------------------------
   436 // ---------------------------------------------------------
  1465 // ---------------------------------------------------------
   438 // ---------------------------------------------------------
  1466 //
   439 //
  1467 void CApDataHandler::WriteWapBearerDataL( TBool aIsNew, TUint32 aWapId,
   440 void CApDataHandler::WriteWapBearerDataL( TBool aIsNew, TUint32 aWapId,
  1468                                    CApAccessPointItem& aApItem )
   441                                    CApAccessPointItem& aApItem )
  1469     {
   442     {
  1470     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteWapBearerDataL" ) ) );
       
  1471 
       
  1472     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1473     CCommsDbTableView* bearert;
       
  1474     if ( aIsNew )
       
  1475         {
       
  1476         bearert = iDb->OpenTableLC( TPtrC(*aApItem.iWapBearer) );
       
  1477         // CommDB's back-link makes returned UID value unusable,
       
  1478         // variable needed just to be able to make the call...
       
  1479         TUint32 dummy;
       
  1480         User::LeaveIfError( bearert->InsertRecord( dummy ) );
       
  1481         }
       
  1482     else
       
  1483         {
       
  1484         bearert = iDb->OpenViewMatchingUintLC( TPtrC(*aApItem.iWapBearer),
       
  1485                                               TPtrC(WAP_ACCESS_POINT_ID),
       
  1486                                               aWapId );
       
  1487         User::LeaveIfError( bearert->GotoFirstRecord() );
       
  1488         User::LeaveIfError( bearert->UpdateRecord() );
       
  1489         }
       
  1490     bearert->WriteTextL( TPtrC(WAP_GATEWAY_ADDRESS),
       
  1491                          *aApItem.iWapGatewayAddress );
       
  1492     bearert->WriteUintL( TPtrC(WAP_WSP_OPTION),
       
  1493                          aApItem.iIsConnectionTypeContinuous );
       
  1494     bearert->WriteBoolL( TPtrC(WAP_SECURITY), aApItem.iIsWTLSSecurityOn );
       
  1495     bearert->WriteUintL( TPtrC(WAP_ACCESS_POINT_ID), aWapId );
       
  1496 
       
  1497     if ( *aApItem.iWapBearer == TPtrC(WAP_IP_BEARER) )
       
  1498         {
       
  1499         bearert->WriteUintL( TPtrC(WAP_IAP), aApItem.iWapIap );        
       
  1500         bearert->WriteUintL( TPtrC(WAP_PROXY_PORT), aApItem.iWapProxyPort );
       
  1501         bearert->WriteTextL( TPtrC(WAP_PROXY_LOGIN_NAME),
       
  1502                              *aApItem.iWapProxyLoginName );
       
  1503         bearert->WriteTextL( TPtrC(WAP_PROXY_LOGIN_PASS),
       
  1504                              *aApItem.iWapProxyLoginPass );
       
  1505         }
       
  1506     else
       
  1507         {
       
  1508         User::Leave( KErrInvalidBearer );
       
  1509         }
       
  1510 
       
  1511     User::LeaveIfError( bearert->PutRecordChanges( EFalse, EFalse ) );
       
  1512 
       
  1513     CleanupStack::PopAndDestroy( bearert );   // bearert
       
  1514 
       
  1515     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteWapBearerDataL" ) ) );
       
  1516     }
   443     }
  1517 
   444 
  1518 
   445 
  1519 
   446 
  1520 
   447 
  1523 // ---------------------------------------------------------
   450 // ---------------------------------------------------------
  1524 //
   451 //
  1525 void CApDataHandler::WriteWapApDataL( TBool aIsNew, TUint32 aWapId,
   452 void CApDataHandler::WriteWapApDataL( TBool aIsNew, TUint32 aWapId,
  1526                                    CApAccessPointItem& aApItem )
   453                                    CApAccessPointItem& aApItem )
  1527     {
   454     {
  1528     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteWapApDataL" ) ) );
       
  1529 
       
  1530     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1531     CCommsDbTableView* wapt;
       
  1532 
       
  1533     if ( aIsNew )
       
  1534         {
       
  1535         wapt = iDb->OpenTableLC( TPtrC(WAP_ACCESS_POINT) );
       
  1536         TInt err = wapt->InsertRecord( aApItem.iWapUid );
       
  1537         if ( err )
       
  1538             {
       
  1539             User::LeaveIfError( err );
       
  1540             }
       
  1541         // CommDB's back-link makes returned UID value unusable,
       
  1542         // variable needed just to be able to make the call...
       
  1543         }
       
  1544     else
       
  1545         {
       
  1546         wapt = iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
       
  1547                                            TPtrC(COMMDB_ID), aWapId );
       
  1548         User::LeaveIfError( wapt->GotoFirstRecord() );
       
  1549         User::LeaveIfError( wapt->UpdateRecord() );
       
  1550         }
       
  1551 
       
  1552     wapt->WriteTextL( TPtrC(WAP_CURRENT_BEARER), *aApItem.iWapBearer );
       
  1553     wapt->WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iWapAccessPointName );
       
  1554 
       
  1555     wapt->WriteLongTextL( TPtrC(WAP_START_PAGE), *aApItem.iStartingPage );
       
  1556 
       
  1557     User::LeaveIfError( wapt->PutRecordChanges( EFalse, EFalse ) );
       
  1558 
       
  1559     CleanupStack::PopAndDestroy( wapt );   // wapt
       
  1560 
       
  1561     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteWapApDataL" ) ) );
       
  1562     }
   455     }
  1563 
   456 
  1564 
   457 
  1565 
   458 
  1566 // ---------------------------------------------------------
   459 // ---------------------------------------------------------
  1568 // ---------------------------------------------------------
   461 // ---------------------------------------------------------
  1569 //
   462 //
  1570 void CApDataHandler::WriteIapDataL( TBool aIsNew, TUint32 aIapId,
   463 void CApDataHandler::WriteIapDataL( TBool aIsNew, TUint32 aIapId,
  1571                                    CApAccessPointItem& aApItem )
   464                                    CApAccessPointItem& aApItem )
  1572     {
   465     {
  1573     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteIapDataL" ) ) );
       
  1574 
       
  1575     CCommsDbTableView* iapt;
       
  1576     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1577     if ( aIsNew )
       
  1578         {
       
  1579         iapt = iDb->OpenTableLC( TPtrC(IAP) );
       
  1580         User::LeaveIfError( iapt->InsertRecord( aApItem.iWapIap ) );
       
  1581         }
       
  1582     else
       
  1583         {
       
  1584         iapt = iDb->OpenViewMatchingUintLC( TPtrC(IAP),
       
  1585                                                TPtrC(COMMDB_ID), aIapId );
       
  1586         User::LeaveIfError( iapt->GotoFirstRecord() );
       
  1587         User::LeaveIfError( iapt->UpdateRecord() );
       
  1588         }
       
  1589 
       
  1590     iapt->WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iIapName );
       
  1591     iapt->WriteUintL( TPtrC(IAP_SERVICE), aApItem.iIapServiceId );
       
  1592     iapt->WriteTextL( TPtrC(IAP_SERVICE_TYPE), *aApItem.iIapServiceType );
       
  1593 
       
  1594     // hardcoded...
       
  1595     TApBearerType bearer = aApItem.BearerTypeL();
       
  1596     switch ( bearer )
       
  1597         {
       
  1598         case EApBearerTypeWLAN:
       
  1599             {
       
  1600             if ( aApItem.iExt->iWlanData )
       
  1601                 {
       
  1602                 iapt->WriteTextL( TPtrC(IAP_BEARER_TYPE), TPtrC(LAN_BEARER) );
       
  1603                 }
       
  1604             else
       
  1605                 {
       
  1606                 User::Leave( KErrNotSupported );
       
  1607                 }
       
  1608             break;
       
  1609             }
       
  1610 #ifdef __TEST_LAN_BEARER 
       
  1611         case EApBearerTypeLAN:
       
  1612             {
       
  1613             iapt->WriteTextL( TPtrC(IAP_BEARER_TYPE), TPtrC(LAN_BEARER) );
       
  1614             break;
       
  1615             }
       
  1616 #endif // __TEST_LAN_BEARER        
       
  1617         case EApBearerTypeLANModem:
       
  1618             {
       
  1619             iapt->WriteTextL( TPtrC(IAP_BEARER_TYPE), TPtrC(LAN_BEARER) );
       
  1620             break;
       
  1621             }
       
  1622         default:
       
  1623             {
       
  1624             iapt->WriteTextL( TPtrC(IAP_BEARER_TYPE), TPtrC(MODEM_BEARER) );
       
  1625             break;
       
  1626             }            
       
  1627         }
       
  1628         
       
  1629     TUint32 id = GetModemBearerIDL( aApItem );
       
  1630     iapt->WriteUintL( TPtrC(IAP_BEARER), id );
       
  1631     
       
  1632     iapt->WriteUintL( TPtrC(IAP_NETWORK), aApItem.iNetworkId );
       
  1633     // Network weighting!
       
  1634     iapt->WriteUintL( TPtrC(IAP_NETWORK_WEIGHTING), 0 );
       
  1635     
       
  1636     TUint32 loc = GetLocationIdL();
       
  1637     iapt->WriteUintL( TPtrC(IAP_LOCATION), loc );
       
  1638 
       
  1639     // now put changes
       
  1640     User::LeaveIfError( iapt->PutRecordChanges( EFalse, EFalse ) );
       
  1641 
       
  1642     CleanupStack::PopAndDestroy( iapt );  // iapt
       
  1643 
       
  1644     if ( aIsNew )
       
  1645         {
       
  1646         CCommsDbConnectionPrefTableView* view = 
       
  1647             iDb->OpenConnectionPrefTableViewOnRankLC( 
       
  1648                     ECommDbConnectionDirectionOutgoing, 1 );
       
  1649         
       
  1650         TInt ret = view->GotoFirstRecord();
       
  1651         
       
  1652         CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref tablePref;
       
  1653         
       
  1654         if ( ret == KErrNone )
       
  1655             {
       
  1656             view->ReadConnectionPreferenceL( tablePref );
       
  1657                 
       
  1658             TUint32 iapId = tablePref.iBearer.iIapId;
       
  1659                 
       
  1660             // Check if iap exists
       
  1661             CCommsDbTableView* view2 = 
       
  1662                 iDb->OpenViewMatchingUintLC( TPtrC(IAP), 
       
  1663                                              TPtrC(COMMDB_ID), 
       
  1664                                              iapId );
       
  1665         
       
  1666             TInt exists = view2->GotoFirstRecord();
       
  1667             CleanupStack::PopAndDestroy(); // view2
       
  1668 
       
  1669             if ( iapId == 0 || exists != KErrNone )
       
  1670                 {
       
  1671                 if ( bearer & 
       
  1672                    ( EApBearerTypeCSD 
       
  1673                      + EApBearerTypeHSCSD 
       
  1674                      + EApBearerTypeGPRS 
       
  1675                      + EApBearerTypeCDMA ) )
       
  1676                     {
       
  1677                     // Get the current settings and then overwrite with the Iap
       
  1678                     tablePref.iBearer.iIapId = aApItem.iWapIap;
       
  1679                     tablePref.iBearer.iBearerSet = 
       
  1680                             KCommDbBearerCSD | KCommDbBearerWcdma;
       
  1681                     view->UpdateBearerL( tablePref.iBearer );
       
  1682                     }
       
  1683                 }
       
  1684             }
       
  1685         CleanupStack::PopAndDestroy(); // view
       
  1686         }
       
  1687 
       
  1688     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteIapDataL" ) ) );
       
  1689     }
   466     }
  1690 
   467 
  1691 
   468 
  1692 
   469 
  1693 // ---------------------------------------------------------
   470 // ---------------------------------------------------------
  1695 // ---------------------------------------------------------
   472 // ---------------------------------------------------------
  1696 //
   473 //
  1697 void CApDataHandler::WriteIspDataL( TBool aIsNew, TUint32 aIspId,
   474 void CApDataHandler::WriteIspDataL( TBool aIsNew, TUint32 aIspId,
  1698                                    CApAccessPointItem& aApItem )
   475                                    CApAccessPointItem& aApItem )
  1699     {
   476     {
  1700     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteIspDataL" ) ) );
       
  1701 
       
  1702     aApItem.WriteUint( EApIapServiceId, aIspId );
       
  1703     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  1704     if ( ( aApItem.iIapServiceType->Compare( TPtrC(OUTGOING_WCDMA ) ) == 0 ) ||
       
  1705         ( aApItem.iIapServiceType->Compare( TPtrC(INCOMING_WCDMA ) ) == 0 ) )
       
  1706         {
       
  1707         WriteGprsDataL( aIsNew, aApItem );
       
  1708         }
       
  1709     else
       
  1710         {
       
  1711         if ( ( aApItem.iIapServiceType->Compare( TPtrC(DIAL_IN_ISP) ) == 0 ) ||
       
  1712             ( aApItem.iIapServiceType->Compare( TPtrC(DIAL_OUT_ISP) ) == 0 ) )
       
  1713             {
       
  1714             WriteCsdDataL( aIsNew, aApItem );
       
  1715             }
       
  1716         else
       
  1717             { // check if VPN
       
  1718             if ( aApItem.iIapServiceType->Compare( TPtrC(VPN_SERVICE) ) == 0 )
       
  1719                 { // currently, KErrNotSupported
       
  1720                 User::Leave( KErrNotSupported );
       
  1721                 }
       
  1722             else
       
  1723                 { 
       
  1724                 if ( aApItem.iIapServiceType->Compare( 
       
  1725                                 TPtrC(LAN_SERVICE) ) == 0 )
       
  1726                     {
       
  1727                     WriteLanDataL( aIsNew, aApItem );
       
  1728                     }
       
  1729                 else
       
  1730                     {
       
  1731                     // something unknown, 
       
  1732                     User::Leave( KErrInvalidBearer );
       
  1733                     }
       
  1734                 }
       
  1735             }
       
  1736         }
       
  1737 
       
  1738     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteIspDataL" ) ) );
       
  1739     }
   477     }
  1740 
   478 
  1741 
   479 
  1742 
   480 
  1743 
   481 
  1746 // ---------------------------------------------------------
   484 // ---------------------------------------------------------
  1747 //
   485 //
  1748 void CApDataHandler::WriteGprsDataL( TBool aIsNew,
   486 void CApDataHandler::WriteGprsDataL( TBool aIsNew,
  1749                                     CApAccessPointItem& aApItem )
   487                                     CApAccessPointItem& aApItem )
  1750     {
   488     {
  1751     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteGprsDataL" ) ) );
       
  1752 
       
  1753     CCommsDbTableView* table;
       
  1754 
       
  1755     if ( aIsNew )
       
  1756         {
       
  1757         table = iDb->OpenTableLC( *aApItem.iIapServiceType );
       
  1758         User::LeaveIfError( table->InsertRecord( aApItem.iIapServiceId ) );
       
  1759         }
       
  1760     else
       
  1761         {
       
  1762         table = iDb->OpenViewMatchingUintLC( *aApItem.iIapServiceType,
       
  1763                                            TPtrC(COMMDB_ID),
       
  1764                                            aApItem.iIapServiceId );
       
  1765         User::LeaveIfError( table->GotoFirstRecord() );
       
  1766         User::LeaveIfError( table->UpdateRecord() );
       
  1767         }
       
  1768     // now write record data
       
  1769     table->WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iIspName );
       
  1770 
       
  1771     table->WriteLongTextL( TPtrC(GPRS_APN), *aApItem.iGprsAccessPointName );
       
  1772 
       
  1773     
       
  1774     if ( aApItem.iGprsPdpType == EIPv6 )
       
  1775         {
       
  1776         table->WriteUintL( TPtrC(GPRS_PDP_TYPE), 
       
  1777                            RPacketContext::EPdpTypeIPv6 );
       
  1778         }
       
  1779     else
       
  1780         {
       
  1781         table->WriteUintL( TPtrC(GPRS_PDP_TYPE), 
       
  1782                            RPacketContext::EPdpTypeIPv4 );
       
  1783         }
       
  1784 
       
  1785     table->WriteTextL( TPtrC(GPRS_PDP_ADDRESS), *aApItem.iGprsPdpAddress );
       
  1786 
       
  1787     table->WriteUintL( TPtrC(GPRS_REQ_PRECEDENCE),
       
  1788                        aApItem.iGprsReqPrecedence );
       
  1789 
       
  1790     table->WriteUintL( TPtrC(GPRS_REQ_DELAY), aApItem.iGprsReqDelay );
       
  1791 
       
  1792     table->WriteUintL( TPtrC(GPRS_REQ_RELIABILITY),
       
  1793                        aApItem.iGprsReqReliability );
       
  1794 
       
  1795     table->WriteUintL( TPtrC(GPRS_REQ_PEAK_THROUGHPUT),
       
  1796                        aApItem.iGprsReqPeakThroughput );
       
  1797 
       
  1798     table->WriteUintL( TPtrC(GPRS_REQ_MEAN_THROUGHPUT),
       
  1799                        aApItem.iGprsReqMeanPeakThroughput );
       
  1800 
       
  1801     table->WriteUintL( TPtrC(GPRS_MIN_PRECEDENCE),
       
  1802                        aApItem.iGprsMinPrecedence );
       
  1803 
       
  1804     table->WriteUintL( TPtrC(GPRS_MIN_DELAY), aApItem.iGprsMinDelay );
       
  1805 
       
  1806     table->WriteUintL( TPtrC(GPRS_MIN_RELIABILITY),
       
  1807                        aApItem.iGprsMinReliability );
       
  1808 
       
  1809     table->WriteUintL( TPtrC(GPRS_MIN_PEAK_THROUGHPUT),
       
  1810                        aApItem.iGprsMinPeakThroughput );
       
  1811 
       
  1812     table->WriteUintL( TPtrC(GPRS_MIN_MEAN_THROUGHPUT),
       
  1813                        aApItem.iGprsMinMeanThroughput );
       
  1814 
       
  1815     table->WriteBoolL( TPtrC(GPRS_DATA_COMPRESSION),
       
  1816                      aApItem.iIspEnableSwCompression );
       
  1817 
       
  1818     table->WriteBoolL( TPtrC(GPRS_HEADER_COMPRESSION),
       
  1819                      aApItem.iEnablePPPCompression );
       
  1820 
       
  1821     table->WriteBoolL( TPtrC(GPRS_ANONYMOUS_ACCESS),
       
  1822                      aApItem.iGprsUseAnonymAccess );
       
  1823 
       
  1824 /*
       
  1825 // Keep as long as replacing IF_NAME does not works as specified 
       
  1826     table->WriteTextL( TPtrC(IF_NAME), *aApItem.iIspIfName );
       
  1827 */
       
  1828 
       
  1829     table->WriteTextL( TPtrC(GPRS_IF_PARAMS), *aApItem.iIspIfParams );
       
  1830 
       
  1831     table->WriteTextL( TPtrC(GPRS_IF_NETWORKS), *aApItem.iIspIfNetworks );
       
  1832 
       
  1833     table->WriteBoolL( TPtrC(GPRS_IF_PROMPT_FOR_AUTH),
       
  1834                      aApItem.iIspIfPromptForAuth );
       
  1835 
       
  1836     table->WriteTextL( TPtrC(GPRS_IF_AUTH_NAME), *aApItem.iIspIfAuthName );
       
  1837 
       
  1838     table->WriteTextL( TPtrC(GPRS_IF_AUTH_PASS), *aApItem.iIspIfAuthPass );
       
  1839 
       
  1840     table->WriteUintL( TPtrC(GPRS_IF_AUTH_RETRIES),
       
  1841                      aApItem.iIspIfAuthRetries );
       
  1842 
       
  1843     table->WriteTextL( TPtrC(GPRS_IP_NETMASK), *aApItem.iIspIPNetMask );
       
  1844 
       
  1845     table->WriteTextL( TPtrC(GPRS_IP_GATEWAY), *aApItem.iIspGateway );
       
  1846 
       
  1847     table->WriteBoolL( TPtrC(GPRS_IP_ADDR_FROM_SERVER),
       
  1848                        aApItem.iIspIPAddrFromServer );
       
  1849 
       
  1850     table->WriteTextL( TPtrC(GPRS_IP_ADDR), *aApItem.iIspIPAddr );
       
  1851 
       
  1852     table->WriteBoolL( TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER),
       
  1853                      aApItem.iGetDNSIPFromServer );
       
  1854 
       
  1855     table->WriteTextL( TPtrC(GPRS_IP_NAME_SERVER1), *aApItem.iPrimaryDNS );
       
  1856 
       
  1857     table->WriteTextL( TPtrC(GPRS_IP_NAME_SERVER2), *aApItem.iSecondaryDNS );
       
  1858 
       
  1859     table->WriteBoolL( TPtrC(GPRS_ENABLE_LCP_EXTENSIONS),
       
  1860                      aApItem.iIspEnableLCPExtensions );
       
  1861 
       
  1862     table->WriteBoolL( TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH),
       
  1863                      aApItem.iIsPasswordAuthenticationSecure );
       
  1864 
       
  1865     table->WriteUintL( TPtrC(GPRS_AP_TYPE), aApItem.iIspType );
       
  1866 
       
  1867 
       
  1868     // Agreed to use const...
       
  1869     table->WriteUintL( TPtrC(GPRS_QOS_WARNING_TIMEOUT), 
       
  1870                        TUint32(KGprsOsTimeout) );
       
  1871 
       
  1872     if ( iExt->iIsIpv6Supported )
       
  1873         {
       
  1874         WriteServiceIp6L( *table, aApItem );
       
  1875         }
       
  1876 
       
  1877 //    WriteDaemonL( *table, aApItem ); starts here
       
  1878     if ( aApItem.iIspIPAddrFromServer )
       
  1879         {
       
  1880         table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), 
       
  1881                            KDaemonManagerName );
       
  1882         table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), 
       
  1883                            KConfigDaemonName );
       
  1884         }
       
  1885     else
       
  1886         {
       
  1887         // 3.1 it is changed!!
       
  1888         if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
  1889             {
       
  1890             table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), 
       
  1891                                KDaemonManagerName );
       
  1892             table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), 
       
  1893                                KConfigDaemonName );            
       
  1894             }
       
  1895         else
       
  1896             {
       
  1897             table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), KEmpty );
       
  1898             table->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), KEmpty );            
       
  1899             }
       
  1900         }
       
  1901 //    WriteDaemonL() Ends here
       
  1902     
       
  1903     // now put changes
       
  1904     User::LeaveIfError( table->PutRecordChanges( EFalse, EFalse ) );
       
  1905 
       
  1906     CleanupStack::PopAndDestroy( table );  // table
       
  1907 
       
  1908     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteGprsDataL" ) ) );
       
  1909     }
   489     }
  1910 
   490 
  1911 
   491 
  1912 
   492 
  1913 // ---------------------------------------------------------
   493 // ---------------------------------------------------------
  1915 // ---------------------------------------------------------
   495 // ---------------------------------------------------------
  1916 //
   496 //
  1917 void CApDataHandler::WriteLanDataL( TBool aIsNew,
   497 void CApDataHandler::WriteLanDataL( TBool aIsNew,
  1918                                     CApAccessPointItem& aApItem )
   498                                     CApAccessPointItem& aApItem )
  1919     {
   499     {
  1920     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteLanDataL" ) ) );
       
  1921 
       
  1922     CCommsDbTableView* table;
       
  1923 
       
  1924     if ( aIsNew )
       
  1925         {
       
  1926         table = iDb->OpenTableLC( *aApItem.iIapServiceType );
       
  1927         User::LeaveIfError( table->InsertRecord( aApItem.iIapServiceId ) );
       
  1928         }
       
  1929     else
       
  1930         {
       
  1931         table = iDb->OpenViewMatchingUintLC( *aApItem.iIapServiceType,
       
  1932                                            TPtrC(COMMDB_ID),
       
  1933                                            aApItem.iIapServiceId );
       
  1934         User::LeaveIfError( table->GotoFirstRecord() );
       
  1935         User::LeaveIfError( table->UpdateRecord() );
       
  1936         }
       
  1937 
       
  1938     // now write record data
       
  1939     WriteServiceL( *table, aApItem );
       
  1940 
       
  1941     TApBearerType bearer = aApItem.BearerTypeL();
       
  1942 
       
  1943    
       
  1944     if ( bearer == EApBearerTypeWLAN )
       
  1945         {
       
  1946         if ( aApItem.iExt->iWlanData )
       
  1947             {
       
  1948         
       
  1949             CCommsDbTableView* wlantable = NULL;
       
  1950 
       
  1951             if ( aIsNew )
       
  1952                 {        
       
  1953                 TUint32 dummy;
       
  1954                 wlantable = iDb->OpenTableLC( TPtrC(WLAN_SERVICE) );
       
  1955                 User::LeaveIfError( wlantable->InsertRecord( dummy ) );
       
  1956                 aApItem.iExt->iWlanData->iWlanId = dummy;        
       
  1957                 }
       
  1958             else
       
  1959                 {
       
  1960                 // WLAN settings table backlinks to LAN service, 
       
  1961                 // so we query WLAN settings for a record 
       
  1962                 // where WLAN_SERVICE_ID is LAN_SERVICE's COMMDB_ID, 
       
  1963                 // which is aApItem.iIapServiceId...
       
  1964                 wlantable = iDb->OpenViewMatchingUintLC( TPtrC(WLAN_SERVICE),
       
  1965                                                          TPtrC(WLAN_SERVICE_ID),
       
  1966                                                          aApItem.iIapServiceId );
       
  1967                 User::LeaveIfError( wlantable->GotoFirstRecord() );
       
  1968                 User::LeaveIfError( wlantable->UpdateRecord() );
       
  1969                 }
       
  1970 
       
  1971             // Add WLAN specific data storage
       
  1972             WriteWlanL( *wlantable, aApItem );
       
  1973             User::LeaveIfError( wlantable->PutRecordChanges( EFalse, EFalse ) );
       
  1974             CleanupStack::PopAndDestroy( wlantable );  // wlantable
       
  1975             }
       
  1976         else
       
  1977             {                        
       
  1978             // WLAN not supported, do not try to write it....
       
  1979             User::Leave( KErrInvalidBearer );
       
  1980             }
       
  1981 
       
  1982         }
       
  1983     
       
  1984     if ( iExt->iIsIpv6Supported )
       
  1985         {
       
  1986         WriteServiceIp6L( *table, aApItem );
       
  1987         }
       
  1988 
       
  1989     // now put changes
       
  1990     User::LeaveIfError( table->PutRecordChanges( EFalse, EFalse ) );
       
  1991     CleanupStack::PopAndDestroy( table );  // table
       
  1992 
       
  1993     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteLanDataL" ) ) );
       
  1994     }
   500     }
  1995 
   501 
  1996 
   502 
  1997 
   503 
  1998 // ---------------------------------------------------------
   504 // ---------------------------------------------------------
  2004                                         CApAccessPointItem& aApItem,
   510                                         CApAccessPointItem& aApItem,
  2005                                         TBool aIsNew,
   511                                         TBool aIsNew,
  2006                                         TBool& aNameChanged
   512                                         TBool& aNameChanged
  2007                                         )
   513                                         )
  2008     {
   514     {
  2009     CLOG( ( EHandler, 0, 
   515     return 0;
  2010         _L( "-> CApDataHandler::DoUpdateAccessPointDataL" ) ) );
       
  2011 
       
  2012     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  2013     if ( aApItem.iWapAccessPointName->Length() == 0 )
       
  2014         {
       
  2015         User::Leave( KErrInvalidName );
       
  2016         }
       
  2017 
       
  2018     if ( aIsNew )
       
  2019         {
       
  2020         HBufC* sgd = ApCommons::DoMakeValidNameL
       
  2021                                         (
       
  2022                                         *iDb,
       
  2023                                         aNameChanged,
       
  2024                                         aApItem.iWapAccessPointName,
       
  2025                                         aApItem.iWapUid,
       
  2026                                         aIsNew
       
  2027                                         );
       
  2028         if ( aNameChanged )
       
  2029             {
       
  2030             CleanupStack::PushL( sgd );
       
  2031             aApItem.SetNamesL( *sgd );
       
  2032             CleanupStack::Pop( sgd );
       
  2033             }
       
  2034         delete sgd;
       
  2035         }
       
  2036     else
       
  2037         {
       
  2038         // first check the existence of the access point,
       
  2039         // just to be on the sure side...
       
  2040         CCommsDbTableView* wapt;
       
  2041         wapt = iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
       
  2042                                            TPtrC(COMMDB_ID), aApItem.iWapUid );
       
  2043         // if no other problem, will return KErrNone if it exists
       
  2044         // so we will go through to the next step.
       
  2045         // if returns KErrNotFound or any other problem, leave here.
       
  2046         User::LeaveIfError( wapt->GotoFirstRecord() );
       
  2047         // now we need to destroy to create a new 'view'
       
  2048         CleanupStack::PopAndDestroy( wapt ); // wapt
       
  2049 
       
  2050         // now we can go on with the real stuff here...
       
  2051         // check if a record with the currently given name exists.
       
  2052         // No problem, if the UID is the same as ours,
       
  2053         // otherwise, leave because name already exists...
       
  2054         wapt = iDb->OpenViewMatchingTextLC( TPtrC(WAP_ACCESS_POINT),
       
  2055                                             TPtrC(COMMDB_NAME),
       
  2056                                             *aApItem.iWapAccessPointName );
       
  2057         TInt res =  wapt->GotoFirstRecord();
       
  2058         if ( res == KErrNotFound )
       
  2059             { // no such name
       
  2060             aNameChanged = EFalse;
       
  2061             }
       
  2062         else
       
  2063             {
       
  2064             if ( res == KErrNone )
       
  2065                 {
       
  2066                 TUint32 id;
       
  2067                 wapt->ReadUintL( TPtrC(COMMDB_ID), id );
       
  2068                 if ( id != aApItem.iWapUid )
       
  2069                     {
       
  2070                     User::Leave( KErrAlreadyExists );
       
  2071                     }
       
  2072                 }
       
  2073             else
       
  2074                 {
       
  2075                 User::LeaveIfError( res );
       
  2076                 }
       
  2077             }
       
  2078         CleanupStack::PopAndDestroy( wapt );   // wapt
       
  2079         }
       
  2080 
       
  2081     TBool NeedManualUpdate( ETrue );
       
  2082 
       
  2083     // additional code for managing bearer-change starts here...
       
  2084     if ( !aIsNew )
       
  2085         { // only check if update op.
       
  2086         // if bearer changed, it also UPDATES everything !
       
  2087         // if no change, update MUST BE DONE HERE MANUALLY!
       
  2088         if ( HandleBearerChangeIfNeededL( aApItem ) )
       
  2089             {
       
  2090             NeedManualUpdate = EFalse;
       
  2091             }
       
  2092         }
       
  2093     if ( NeedManualUpdate )
       
  2094         {
       
  2095         WriteIspDataL( aIsNew, aApItem.iIapServiceId, aApItem );
       
  2096         WriteNetworkDataL( aIsNew, aApItem );
       
  2097         WriteIapDataL( aIsNew, aApItem.iWapIap, aApItem );
       
  2098         WriteWapApDataL( aIsNew, aApItem.iWapUid, aApItem );
       
  2099         WriteWapBearerDataL( aIsNew, aApItem.iWapUid, aApItem );
       
  2100         if ( aApItem.HasProxy() )
       
  2101             {
       
  2102             WriteProxyDataL( aIsNew, aApItem );
       
  2103             }
       
  2104         else
       
  2105             {
       
  2106             if ( !aIsNew )
       
  2107                 {
       
  2108                 TRAP_IGNORE( RemoveProxyDataL( aApItem.iIapServiceType, 
       
  2109                                                aApItem.iIapServiceId ) );
       
  2110                 }
       
  2111             }
       
  2112         }
       
  2113 
       
  2114     CLOG( ( EHandler, 1, 
       
  2115         _L( "<- CApDataHandler::DoUpdateAccessPointDataL" ) ) );
       
  2116     return aApItem.iWapUid;
       
  2117     }
   516     }
  2118 
   517 
  2119 
   518 
  2120 
   519 
  2121 // ---------------------------------------------------------
   520 // ---------------------------------------------------------
  2122 // CApDataHandler::SetDefaultIapIspL
   521 // CApDataHandler::SetDefaultIapIspL
  2123 // ---------------------------------------------------------
   522 // ---------------------------------------------------------
  2124 //
   523 //
  2125 void CApDataHandler::SetDefaultIapIspL( TUint32 aUid )
   524 void CApDataHandler::SetDefaultIapIspL( TUint32 aUid )
  2126     {
   525     {
  2127     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::SetDefaultIapIspL" ) ) );
       
  2128     
       
  2129     CApAccessPointItem* ap = CApAccessPointItem::NewLC();
       
  2130     AccessPointDataL( aUid, *ap );
       
  2131     // Get IAP uid from aUid record
       
  2132     // ap.iWapIap
       
  2133     // Dial In or Dial Out?
       
  2134     // ap.iWapIspType
       
  2135     // store it accordingly
       
  2136     switch ( ap->BearerTypeL() )
       
  2137         {
       
  2138         case EApBearerTypeCSD:
       
  2139         case EApBearerTypeHSCSD:
       
  2140             {
       
  2141 //            iDb->SetGlobalSettingL( TPtrC(DIAL_OUT_IAP), ap->iWapIap );
       
  2142             SetPreferredIfDbIapTypeL
       
  2143                 ( 1,                                    // aRank,
       
  2144                   ECommDbConnectionDirectionOutgoing,   //aDirection,
       
  2145                   KCommDbBearerCSD,                     // aBearers,
       
  2146                   ECommDbDialogPrefDoNotPrompt,         //aPrompt,
       
  2147                   ap->iWapIap,                          //aIAP,
       
  2148                   ETrue                                 //aOverwrite
       
  2149                 );
       
  2150             break;
       
  2151             }
       
  2152         case EApBearerTypeGPRS:
       
  2153         case EApBearerTypeCDMA:
       
  2154             {
       
  2155             // Not applicable !
       
  2156             User::Leave( KErrArgument );
       
  2157             break;
       
  2158             }
       
  2159         default:
       
  2160             {
       
  2161             User::Leave( KErrInvalidIspRequest );
       
  2162             }
       
  2163         }
       
  2164     CleanupStack::PopAndDestroy( ap );    // ap
       
  2165 
       
  2166     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::SetDefaultIapIspL" ) ) );
       
  2167     }
   526     }
  2168 
   527 
  2169 
   528 
  2170 
   529 
  2171 
   530 
  2174 // CApDataHandler::RemoveWapBearerApL
   533 // CApDataHandler::RemoveWapBearerApL
  2175 // ---------------------------------------------------------
   534 // ---------------------------------------------------------
  2176 //
   535 //
  2177 void CApDataHandler::RemoveWapBearerApL( TUint32 aUid )
   536 void CApDataHandler::RemoveWapBearerApL( TUint32 aUid )
  2178     {
   537     {
  2179     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveWapBearerApL" ) ) );
       
  2180 
       
  2181     CCommsDbTableView* bearert;
       
  2182     bearert = iDb->OpenViewMatchingUintLC( TPtrC(WAP_IP_BEARER),
       
  2183                                    TPtrC(WAP_ACCESS_POINT_ID), aUid );
       
  2184 
       
  2185     TInt res = bearert->GotoFirstRecord();  // OK.
       
  2186     if ( res == KErrNone )
       
  2187         { // exists, delete it
       
  2188         User::LeaveIfError( bearert->DeleteRecord() );
       
  2189         }
       
  2190     else
       
  2191         {
       
  2192         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2193         // we are 'repairing it' this way.
       
  2194         if ( res != KErrNotFound )
       
  2195             {
       
  2196             User::LeaveIfError( res );
       
  2197             }
       
  2198         }
       
  2199     CleanupStack::PopAndDestroy( bearert ); // bearert
       
  2200 
       
  2201     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveWapBearerApL" ) ) );
       
  2202     }
   538     }
  2203 
   539 
  2204 
   540 
  2205 
   541 
  2206 // ---------------------------------------------------------
   542 // ---------------------------------------------------------
  2207 // CApDataHandler::RemoveWapApL
   543 // CApDataHandler::RemoveWapApL
  2208 // ---------------------------------------------------------
   544 // ---------------------------------------------------------
  2209 //
   545 //
  2210 void CApDataHandler::RemoveWapApL( TUint32 aUid )
   546 void CApDataHandler::RemoveWapApL( TUint32 aUid )
  2211     {
   547     {
  2212     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveWapApL" ) ) );
       
  2213 
       
  2214     CCommsDbTableView* wapt = iDb->OpenViewMatchingUintLC(
       
  2215                                         TPtrC(WAP_ACCESS_POINT),
       
  2216                                         TPtrC(COMMDB_ID), aUid );
       
  2217     TInt res = wapt->GotoFirstRecord(); // OK.
       
  2218     if ( res == KErrNone )
       
  2219         { // exists, delete it
       
  2220         User::LeaveIfError( wapt->DeleteRecord() );
       
  2221         }
       
  2222     else
       
  2223         {
       
  2224         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2225         // we are 'repairing it' this way.
       
  2226         if ( res != KErrNotFound )
       
  2227             {
       
  2228             User::Leave( res );
       
  2229             }
       
  2230         }
       
  2231     CleanupStack::PopAndDestroy( wapt ); // wapt
       
  2232 
       
  2233     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveWapApL" ) ) );
       
  2234     }
   548     }
  2235 
   549 
  2236 
   550 
  2237 // ---------------------------------------------------------
   551 // ---------------------------------------------------------
  2238 // CApDataHandler::RemoveIapL
   552 // CApDataHandler::RemoveIapL
  2239 // ---------------------------------------------------------
   553 // ---------------------------------------------------------
  2240 //
   554 //
  2241 void CApDataHandler::RemoveIapL( TUint32 aUid )
   555 void CApDataHandler::RemoveIapL( TUint32 aUid )
  2242     {
   556     {
  2243     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveIapL" ) ) );
       
  2244 
       
  2245     CCommsDbTableView* iapt;
       
  2246     iapt = iDb->OpenViewMatchingUintLC( TPtrC(IAP),
       
  2247                                    TPtrC(COMMDB_ID), aUid );
       
  2248     TInt res = iapt->GotoFirstRecord(); // OK.
       
  2249     if ( res == KErrNone )
       
  2250         { // exists, delete it
       
  2251         User::LeaveIfError( iapt->DeleteRecord() );
       
  2252         }
       
  2253     else
       
  2254         {
       
  2255         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2256         // we are 'repairing it' this way.
       
  2257         if ( res != KErrNotFound )
       
  2258             {
       
  2259             User::Leave( res );
       
  2260             }
       
  2261         }
       
  2262     CleanupStack::PopAndDestroy( iapt ); // iapt
       
  2263 
       
  2264     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveIapL" ) ) );
       
  2265     }
   557     }
  2266 
   558 
  2267 
   559 
  2268 
   560 
  2269 // ---------------------------------------------------------
   561 // ---------------------------------------------------------
  2270 // CApDataHandler::RemoveIspL
   562 // CApDataHandler::RemoveIspL
  2271 // ---------------------------------------------------------
   563 // ---------------------------------------------------------
  2272 //
   564 //
  2273 void CApDataHandler::RemoveIspL( TUint32 aUid, TBool aOut )
   565 void CApDataHandler::RemoveIspL( TUint32 aUid, TBool aOut )
  2274     {
   566     {
  2275     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveIspL" ) ) );
       
  2276 
       
  2277     CCommsDbTableView* ispt;
       
  2278     if ( aOut )
       
  2279         {
       
  2280         ispt = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_OUT_ISP),
       
  2281                                        TPtrC(COMMDB_ID), aUid );
       
  2282         }
       
  2283     else
       
  2284         {
       
  2285         ispt = iDb->OpenViewMatchingUintLC( TPtrC(DIAL_IN_ISP),
       
  2286                                        TPtrC(COMMDB_ID), aUid );
       
  2287         }
       
  2288 
       
  2289     TInt res = ispt->GotoFirstRecord(); // OK.
       
  2290     if ( res == KErrNone )
       
  2291         { // exists, delete it
       
  2292         User::LeaveIfError( ispt->DeleteRecord() );
       
  2293         }
       
  2294     else
       
  2295         {
       
  2296         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2297         // we are 'repairing it' this way.
       
  2298         if ( res != KErrNotFound )
       
  2299             {
       
  2300             User::Leave( res );
       
  2301             }
       
  2302         }
       
  2303     CleanupStack::PopAndDestroy( ispt ); // ispt
       
  2304 
       
  2305     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveIspL" ) ) );
       
  2306     }
   567     }
  2307 
   568 
  2308 
   569 
  2309 
   570 
  2310 // ---------------------------------------------------------
   571 // ---------------------------------------------------------
  2311 // CApDataHandler::RemoveGprsL
   572 // CApDataHandler::RemoveGprsL
  2312 // ---------------------------------------------------------
   573 // ---------------------------------------------------------
  2313 //
   574 //
  2314 void CApDataHandler::RemoveGprsL( TUint32 aUid, TBool aOut )
   575 void CApDataHandler::RemoveGprsL( TUint32 aUid, TBool aOut )
  2315     {
   576     {
  2316     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveGprsL" ) ) );
       
  2317 
       
  2318     CCommsDbTableView* table;
       
  2319     if ( aOut )
       
  2320         {
       
  2321         table = iDb->OpenViewMatchingUintLC( TPtrC(OUTGOING_WCDMA),
       
  2322                                        TPtrC(COMMDB_ID), aUid );
       
  2323         }
       
  2324     else
       
  2325         {
       
  2326         table = iDb->OpenViewMatchingUintLC( TPtrC(INCOMING_WCDMA),
       
  2327                                        TPtrC(COMMDB_ID), aUid );
       
  2328         }
       
  2329 
       
  2330     TInt res = table->GotoFirstRecord(); // O.K.
       
  2331     if ( res == KErrNone )
       
  2332         { // exists, delete it
       
  2333         User::LeaveIfError( table->DeleteRecord() );
       
  2334         }
       
  2335     else
       
  2336         {
       
  2337         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2338         // we are 'repairing it' this way.
       
  2339         if ( res != KErrNotFound )
       
  2340             {
       
  2341             User::Leave( res );
       
  2342             }
       
  2343         }
       
  2344 
       
  2345     CleanupStack::PopAndDestroy( table ); // table
       
  2346 
       
  2347     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveGprsL" ) ) );
       
  2348     }
   577     }
  2349 
   578 
  2350 
   579 
  2351 // ---------------------------------------------------------
   580 // ---------------------------------------------------------
  2352 // CApDataHandler::RemoveLanL
   581 // CApDataHandler::RemoveLanL
  2353 // ---------------------------------------------------------
   582 // ---------------------------------------------------------
  2354 //
   583 //
  2355 void CApDataHandler::RemoveLanL( TUint32 aUid )
   584 void CApDataHandler::RemoveLanL( TUint32 aUid )
  2356     {
   585     {
  2357     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveLanL" ) ) );
       
  2358 
       
  2359     CCommsDbTableView* table = iDb->OpenViewMatchingUintLC
       
  2360         ( TPtrC(LAN_SERVICE), TPtrC(COMMDB_ID), aUid );
       
  2361 
       
  2362     TInt res = table->GotoFirstRecord(); // O.K.
       
  2363     if ( res == KErrNone )
       
  2364         { // exists, delete it
       
  2365         User::LeaveIfError( table->DeleteRecord() );
       
  2366         }
       
  2367     else
       
  2368         {
       
  2369         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  2370         // we are 'repairing it' this way.
       
  2371         if ( res != KErrNotFound )
       
  2372             {
       
  2373             User::Leave( res );
       
  2374             }
       
  2375         }
       
  2376     CleanupStack::PopAndDestroy( table ); // table
       
  2377     
       
  2378     // try to remove WLAN part, if it has any
       
  2379     // TRAP and ignore if not found
       
  2380     TRAP( res, RemoveWlanL( aUid ) );
       
  2381     if ( res != KErrNotFound )
       
  2382         {
       
  2383         User::LeaveIfError( res );
       
  2384         }
       
  2385 
       
  2386     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveLanL" ) ) );
       
  2387     }
   586     }
  2388 
   587 
  2389 
   588 
  2390 
   589 
  2391 // ---------------------------------------------------------
   590 // ---------------------------------------------------------
  2392 // CApDataHandler::RemoveWlanL
   591 // CApDataHandler::RemoveWlanL
  2393 // ---------------------------------------------------------
   592 // ---------------------------------------------------------
  2394 //
   593 //
  2395 void CApDataHandler::RemoveWlanL( TUint32 aUid )
   594 void CApDataHandler::RemoveWlanL( TUint32 aUid )
  2396     {
   595     {
  2397     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveWlanL - ERROR: not suported" ) ) );
       
  2398     User::Leave( KErrNotSupported );
   596     User::Leave( KErrNotSupported );
  2399     }
   597     }
  2400 
   598 
  2401 
   599 
  2402 
   600 
  2405 // ---------------------------------------------------------
   603 // ---------------------------------------------------------
  2406 //
   604 //
  2407 TBool CApDataHandler::HandleBearerChangeIfNeededL
   605 TBool CApDataHandler::HandleBearerChangeIfNeededL
  2408                                     ( CApAccessPointItem& aApItem )
   606                                     ( CApAccessPointItem& aApItem )
  2409     {
   607     {
  2410     CLOG( ( EHandler, 0, 
   608     return EFalse;
  2411         _L( "-> CApDataHandler::HandleBearerChangeIfNeededL" ) ) );
       
  2412 
       
  2413     TApBearerType anew = aApItem.BearerTypeL();
       
  2414 
       
  2415     CApUtils* au = CApUtils::NewLC( *iDb );
       
  2416     TApBearerType aold = au->BearerTypeL( aApItem.iWapUid );
       
  2417     // if different WAP_Bearer table, OR different IAP_SERVICE table,
       
  2418     // delete old ones and save current as NEW records
       
  2419     // under the SAME iWapUid !
       
  2420 
       
  2421     TBool retval( EFalse );
       
  2422     if ( ( aold != anew ) &&
       
  2423         !(
       
  2424            (( aold == EApBearerTypeHSCSD ) && ( anew == EApBearerTypeCSD ) )
       
  2425            ||
       
  2426            ( ( aold == EApBearerTypeCSD ) && ( anew == EApBearerTypeHSCSD ) )
       
  2427          )
       
  2428         )
       
  2429         {// different bearers!
       
  2430         HBufC* buf = HBufC::NewLC( KModifiableTextLength );
       
  2431         TPtr ptr( buf->Des() );
       
  2432         au->WapBearerTypeL( aApItem.iWapUid, ptr );
       
  2433 
       
  2434         CApAccessPointItem* apitem = CApAccessPointItem::NewLC();
       
  2435         AccessPointDataL( aApItem.iWapUid, *apitem );
       
  2436 
       
  2437         if ( *aApItem.iWapBearer != ptr )
       
  2438             {
       
  2439             // if different WAP_Bearer table, delete old wap_bearer
       
  2440             // & if needed, IAP, ISP, GPRS, CDMA, too
       
  2441             //  and Crete new wap bearer & if needed, IAP, ISP, GPRS, CDMA, too
       
  2442             if ( *apitem->iWapBearer == TPtrC(WAP_IP_BEARER) )
       
  2443                 {
       
  2444                 // e.g.:RemoveIpBearer(iIapServiceType, iIapServiceId,
       
  2445                 //                     iWapIap )
       
  2446                 if ( ( *apitem->iIapServiceType == TPtrC(DIAL_OUT_ISP) )
       
  2447                     || ( *apitem->iIapServiceType == TPtrC(DIAL_IN_ISP) ) )
       
  2448                     { // ISP
       
  2449                     RemoveIspL( apitem->iIapServiceId,
       
  2450                         ( *apitem->iIapServiceType == TPtrC(DIAL_OUT_ISP) ) );
       
  2451                     }
       
  2452                 else if( ( *apitem->iIapServiceType ==
       
  2453                                         TPtrC(OUTGOING_WCDMA) )
       
  2454                         || ( *apitem->iIapServiceType ==
       
  2455                                         TPtrC(INCOMING_WCDMA) ) )
       
  2456                     {// Gprs
       
  2457                     RemoveGprsL( apitem->iIapServiceId,
       
  2458                         ( *apitem->iIapServiceType == 
       
  2459                                 TPtrC(OUTGOING_WCDMA) ) );
       
  2460                     }
       
  2461                 else
       
  2462                     {
       
  2463                     // check if WLAN
       
  2464                     if ( aApItem.iExt->iWlanData )
       
  2465                         {
       
  2466                         RemoveLanL( apitem->iIapServiceId );
       
  2467                         }
       
  2468                     else
       
  2469                         {                            
       
  2470                         // no leave on else Unknown, as we are deleting 
       
  2471                         // so silently ignore the error...
       
  2472                         }
       
  2473                     }
       
  2474                 RemoveIapL( apitem->iWapIap );
       
  2475                 RemoveWapBearerApL( aApItem.iWapUid );
       
  2476                 }
       
  2477             else
       
  2478                 { // SMS
       
  2479                 User::Leave( KErrInvalidBearerType );
       
  2480                 }
       
  2481             RemoveProxyDataL( apitem->iIapServiceType, apitem->iIapServiceId );
       
  2482             WriteIspDataL( ETrue, aApItem.iIapServiceId, aApItem );
       
  2483             WriteIapDataL( ETrue, aApItem.iWapIap, aApItem );
       
  2484 
       
  2485             // gets the UID needed for Bearer table
       
  2486             WriteWapApDataL( EFalse, aApItem.iWapUid, aApItem );
       
  2487             // needs new bearer record
       
  2488             WriteWapBearerDataL( ETrue, aApItem.iWapUid, aApItem );
       
  2489             if ( aApItem.HasProxy() )
       
  2490                 {
       
  2491                 WriteProxyDataL( ETrue, aApItem );
       
  2492                 }
       
  2493             }
       
  2494         else
       
  2495             { // bearer table is same, but IAP_SERVICE is different
       
  2496             if ( ( aold == EApBearerTypeHSCSD ) ||
       
  2497                  ( aold == EApBearerTypeCSD ) )
       
  2498                 {
       
  2499                 RemoveIspL( apitem->iIapServiceId,
       
  2500                     ( *apitem->iIapServiceType == TPtrC(DIAL_OUT_ISP) ) );
       
  2501                 }
       
  2502             else if ( ( *apitem->iIapServiceType ==
       
  2503                                         TPtrC(OUTGOING_WCDMA) )
       
  2504                      || ( *apitem->iIapServiceType ==
       
  2505                                         TPtrC(INCOMING_WCDMA) ) )
       
  2506                 {
       
  2507                 RemoveGprsL( apitem->iIapServiceId,
       
  2508                     ( *apitem->iIapServiceType == TPtrC(OUTGOING_WCDMA) ) );
       
  2509                 }
       
  2510             else 
       
  2511                 {
       
  2512                 // check if WLAN
       
  2513                 if ( aApItem.iExt->iWlanData )
       
  2514                     {
       
  2515                     RemoveLanL( apitem->iIapServiceId );
       
  2516                     }
       
  2517                 else
       
  2518                     {
       
  2519                     // no leave on else Unknown, as we are deleting 
       
  2520                     // so silently ignore the error...
       
  2521                     }
       
  2522                 }
       
  2523             RemoveProxyDataL( apitem->iIapServiceType, apitem->iIapServiceId );
       
  2524             WriteIspDataL( ETrue, aApItem.iIapServiceId, aApItem );
       
  2525             WriteIapDataL( EFalse, aApItem.iWapIap, aApItem );
       
  2526             // gets the UID needed for Bearer table
       
  2527             WriteWapApDataL( EFalse, aApItem.iWapUid, aApItem );
       
  2528             WriteWapBearerDataL( EFalse, aApItem.iWapUid, aApItem );
       
  2529             if ( aApItem.HasProxy() )
       
  2530                 {
       
  2531                 WriteProxyDataL( ETrue, aApItem );
       
  2532                 }
       
  2533             }
       
  2534         CleanupStack::PopAndDestroy( 2, buf ); // apitem, buf
       
  2535         retval = ETrue;
       
  2536         }
       
  2537     CleanupStack::PopAndDestroy( au ); // au
       
  2538     // additional code for managing bearer-change ends here...
       
  2539 
       
  2540     CLOG( ( EHandler, 1, 
       
  2541         _L( "<- CApDataHandler::HandleBearerChangeIfNeededL" ) ) );
       
  2542     return retval;
       
  2543     }
   609     }
  2544 
   610 
  2545 
   611 
  2546 
   612 
  2547 
   613 
  2551 // ---------------------------------------------------------
   617 // ---------------------------------------------------------
  2552 //
   618 //
  2553 void CApDataHandler::DoAccessPointDataL( TUint32 aUid,
   619 void CApDataHandler::DoAccessPointDataL( TUint32 aUid,
  2554                                          CApAccessPointItem& aApItem )
   620                                          CApAccessPointItem& aApItem )
  2555     {
   621     {
  2556     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DoAccessPointDataL" ) ) );
       
  2557 
       
  2558     ReadWapDataL( aUid, aApItem );
       
  2559 
       
  2560     if ( *aApItem.iWapBearer == TPtrC(WAP_IP_BEARER) )
       
  2561         {
       
  2562         ReadIapDataL( aApItem.iWapIap, aApItem );
       
  2563         ReadNetworkDataL( aApItem );
       
  2564         ReadIspDataL( aApItem.iIapServiceId, aApItem );
       
  2565         }
       
  2566     ReadProxyDataL( aApItem );
       
  2567 
       
  2568     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DoAccessPointDataL" ) ) );
       
  2569     }
   622     }
  2570 
   623 
  2571 
   624 
  2572 // ---------------------------------------------------------
   625 // ---------------------------------------------------------
  2573 // CApDataHandler::DoRemoveAPL
   626 // CApDataHandler::DoRemoveAPL
  2574 // ---------------------------------------------------------
   627 // ---------------------------------------------------------
  2575 //
   628 //
  2576 void CApDataHandler::DoRemoveAPL( TUint32 aUid )
   629 void CApDataHandler::DoRemoveAPL( TUint32 aUid )
  2577     {
   630     {
  2578     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DoRemoveAPL" ) ) );
       
  2579 
       
  2580     CApUtils* utils = CApUtils::NewLC( *iDb );
       
  2581     if ( utils->IsAPInUseL( aUid ) )
       
  2582         {
       
  2583         User::Leave( KErrInUse );
       
  2584         }
       
  2585     CleanupStack::PopAndDestroy( utils );   // utils
       
  2586 
       
  2587     CCommsDbTableView* wapt;
       
  2588     wapt = iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
       
  2589                                        TPtrC(COMMDB_ID), aUid );
       
  2590     User::LeaveIfError( wapt->GotoFirstRecord() );
       
  2591     HBufC* buf = HBufC::NewLC( KCommsDbSvrMaxFieldLength );
       
  2592     TPtr ptr( buf->Des() );
       
  2593     wapt->ReadTextL( TPtrC(WAP_CURRENT_BEARER),
       
  2594                      ptr ); // see declaration for comments!
       
  2595 
       
  2596     if ( *buf == TPtrC(WAP_IP_BEARER) )
       
  2597         {
       
  2598         // get serviceType
       
  2599         CCommsDbTableView* bearert;
       
  2600         bearert = iDb->OpenViewMatchingUintLC( TPtrC(WAP_IP_BEARER),
       
  2601                                                TPtrC(WAP_ACCESS_POINT_ID),
       
  2602                                                aUid );
       
  2603 
       
  2604         User::LeaveIfError( bearert->GotoFirstRecord() );
       
  2605         TUint32 iapid;
       
  2606         ApCommons::ReadUintL( bearert, TPtrC(WAP_IAP), iapid );
       
  2607 
       
  2608         CCommsDbTableView* iapt;
       
  2609         iapt = iDb->OpenViewMatchingUintLC( TPtrC(IAP), TPtrC(COMMDB_ID),
       
  2610                                             iapid );
       
  2611 
       
  2612         User::LeaveIfError( iapt->GotoFirstRecord() );
       
  2613         HBufC* servicetype = HBufC::NewLC( KCommsDbSvrMaxFieldLength );
       
  2614         TPtr servptr( servicetype->Des() );
       
  2615         iapt->ReadTextL( TPtrC(IAP_SERVICE_TYPE), servptr );
       
  2616         TUint32 ispid;
       
  2617         iapt->ReadUintL( TPtrC(IAP_SERVICE), ispid );
       
  2618         TUint32 networkid;
       
  2619         iapt->ReadUintL( TPtrC(IAP_NETWORK), networkid );
       
  2620         RemoveNetworkDataL( networkid );
       
  2621         if ( ( *servicetype == TPtrC(DIAL_OUT_ISP) ) ||
       
  2622              ( *servicetype == TPtrC(DIAL_IN_ISP) ) )
       
  2623             { // ISP
       
  2624             RemoveIspL( ispid, ( *servicetype == TPtrC(DIAL_OUT_ISP)) );
       
  2625             RemoveIapL( iapid );
       
  2626             }
       
  2627         else
       
  2628             { // Gprs
       
  2629             if ( ( *servicetype == TPtrC(OUTGOING_WCDMA) ) ||
       
  2630                  ( *servicetype == TPtrC(INCOMING_WCDMA) ) )
       
  2631                 {
       
  2632                 RemoveGprsL( ispid, ( *servicetype == TPtrC(OUTGOING_WCDMA)) );
       
  2633                 RemoveIapL( iapid );
       
  2634                 }
       
  2635             else
       
  2636                 { 
       
  2637                 if ( *servicetype ==TPtrC(LAN_SERVICE) )
       
  2638                     {
       
  2639                     // LAN, WLAN
       
  2640                     RemoveLanL( ispid );
       
  2641                     RemoveIapL( iapid );
       
  2642                     }
       
  2643                 else
       
  2644                     {
       
  2645                     // VPN...
       
  2646                     }
       
  2647                 }
       
  2648             }
       
  2649         RemoveProxyDataL( servicetype, ispid );
       
  2650         RemoveWapBearerApL( aUid );
       
  2651         CleanupStack::PopAndDestroy( 3, bearert ); // servicetype,iapt,bearert
       
  2652         }
       
  2653     else
       
  2654         { // sms,
       
  2655         User::Leave( KErrInvalidBearerType );
       
  2656         }
       
  2657 
       
  2658     RemoveWapApL( aUid );
       
  2659 
       
  2660     CleanupStack::PopAndDestroy( 2, wapt );   // buf, wapt
       
  2661 
       
  2662     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DoRemoveAPL" ) ) );
       
  2663     }
   631     }
  2664 
   632 
  2665 
   633 
  2666 
   634 
  2667 // ---------------------------------------------------------
   635 // ---------------------------------------------------------
  2669 // ---------------------------------------------------------
   637 // ---------------------------------------------------------
  2670 //
   638 //
  2671 void CApDataHandler::DoSetAsDefaultL( TUint32 aUid,
   639 void CApDataHandler::DoSetAsDefaultL( TUint32 aUid,
  2672                                       TCommsDbIspType aIntendedType )
   640                                       TCommsDbIspType aIntendedType )
  2673     {
   641     {
  2674     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DoSetAsDefaultL" ) ) );
       
  2675 
       
  2676     // Due to changes in the database, ONLY WAP_ACCESS_POINT_ID
       
  2677     switch ( aIntendedType )
       
  2678         {
       
  2679         case EIspTypeInternetOnly:
       
  2680             {
       
  2681             SetDefaultIapIspL( aUid );
       
  2682             break;
       
  2683             }
       
  2684         case EIspTypeWAPOnly:
       
  2685             {
       
  2686             iDb->SetGlobalSettingL( TPtrC(WAP_ACCESS_POINT), aUid );
       
  2687             break;
       
  2688             }
       
  2689         case EIspTypeInternetAndWAP:
       
  2690             {
       
  2691             iDb->SetGlobalSettingL( TPtrC(WAP_ACCESS_POINT), aUid );
       
  2692             SetDefaultIapIspL( aUid );
       
  2693             break;
       
  2694             }
       
  2695         default :
       
  2696             {
       
  2697             __ASSERT_DEBUG( EFalse, User::Panic( KErrInvalidIntendedType,
       
  2698                                                  aIntendedType ) );
       
  2699             break;
       
  2700             }
       
  2701         }
       
  2702 
       
  2703     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DoSetAsDefaultL" ) ) );
       
  2704     }
   642     }
  2705 
   643 
  2706 
   644 
  2707 
   645 
  2708 // ---------------------------------------------------------
   646 // ---------------------------------------------------------
  2716                                  TCommDbDialogPref aPrompt,
   654                                  TCommDbDialogPref aPrompt,
  2717                                  TUint32 aIAP,
   655                                  TUint32 aIAP,
  2718                                  TBool aOverwrite
   656                                  TBool aOverwrite
  2719                                     )
   657                                     )
  2720     {
   658     {
  2721     CLOG( ( EHandler, 0, 
       
  2722         _L( "-> CApDataHandler::DoSetPreferredIfDbIapTypeL" ) ) );
       
  2723 
       
  2724     CCommsDbConnectionPrefTableView* preft =
       
  2725              iDb->OpenConnectionPrefTableViewOnRankLC( aDirection, aRank );
       
  2726     if ( aOverwrite )
       
  2727         {
       
  2728         TInt res = preft->GotoFirstRecord(); // OK.
       
  2729         if ( res == KErrNone )
       
  2730             { // already exists, delete original and store the new one...
       
  2731             preft->DeleteConnectionPreferenceL();
       
  2732             }
       
  2733         else
       
  2734             {
       
  2735             // silently ignore KErrNotFound.
       
  2736             // It is not an error in this case.
       
  2737             if ( res != KErrNotFound )
       
  2738                 {
       
  2739                 User::Leave( res );
       
  2740                 }
       
  2741             }
       
  2742         }
       
  2743     CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
       
  2744     pref.iRanking = aRank;
       
  2745     pref.iBearer.iBearerSet = aBearers;
       
  2746     pref.iDialogPref = aPrompt;
       
  2747     pref.iBearer.iIapId = aIAP;
       
  2748     pref.iDirection = aDirection;
       
  2749     preft->InsertConnectionPreferenceL( pref );
       
  2750     CleanupStack::PopAndDestroy( preft ); // preft
       
  2751 
       
  2752     CLOG( ( EHandler, 1, 
       
  2753         _L( "<- CApDataHandler::DoSetPreferredIfDbIapTypeL" ) ) );
       
  2754     }
   659     }
  2755 
   660 
  2756 
   661 
  2757 
   662 
  2758 // ---------------------------------------------------------
   663 // ---------------------------------------------------------
  2768                                  TUint32 /*aChargeCard*/,
   673                                  TUint32 /*aChargeCard*/,
  2769                                  const TDesC& /*aServiceType*/,
   674                                  const TDesC& /*aServiceType*/,
  2770                                  TBool /*aOverwrite*/
   675                                  TBool /*aOverwrite*/
  2771                                     )
   676                                     )
  2772     {
   677     {
  2773     /*
       
  2774     DEPRECATED!!!
       
  2775     */
       
  2776     CLOG( ( EHandler, 0, 
       
  2777         _L( "<-> CApDataHandler::DoSetPreferredIfDbIspTypeL" ) ) );
       
  2778 
       
  2779     User::Leave( KErrNotSupported );
   678     User::Leave( KErrNotSupported );
  2780     }
   679     }
  2781 
   680 
  2782 
   681 
  2783 
   682 
  2785 // CApDataHandler::ApSpeed2EtelL
   684 // CApDataHandler::ApSpeed2EtelL
  2786 // ---------------------------------------------------------
   685 // ---------------------------------------------------------
  2787 //
   686 //
  2788 void CApDataHandler::ApSpeed2EtelL( CApAccessPointItem* aItem )
   687 void CApDataHandler::ApSpeed2EtelL( CApAccessPointItem* aItem )
  2789     {
   688     {
  2790     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ApSpeed2EtelL" ) ) );
       
  2791     
       
  2792     __ASSERT_DEBUG( (aItem), ApCommons::Panic( ENullPointer ) ) ;
       
  2793     
       
  2794     /*****************************************************
       
  2795     *   Series 60 Customer / ETel
       
  2796     *   Series 60  ETel API
       
  2797     *****************************************************/
       
  2798     
       
  2799     TInt bear = CSD;
       
  2800     switch ( aItem->BearerTypeL() )
       
  2801         {
       
  2802         case EApBearerTypeCSD:
       
  2803             {
       
  2804             // search for (CSD, x, x)
       
  2805             bear = CSD;
       
  2806             break;
       
  2807             }
       
  2808         case EApBearerTypeHSCSD:
       
  2809             {
       
  2810             // HSCSD
       
  2811             // search for (HCSD, x, x)
       
  2812             bear = HSCSD;
       
  2813             break;
       
  2814             }
       
  2815         default:
       
  2816             {
       
  2817             // it is called only for CSD/HSCSD bearers, but to be sure...
       
  2818             __ASSERT_DEBUG( EFalse, ApCommons::Panic( ENotSupported ) ) ;
       
  2819             User::Leave( KErrInvalidBearerType );
       
  2820             break;
       
  2821             }
       
  2822         }
       
  2823     
       
  2824     TInt type = Analogue;
       
  2825     switch ( aItem->iBearerCallTypeIsdn )
       
  2826         {
       
  2827         case ECallTypeAnalogue:
       
  2828             {
       
  2829             type = Analogue;
       
  2830             break;
       
  2831             }
       
  2832         case ECallTypeISDNv110:
       
  2833             {
       
  2834             type = V110;
       
  2835             break;
       
  2836             }
       
  2837         case ECallTypeISDNv120:
       
  2838             {
       
  2839             type = V120;
       
  2840             break;
       
  2841             }
       
  2842         default:
       
  2843             {
       
  2844             // it has only 3 states, but to be sure...
       
  2845             __ASSERT_DEBUG( EFalse, ApCommons::Panic( EInvalidSpeed ) ) ;
       
  2846             User::Leave( KErrInvalidBearerType );
       
  2847             break;            
       
  2848             }
       
  2849         }
       
  2850         
       
  2851     TBool found(EFalse);
       
  2852     // just get count once...
       
  2853     TInt count = sizeof(SpeedData)/sizeof(SpeedData[0]);    
       
  2854     
       
  2855     for( TInt i=0; i<count; i++)
       
  2856         {
       
  2857         if ( ( SpeedData[i][0] == bear ) 
       
  2858             && ( SpeedData[i][1] == type ) 
       
  2859             && ( SpeedData[i][2] == aItem->iMaxConnSpeed ) )
       
  2860             {
       
  2861             // wwe found it, get values, break
       
  2862             // Bearer_name, Bearer speed, Bearer_ce, Bearer_type
       
  2863             aItem->WriteUint( EApIspBearerName, SpeedData[i][3] );
       
  2864             aItem->iExt->iBearerSpeed = SpeedData[i][4];
       
  2865             aItem->WriteUint( EApIspBearerCE, SpeedData[i][5] );
       
  2866             aItem->WriteUint( EApIspBearerType, SpeedData[i][6] );
       
  2867             
       
  2868             
       
  2869             // Channel coding, Aiur, Req.Slot, MaxSlot, 
       
  2870             aItem->WriteUint( EApIspChannelCoding, SpeedData[i][7] );
       
  2871             aItem->WriteUint( EApIspAIUR, SpeedData[i][8] );
       
  2872             aItem->WriteUint( EApIspRequestedTimeSlots, SpeedData[i][9] );
       
  2873             aItem->WriteUint( EApIspMaximumTimeSlots, SpeedData[i][10] );
       
  2874             
       
  2875             // Bearer_service, Bearer_Protocol
       
  2876             aItem->WriteUint( EApIapBearerService, SpeedData[i][11] );
       
  2877             aItem->iExt->iBearerProtocol = SpeedData[i][12];
       
  2878 
       
  2879             i = count;
       
  2880             found = ETrue;
       
  2881             }
       
  2882         }
       
  2883     if ( !found )
       
  2884         {
       
  2885         // if not found, someone set an invalid speed in the engine
       
  2886         // which already should have been checked, 
       
  2887         // just to be on the sure side
       
  2888         __ASSERT_DEBUG( EFalse, ApCommons::Panic( EInvalidSpeed ) ) ;
       
  2889         User::Leave(KErrNotFound);
       
  2890         }
       
  2891 
       
  2892     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ApSpeed2EtelL" ) ) );
       
  2893     }
   689     }
  2894 
   690 
  2895 
   691 
  2896 
   692 
  2897 // ---------------------------------------------------------
   693 // ---------------------------------------------------------
  2898 // CApDataHandler::EtelSpeed2ApL
   694 // CApDataHandler::EtelSpeed2ApL
  2899 // ---------------------------------------------------------
   695 // ---------------------------------------------------------
  2900 //
   696 //
  2901 void CApDataHandler::EtelSpeed2ApL( CApAccessPointItem& aItem )
   697 void CApDataHandler::EtelSpeed2ApL( CApAccessPointItem& aItem )
  2902     {
   698     {
  2903     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::EtelSpeed2ApL" ) ) );
       
  2904 
       
  2905     // ************* ALERT ***************
       
  2906     // We utilise the fact that this is called right after the data 
       
  2907     // had been read from the DB and the 
       
  2908     // aItem.iMaxConnSpeed and aItem.iBearerCallTypeIsdn members 
       
  2909     // are holding the CommsDb style values.
       
  2910     // now we are converting it to our style as the API is fixed
       
  2911     // and so are the used enums...
       
  2912 
       
  2913     /*****************************************************
       
  2914     *   Series 60 Customer / ETel
       
  2915     *   Series 60  ETel API
       
  2916     *****************************************************/
       
  2917 
       
  2918     TBool found(EFalse);
       
  2919     // just get count once...
       
  2920     TInt count = sizeof(SpeedData)/sizeof(SpeedData[0]);    
       
  2921     
       
  2922     for( TInt i=0; i<count; i++)
       
  2923         {
       
  2924         if ( ( SpeedData[i][3] == aItem.iIspBearerName )
       
  2925             && ( SpeedData[i][4] == aItem.iExt->iBearerSpeed )
       
  2926             && ( SpeedData[i][5] == aItem.iIspBearerCE )
       
  2927             && ( SpeedData[i][6] == aItem.iIspBearerType )
       
  2928             && ( SpeedData[i][7] == aItem.iIspChannelCoding )
       
  2929             && ( SpeedData[i][8] == aItem.iIspAIUR )
       
  2930             && ( SpeedData[i][9] == aItem.iIspRequestedTimeSlots )
       
  2931             && ( SpeedData[i][10] == aItem.iIspMaximumTimeSlots )
       
  2932             && ( SpeedData[i][11] == aItem.iApIapBearerService )
       
  2933             && ( SpeedData[i][12] == aItem.iExt->iBearerProtocol ) )
       
  2934             {
       
  2935             // we found it, get values, break
       
  2936             switch ( SpeedData[i][0] )
       
  2937                 { 
       
  2938                 case CSD:
       
  2939                     {
       
  2940                     aItem.iIspBearerType = EBearerTypeCSD;
       
  2941                     break;
       
  2942                     }
       
  2943                 case HSCSD:
       
  2944                     {
       
  2945                     aItem.iIspBearerType = EBearerTypeHSCSD;
       
  2946                     break;            
       
  2947                     }
       
  2948                 default:
       
  2949                     { // incorrect db, repair...
       
  2950                     aItem.iIspBearerType = EBearerTypeCSD;
       
  2951                     break;
       
  2952                     }
       
  2953                 }
       
  2954 
       
  2955             
       
  2956             switch ( SpeedData[i][1])
       
  2957                 {
       
  2958                 case Analogue:
       
  2959                     {
       
  2960                     aItem.iBearerCallTypeIsdn = ECallTypeAnalogue;
       
  2961                     break;
       
  2962                     }
       
  2963                 case V110:
       
  2964                     {
       
  2965                     aItem.iBearerCallTypeIsdn = ECallTypeISDNv110;
       
  2966                     break;
       
  2967                     }
       
  2968                 case V120: 
       
  2969                     {
       
  2970                     aItem.iBearerCallTypeIsdn = ECallTypeISDNv120;
       
  2971                     break;
       
  2972                     }                    
       
  2973                 default:
       
  2974                     {
       
  2975                     // incorrect db, repair...
       
  2976                     aItem.iBearerCallTypeIsdn = ECallTypeAnalogue;
       
  2977                     break;
       
  2978                     }
       
  2979                 }
       
  2980             
       
  2981             aItem.iMaxConnSpeed = TApCallSpeed(SpeedData[i][2]);
       
  2982             i = count;
       
  2983             found = ETrue;
       
  2984             }
       
  2985         }
       
  2986     if ( !found )
       
  2987         {
       
  2988         // if not found, someone set an invalid speed in the engine
       
  2989         // which already should have been checked, 
       
  2990         // just to be on the sure side
       
  2991         __ASSERT_DEBUG( EFalse, ApCommons::Panic( EInvalidSpeed ) ) ;
       
  2992         User::Leave(KErrNotFound);
       
  2993         }
       
  2994   
       
  2995     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::EtelSpeed2ApL" ) ) );
       
  2996 
       
  2997     }
   699     }
  2998 
   700 
  2999 
   701 
  3000 
   702 
  3001 // Getting default access point
   703 // Getting default access point
  3004 // ---------------------------------------------------------
   706 // ---------------------------------------------------------
  3005 //
   707 //
  3006 TUint32 CApDataHandler::DoGetDefaultL( TBool aIsWap,
   708 TUint32 CApDataHandler::DoGetDefaultL( TBool aIsWap,
  3007                                              TBool* aReadOnly ) const
   709                                              TBool* aReadOnly ) const
  3008     { // client MUST initiate a transaction, we will NOT !
   710     { // client MUST initiate a transaction, we will NOT !
  3009     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::DoGetDefaultL" ) ) );
   711     return KErrNotSupported;
  3010 
       
  3011     TUint32 value( KErrNone );
       
  3012     if ( aIsWap )
       
  3013         {
       
  3014         iDb->GetGlobalSettingL( TPtrC(WAP_ACCESS_POINT), value );
       
  3015         }
       
  3016     else
       
  3017         { 
       
  3018         TUint32 tmp( 0 );
       
  3019         // CONST_CAST added later, originally used other code, 
       
  3020         // when moved to 2.0, support was removed and needed 
       
  3021         // to use own (non-const)
       
  3022         // method which can not be made const as it is part of the public API
       
  3023         CONST_CAST( CApDataHandler*, this )->GetPreferredIfDbIapTypeL
       
  3024             ( 1, // Rank
       
  3025               ECommDbConnectionDirectionOutgoing,
       
  3026               tmp,    // aBearers,
       
  3027               tmp,    // aPrompt,
       
  3028               value   // aIAP
       
  3029             );
       
  3030         }
       
  3031 
       
  3032     if ( aReadOnly )
       
  3033         { // get read-only flag for an AP
       
  3034         CCommsDbTableView* wapt =
       
  3035                 iDb->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
       
  3036                                              TPtrC(COMMDB_ID), value);
       
  3037         User::LeaveIfError( wapt->GotoFirstRecord() );
       
  3038         *aReadOnly = ApCommons::DoGetReadOnlyL( *wapt );
       
  3039         CleanupStack::PopAndDestroy( wapt );
       
  3040         }
       
  3041     
       
  3042     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::DoGetDefaultL" ) ) );
       
  3043     return value;
       
  3044     }
   712     }
  3045 
   713 
  3046 
   714 
  3047 // ---------------------------------------------------------
   715 // ---------------------------------------------------------
  3048 // CApDataHandler::WriteProxyDataL
   716 // CApDataHandler::WriteProxyDataL
  3049 // ---------------------------------------------------------
   717 // ---------------------------------------------------------
  3050 //
   718 //
  3051 void CApDataHandler::WriteProxyDataL( TBool aIsNew, 
   719 void CApDataHandler::WriteProxyDataL( TBool aIsNew, 
  3052                                       const CApAccessPointItem& aApItem )
   720                                       const CApAccessPointItem& aApItem )
  3053     {
   721     {
  3054     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteProxyDataL" ) ) );
       
  3055 
       
  3056     CCommsDbTableView* proxies;
       
  3057     if ( aIsNew )
       
  3058         {
       
  3059         proxies = iDb->OpenTableLC( TPtrC(PROXIES) );
       
  3060         // variable needed just to be able to make the call...
       
  3061         TUint32 dummy;
       
  3062         User::LeaveIfError( proxies->InsertRecord( dummy ) );
       
  3063         }
       
  3064     else
       
  3065         {
       
  3066         // Add test cases covering this route
       
  3067         proxies = iDb->OpenViewMatchingTextLC( TPtrC(PROXIES), 
       
  3068                                                TPtrC(PROXY_SERVICE_TYPE),
       
  3069                                                *aApItem.iIapServiceType );
       
  3070         TInt err = proxies->GotoFirstRecord();
       
  3071         if ( err == KErrNotFound )
       
  3072             { // originally there were NO proxy, but now it is added
       
  3073             // variable needed just to be able to make the call...
       
  3074             // Add test cases covering this route
       
  3075             TUint32 dummy;
       
  3076             User::LeaveIfError( proxies->InsertRecord( dummy ) );
       
  3077             }
       
  3078         else
       
  3079             {
       
  3080             // Add test cases covering this route
       
  3081             // now check if we have our record
       
  3082             TUint32 uval;
       
  3083             TBool found( EFalse );
       
  3084             do
       
  3085                 {
       
  3086                 // Add test cases covering this route
       
  3087                 proxies->ReadUintL( TPtrC(PROXY_ISP), uval );
       
  3088                 if ( uval == aApItem.iIapServiceId )
       
  3089                     {
       
  3090                     found = ETrue;
       
  3091                     }
       
  3092                 else
       
  3093                     {
       
  3094                     err = proxies->GotoNextRecord();
       
  3095                     }
       
  3096                 } while ( (!err) && (!found) );
       
  3097             if ( !found )
       
  3098                 { // no proxy record, add it now
       
  3099                 // variable needed just to be able to make the call...
       
  3100                 TUint32 dummy;
       
  3101                 User::LeaveIfError( proxies->InsertRecord( dummy ) );
       
  3102                 }
       
  3103             else
       
  3104                 { // we found our proxy, use it...
       
  3105                 User::LeaveIfError( proxies->UpdateRecord() );
       
  3106                 }
       
  3107             }
       
  3108         }
       
  3109     proxies->WriteUintL( TPtrC(PROXY_ISP), aApItem.iIapServiceId );
       
  3110     proxies->WriteTextL( TPtrC(PROXY_SERVICE_TYPE),
       
  3111                          *aApItem.iIapServiceType );
       
  3112 
       
  3113 
       
  3114     proxies->WriteLongTextL( TPtrC(PROXY_SERVER_NAME),
       
  3115                             *aApItem.iApProxyServerAddress);
       
  3116 
       
  3117     proxies->WriteTextL( TPtrC(PROXY_PROTOCOL_NAME),
       
  3118                          *aApItem.iApProxyProtocolName );
       
  3119 
       
  3120     proxies->WriteUintL( TPtrC(PROXY_PORT_NUMBER),
       
  3121                          aApItem.iApProxyPortNumber );
       
  3122 
       
  3123     proxies->WriteBoolL( TPtrC(PROXY_USE_PROXY_SERVER), 
       
  3124                          aApItem.iApProxyUseProxy );
       
  3125 
       
  3126     proxies->WriteLongTextL( TPtrC(PROXY_EXCEPTIONS),
       
  3127                             *aApItem.iApProxyExceptions );
       
  3128 
       
  3129     User::LeaveIfError( proxies->PutRecordChanges( EFalse, EFalse ) );
       
  3130 
       
  3131     CleanupStack::PopAndDestroy( proxies );   // proxies
       
  3132 
       
  3133     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteProxyDataL" ) ) );
       
  3134     }
   722     }
  3135 
   723 
  3136 
   724 
  3137 // ---------------------------------------------------------
   725 // ---------------------------------------------------------
  3138 // CApDataHandler::ReadProxyDataL
   726 // CApDataHandler::ReadProxyDataL
  3139 // ---------------------------------------------------------
   727 // ---------------------------------------------------------
  3140 //
   728 //
  3141 void CApDataHandler::ReadProxyDataL( CApAccessPointItem& aApItem )
   729 void CApDataHandler::ReadProxyDataL( CApAccessPointItem& aApItem )
  3142     {
   730     {
  3143     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  3144     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadProxyDataL" ) ) );
       
  3145 
       
  3146     // Add test cases covering ALL routes of this function
       
  3147 
       
  3148     CCommsDbTableView* proxies;    
       
  3149     proxies = iDb->OpenViewMatchingTextLC( TPtrC(PROXIES), 
       
  3150                                            TPtrC(PROXY_SERVICE_TYPE),
       
  3151                                            *aApItem.iIapServiceType );
       
  3152 
       
  3153     TInt err = proxies->GotoFirstRecord();
       
  3154 
       
  3155     if ( err != KErrNotFound )
       
  3156         {
       
  3157         User::LeaveIfError( err );
       
  3158         }
       
  3159 
       
  3160     if ( err != KErrNotFound )
       
  3161         {
       
  3162         // we have some proxy, now found our record...
       
  3163         TUint32 uval;
       
  3164         TBool found( EFalse );
       
  3165         do
       
  3166             {
       
  3167             proxies->ReadUintL( TPtrC(PROXY_ISP), uval );
       
  3168             if ( uval == aApItem.iIapServiceId )
       
  3169                 {
       
  3170                 found = ETrue;
       
  3171                 }
       
  3172             else
       
  3173                 {
       
  3174                 err = proxies->GotoNextRecord();
       
  3175                 }
       
  3176             } while ( (!err) && (!found) );
       
  3177         if ( found )
       
  3178             {
       
  3179             HBufC* buf = ApCommons::ReadLongTextLC( proxies,
       
  3180                                                     TPtrC(PROXY_SERVER_NAME),
       
  3181                                                     err );
       
  3182             if ( err != KErrUnknown )
       
  3183                 {
       
  3184                 aApItem.WriteLongTextL( EApProxyServerAddress, *buf );
       
  3185                 }
       
  3186 
       
  3187             CleanupStack::PopAndDestroy( buf ); 
       
  3188             buf = ApCommons::ReadText16ValueLC( proxies, 
       
  3189                                                 TPtrC(PROXY_PROTOCOL_NAME) );
       
  3190             aApItem.WriteTextL( EApProxyProtocolName, *buf );
       
  3191             CleanupStack::PopAndDestroy( buf ); 
       
  3192 
       
  3193             TUint32 tempint( 0 );
       
  3194             TBool tempbool( EFalse );
       
  3195 
       
  3196             ApCommons::ReadUintL( proxies, TPtrC(PROXY_PORT_NUMBER), tempint );
       
  3197             aApItem.WriteUint( EApProxyPortNumber, tempint );
       
  3198 
       
  3199 
       
  3200             ApCommons::ReadBoolL( proxies, 
       
  3201                                   TPtrC(PROXY_USE_PROXY_SERVER), 
       
  3202                                   tempbool );
       
  3203             aApItem.WriteBool( EApProxyUseProxy, tempbool );
       
  3204 
       
  3205             buf = ApCommons::ReadLongTextLC( proxies,
       
  3206                                              TPtrC(PROXY_EXCEPTIONS),
       
  3207                                              err );
       
  3208             aApItem.WriteLongTextL( EApProxyExceptions, *buf );
       
  3209     
       
  3210             CleanupStack::PopAndDestroy( buf );
       
  3211             }
       
  3212         }
       
  3213     CleanupStack::PopAndDestroy( proxies ); // proxies, sqlbuf
       
  3214 
       
  3215     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadProxyDataL" ) ) );
       
  3216     }
   731     }
  3217 
   732 
  3218 
   733 
  3219 
   734 
  3220 // ---------------------------------------------------------
   735 // ---------------------------------------------------------
  3221 // CApDataHandler::RemoveProxyDataL
   736 // CApDataHandler::RemoveProxyDataL
  3222 // ---------------------------------------------------------
   737 // ---------------------------------------------------------
  3223 //
   738 //
  3224 void CApDataHandler::RemoveProxyDataL( HBufC* aServiceType, TUint32 aIspId )
   739 void CApDataHandler::RemoveProxyDataL( HBufC* aServiceType, TUint32 aIspId )
  3225     {
   740     {
  3226     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  3227     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveProxyDataL" ) ) );
       
  3228 
       
  3229     // Add test cases covering ALL routes of this function
       
  3230 
       
  3231     CCommsDbTableView* proxies;    
       
  3232     proxies = iDb->OpenViewMatchingTextLC( TPtrC(PROXIES), 
       
  3233                                            TPtrC(PROXY_SERVICE_TYPE),
       
  3234                                            *aServiceType );
       
  3235 
       
  3236     TInt err = proxies->GotoFirstRecord();
       
  3237 
       
  3238     if ( err != KErrNotFound )
       
  3239         {
       
  3240         User::LeaveIfError( err );
       
  3241         }
       
  3242 
       
  3243     if ( err != KErrNotFound )
       
  3244         {
       
  3245         // we have some proxy, now found our record...
       
  3246         TUint32 uval;
       
  3247         TBool found( EFalse );
       
  3248         do
       
  3249             {
       
  3250             proxies->ReadUintL( TPtrC(PROXY_ISP), uval );
       
  3251             if ( uval == aIspId )
       
  3252                 {
       
  3253                 found = ETrue;
       
  3254                 }
       
  3255             else
       
  3256                 {
       
  3257                 err = proxies->GotoNextRecord();
       
  3258                 }
       
  3259             } while ( (!err) && (!found) );
       
  3260         if ( found )
       
  3261             {
       
  3262             if ( err == KErrNone )
       
  3263                 {
       
  3264                 User::LeaveIfError( proxies->DeleteRecord() );
       
  3265                 }
       
  3266             else
       
  3267                 {
       
  3268                 // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  3269                 // we are 'repairing it' this way.
       
  3270                 if ( err != KErrNotFound )
       
  3271                     {
       
  3272                     User::LeaveIfError( err );
       
  3273                     }
       
  3274                 }
       
  3275             }
       
  3276         }
       
  3277     CleanupStack::PopAndDestroy( proxies ); // proxies
       
  3278     
       
  3279     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveProxyDataL" ) ) );
       
  3280     }
   741     }
  3281 
   742 
  3282 
   743 
  3283 
   744 
  3284 
   745 
  3287 // ---------------------------------------------------------
   748 // ---------------------------------------------------------
  3288 //
   749 //
  3289 void CApDataHandler::WriteNetworkDataL( TBool aIsNew, 
   750 void CApDataHandler::WriteNetworkDataL( TBool aIsNew, 
  3290                                         CApAccessPointItem& aApItem )
   751                                         CApAccessPointItem& aApItem )
  3291     {
   752     {
  3292     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteNetworkDataL" ) ) );
       
  3293 
       
  3294     if ( aApItem.iNetworkName->Compare( KEmpty ) != 0 )
       
  3295         {
       
  3296         CCommsDbTableView* networks;
       
  3297         HBufC* buf = HBufC::NewLC( KApEngineMaxSql );
       
  3298         if ( aIsNew )
       
  3299             {
       
  3300             networks = iDb->OpenTableLC( TPtrC(NETWORK) );
       
  3301             TUint32 netid;
       
  3302             User::LeaveIfError( networks->InsertRecord( netid ) );
       
  3303             aApItem.iNetworkId = netid;
       
  3304             }
       
  3305         else
       
  3306             {
       
  3307             networks = iDb->OpenViewMatchingUintLC( TPtrC(NETWORK), 
       
  3308                                                     TPtrC(COMMDB_ID), 
       
  3309                                                     aApItem.iNetworkId );
       
  3310             TInt err = networks->GotoFirstRecord();
       
  3311             if ( err == KErrNotFound )
       
  3312                 { 
       
  3313                 // originally there were NO network, but now it is added
       
  3314                 TUint32 netid;
       
  3315                 User::LeaveIfError( networks->InsertRecord( netid ) );
       
  3316                 aApItem.iNetworkId = netid;
       
  3317                 }
       
  3318             else
       
  3319                 {
       
  3320                 User::LeaveIfError( networks->UpdateRecord() );
       
  3321                 }
       
  3322             }
       
  3323         networks->WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iNetworkName );
       
  3324 
       
  3325         User::LeaveIfError( networks->PutRecordChanges( EFalse, EFalse ) );
       
  3326 
       
  3327         CleanupStack::PopAndDestroy( networks );   // networks
       
  3328         CleanupStack::PopAndDestroy( buf );   // buf
       
  3329         }
       
  3330     
       
  3331     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::WriteNetworkDataL" ) ) );
       
  3332     }
   753     }
  3333 
   754 
  3334 
   755 
  3335 // ---------------------------------------------------------
   756 // ---------------------------------------------------------
  3336 // CApDataHandler::ReadNetworkDataL
   757 // CApDataHandler::ReadNetworkDataL
  3337 // ---------------------------------------------------------
   758 // ---------------------------------------------------------
  3338 //
   759 //
  3339 void CApDataHandler::ReadNetworkDataL( CApAccessPointItem& aApItem )
   760 void CApDataHandler::ReadNetworkDataL( CApAccessPointItem& aApItem )
  3340     {
   761     {
  3341     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  3342     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadNetworkDataL" ) ) );
       
  3343         
       
  3344     CCommsDbTableView* networks;
       
  3345     networks = iDb->OpenViewMatchingUintLC( TPtrC(NETWORK), 
       
  3346                                             TPtrC(COMMDB_ID), 
       
  3347                                             aApItem.iNetworkId );
       
  3348 
       
  3349     TInt err = networks->GotoFirstRecord();
       
  3350 
       
  3351     if ( err != KErrNotFound )
       
  3352         {
       
  3353         User::LeaveIfError( err );
       
  3354         }
       
  3355     if ( err != KErrNotFound )
       
  3356         {
       
  3357         HBufC* buf = ApCommons::ReadText16ValueLC( networks, 
       
  3358                                                    TPtrC(COMMDB_NAME) );
       
  3359         if ( err != KErrUnknown )
       
  3360             {
       
  3361             aApItem.WriteTextL( EApNetworkName, *buf );
       
  3362             }
       
  3363 
       
  3364         CleanupStack::PopAndDestroy( buf );
       
  3365         }
       
  3366     else
       
  3367         { // not found, set to NONE
       
  3368         aApItem.WriteTextL( EApNetworkName, KEmpty );
       
  3369         }
       
  3370     CleanupStack::PopAndDestroy( networks ); // networks
       
  3371     
       
  3372     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadNetworkDataL" ) ) );
       
  3373     }
   762     }
  3374 
   763 
  3375 
   764 
  3376 
   765 
  3377 // ---------------------------------------------------------
   766 // ---------------------------------------------------------
  3378 // CApDataHandler::RemoveNetworkDataL
   767 // CApDataHandler::RemoveNetworkDataL
  3379 // ---------------------------------------------------------
   768 // ---------------------------------------------------------
  3380 //
   769 //
  3381 void CApDataHandler::RemoveNetworkDataL( TUint32 aIspId )
   770 void CApDataHandler::RemoveNetworkDataL( TUint32 aIspId )
  3382     {
   771     {
  3383     // internal function, caller MUST initiate a transaction, WE WILL NOT.
       
  3384     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveNetworkDataL" ) ) );
       
  3385         
       
  3386     CCommsDbTableView* networks;
       
  3387     networks = iDb->OpenViewMatchingUintLC( TPtrC(NETWORK), 
       
  3388                                             TPtrC(COMMDB_ID), 
       
  3389                                             aIspId );
       
  3390 
       
  3391     TInt err = networks->GotoFirstRecord();
       
  3392 
       
  3393     if ( err == KErrNone )
       
  3394         {
       
  3395         User::LeaveIfError( networks->DeleteRecord() );
       
  3396         }
       
  3397     else
       
  3398         {
       
  3399         // silently ignore KErrNotFound. It is caused by incorrect DB,
       
  3400         // we are 'repairing it' this way.
       
  3401         if ( err != KErrNotFound )
       
  3402             {
       
  3403             User::LeaveIfError( err );
       
  3404             }
       
  3405         }
       
  3406     CleanupStack::PopAndDestroy( networks ); // networks, buf
       
  3407 
       
  3408     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::RemoveNetworkDataL" ) ) );
       
  3409     }
   772     }
  3410 
   773 
  3411 
   774 
  3412 
   775 
  3413 // ---------------------------------------------------------
   776 // ---------------------------------------------------------
  3414 // CApDataHandler::GetLocationIdL
   777 // CApDataHandler::GetLocationIdL
  3415 // ---------------------------------------------------------
   778 // ---------------------------------------------------------
  3416 //
   779 //
  3417 TUint32 CApDataHandler::GetLocationIdL()
   780 TUint32 CApDataHandler::GetLocationIdL()
  3418     {
   781     {
  3419     // agreed that the location record having the name 'Mobile' is used
   782     return 0;    
  3420     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::GetLocationIdL" ) ) );
       
  3421 
       
  3422     CCommsDbTableView* loc;
       
  3423     loc = iDb->OpenViewMatchingTextLC( TPtrC(LOCATION), TPtrC(COMMDB_NAME), 
       
  3424                                        KLocation );
       
  3425     TInt err = loc->GotoFirstRecord();
       
  3426 
       
  3427     User::LeaveIfError( err );
       
  3428     TUint32 id( 0 );
       
  3429     loc->ReadUintL( TPtrC(COMMDB_ID), id );
       
  3430 
       
  3431     CleanupStack::PopAndDestroy( loc ); // loc
       
  3432 
       
  3433     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::GetLocationIdL" ) ) );
       
  3434     return id;    
       
  3435     }
   783     }
  3436 
   784 
  3437 
   785 
  3438 
   786 
  3439 // ---------------------------------------------------------
   787 // ---------------------------------------------------------
  3440 // CApDataHandler::GetModemBearerIDL
   788 // CApDataHandler::GetModemBearerIDL
  3441 // ---------------------------------------------------------
   789 // ---------------------------------------------------------
  3442 //
   790 //
  3443 TUint32 CApDataHandler::GetModemBearerIDL( CApAccessPointItem& aApItem )
   791 TUint32 CApDataHandler::GetModemBearerIDL( CApAccessPointItem& aApItem )
  3444     {
   792     {
  3445     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::GetModemBearerIDL" ) ) );
   793   	User::Leave( KErrInvalidBearerType );
  3446 
       
  3447     // agreed that the modem bearer record having the name 
       
  3448     // 'CSD Modem' is used for (HS)CSD Access Points and
       
  3449     // 'GPRS Modem' is used for GPRS/WCDMA Access Points
       
  3450     // 'CDMA Modem' is used for CDMA Access Points
       
  3451     CCommsDbTableView* view = NULL;
       
  3452     TApBearerType bearer = aApItem.BearerTypeL();
       
  3453     switch ( bearer )
       
  3454         {
       
  3455         case EApBearerTypeCSD:
       
  3456         case EApBearerTypeHSCSD:
       
  3457             {
       
  3458             view = iDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), 
       
  3459                                                TPtrC(COMMDB_NAME), 
       
  3460                                                KModemBearerCSD );
       
  3461             break;
       
  3462             }
       
  3463         case EApBearerTypeCDMA:
       
  3464             {
       
  3465             view = iDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), 
       
  3466                                                TPtrC(COMMDB_NAME), 
       
  3467                                                KModemBearerCDMA );
       
  3468             break;
       
  3469             }
       
  3470         case EApBearerTypeGPRS:
       
  3471             {
       
  3472             view = iDb->OpenViewMatchingTextLC( TPtrC(MODEM_BEARER), 
       
  3473                                                TPtrC(COMMDB_NAME), 
       
  3474                                                KModemBearerGPRS );
       
  3475             break;
       
  3476             }
       
  3477 #ifdef __TEST_LAN_BEARER
       
  3478         case EApBearerTypeLAN:
       
  3479             {
       
  3480             view = iDb->OpenViewMatchingTextLC( TPtrC(LAN_BEARER), 
       
  3481                                            TPtrC(COMMDB_NAME), 
       
  3482                                            KModemBearerLAN );
       
  3483             break;
       
  3484             }
       
  3485 #endif // __TEST_LAN_BEARER            
       
  3486         case EApBearerTypeWLAN:
       
  3487             {
       
  3488             if ( aApItem.iExt->iWlanData )
       
  3489                 {                
       
  3490                 view = iDb->OpenViewMatchingTextLC( TPtrC(LAN_BEARER), 
       
  3491                                                     TPtrC(COMMDB_NAME), 
       
  3492                                                     KModemBearerWLAN );
       
  3493                 }
       
  3494             else
       
  3495                 {
       
  3496                 User::Leave( KErrNotSupported );
       
  3497                 }
       
  3498             break;
       
  3499             }
       
  3500         case EApBearerTypeLANModem:
       
  3501             {
       
  3502             view = iDb->OpenViewMatchingTextLC( TPtrC(LAN_BEARER), 
       
  3503                                            TPtrC(COMMDB_NAME), 
       
  3504                                            KModemBearerLANModem );
       
  3505             break;
       
  3506             }            
       
  3507         default:
       
  3508             {
       
  3509             User::Leave( KErrInvalidBearerType );
       
  3510             }
       
  3511         }
       
  3512         
       
  3513     TUint32 id( 0 );
       
  3514     
       
  3515     if ( view )
       
  3516         {
       
  3517         TInt err = view->GotoFirstRecord();
       
  3518         if ( err == KErrNone )
       
  3519             {
       
  3520             view->ReadUintL( TPtrC(COMMDB_ID), id );
       
  3521             }
       
  3522         else
       
  3523             {
       
  3524             if ( err != KErrNotFound ) 
       
  3525                 {
       
  3526                 User::LeaveIfError( err );
       
  3527                 }
       
  3528             else
       
  3529                 {
       
  3530                 if ( aApItem.iExt->iWlanData )
       
  3531                     {
       
  3532                     id = CreateLanBearerIfNeededL();
       
  3533                     }
       
  3534                 else
       
  3535                     {
       
  3536 #ifdef      __TEST_LAN_BEARER
       
  3537                     id = CreateLanBearerIfNeededL();
       
  3538 #else // __TEST_LAN_BEARER                
       
  3539                     User::Leave( KErrNotSupported );
       
  3540 #endif //__TEST_LAN_BEARER
       
  3541                     }
       
  3542                 }
       
  3543             }
       
  3544         CleanupStack::PopAndDestroy( view ); // view
       
  3545         }
       
  3546 
       
  3547     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::GetModemBearerIDL" ) ) );
       
  3548     return id;
       
  3549     }
   794     }
  3550 
   795 
  3551 
   796 
  3552 
   797 
  3553 
   798 
  3556 // ---------------------------------------------------------
   801 // ---------------------------------------------------------
  3557 //
   802 //
  3558 void CApDataHandler::ReadServiceL( CCommsDbTableView& ispt,
   803 void CApDataHandler::ReadServiceL( CCommsDbTableView& ispt,
  3559                                    CApAccessPointItem& aApItem )
   804                                    CApAccessPointItem& aApItem )
  3560     {
   805     {
  3561     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadServiceL" ) ) );
       
  3562 
       
  3563     HBufC* buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(COMMDB_NAME) );
       
  3564     aApItem.WriteTextL( EApIspName, *buf );
       
  3565     CleanupStack::PopAndDestroy( buf );
       
  3566     
       
  3567 //    TUint32 tempint( 0 );
       
  3568     TBool   tempbool( EFalse );
       
  3569 
       
  3570 /*
       
  3571     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IF_PARAMS) );
       
  3572     aApItem.WriteTextL( EApIspIfParams, *buf );
       
  3573     CleanupStack::PopAndDestroy( buf );
       
  3574 */
       
  3575     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IF_NETWORKS) );
       
  3576     aApItem.WriteTextL( EApWlanIfNetworks, *buf );
       
  3577     CleanupStack::PopAndDestroy( buf );
       
  3578 
       
  3579 /*
       
  3580     ApCommons::ReadBoolL( &ispt, TPtrC(SERVICE_IF_PROMPT_FOR_AUTH), tempbool );
       
  3581     aApItem.WriteBool( EApWlanIfPromptForAuth, tempbool );
       
  3582 
       
  3583     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IF_AUTH_NAME) );
       
  3584     aApItem.WriteTextL( EApWlanIfAuthName, *buf );
       
  3585     CleanupStack::PopAndDestroy( buf );
       
  3586 
       
  3587     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IF_AUTH_PASS) );
       
  3588     aApItem.WriteTextL( EApWlanIfAuthPassword, *buf );
       
  3589     CleanupStack::PopAndDestroy( buf );
       
  3590 
       
  3591     ApCommons::ReadUintL( &ispt, TPtrC(SERVICE_IF_AUTH_RETRIES), tempint );
       
  3592     aApItem.WriteUint( EApWlanIfAuthRetries, tempint );
       
  3593 
       
  3594     ApCommons::ReadBoolL( &ispt,
       
  3595                            TPtrC(SERVICE_IF_CALLBACK_ENABLED), tempbool );
       
  3596     aApItem.WriteBool( EApIspIfCallbackEnabled, tempbool );
       
  3597 
       
  3598     ApCommons::ReadUintL( &ispt, TPtrC(SERVICE_IF_CALLBACK_TYPE), tempint );
       
  3599     aApItem.WriteUint( EApIspIfCallbackType, ( TCallbackAction )tempint );
       
  3600 
       
  3601     HBufC8* buf8 = ApCommons::ReadText8ValueLC
       
  3602                                 ( &ispt, TPtrC(SERVICE_IF_CALLBACK_INFO) );
       
  3603     aApItem.WriteTextL( EApIspIfCallbackInfo, *buf8 );
       
  3604     CleanupStack::PopAndDestroy( buf8 ); 
       
  3605 
       
  3606     ApCommons::ReadUintL( &ispt, TPtrC(SERVICE_CALLBACK_TIMEOUT), tempint );
       
  3607     aApItem.WriteUint( EApIspCallBackTimeOut, tempint );
       
  3608 */
       
  3609 
       
  3610     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IP_NETMASK) );
       
  3611     aApItem.WriteTextL( EApWlanIpNetMask, *buf );
       
  3612     CleanupStack::PopAndDestroy( buf );
       
  3613 
       
  3614     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IP_GATEWAY) );
       
  3615     aApItem.WriteTextL( EApWlanIpGateway, *buf );
       
  3616     CleanupStack::PopAndDestroy( buf );
       
  3617 
       
  3618     ApCommons::ReadBoolL( &ispt, 
       
  3619                           TPtrC(SERVICE_IP_ADDR_FROM_SERVER), tempbool );
       
  3620     aApItem.WriteBool( EApWlanIpAddrFromServer, tempbool );
       
  3621 
       
  3622     buf = ApCommons::ReadText16ValueLC( &ispt, TPtrC(SERVICE_IP_ADDR) );
       
  3623     aApItem.WriteTextL( EApWlanIpAddr, *buf );
       
  3624     CleanupStack::PopAndDestroy( buf );
       
  3625 
       
  3626     ApCommons::ReadBoolL( &ispt, TPtrC(SERVICE_IP_DNS_ADDR_FROM_SERVER),
       
  3627                            tempbool );
       
  3628     aApItem.WriteBool( EApWlanIpDnsAddrFromServer, tempbool );
       
  3629 
       
  3630     buf = ApCommons::ReadText16ValueLC( &ispt, 
       
  3631                                         TPtrC(SERVICE_IP_NAME_SERVER1) );
       
  3632     aApItem.WriteTextL( EApWlanIPNameServer1, *buf );
       
  3633     CleanupStack::PopAndDestroy( buf );
       
  3634 
       
  3635     buf = ApCommons::ReadText16ValueLC( &ispt, 
       
  3636                                         TPtrC(SERVICE_IP_NAME_SERVER2) );
       
  3637     aApItem.WriteTextL( EApWlanIPNameServer2, *buf );
       
  3638     CleanupStack::PopAndDestroy( buf );
       
  3639 
       
  3640 /*
       
  3641     ApCommons::ReadBoolL( &ispt, TPtrC(SERVICE_ENABLE_SW_COMP), tempbool );
       
  3642     aApItem.WriteBool( EApIspEnableSWCompression, tempbool );
       
  3643 
       
  3644     ApCommons::ReadBoolL( &ispt, 
       
  3645                           TPtrC(SERVICE_ENABLE_IP_HEADER_COMP), 
       
  3646                           tempbool );
       
  3647     aApItem.WriteBool( EApIspEnableIpHeaderComp, tempbool);
       
  3648 
       
  3649     ApCommons::ReadBoolL( &ispt, 
       
  3650                           TPtrC(SERVICE_ENABLE_LCP_EXTENSIONS), tempbool );
       
  3651     aApItem.WriteBool( EApIspEnableLCPExtensions, tempbool );
       
  3652 
       
  3653     ApCommons::ReadBoolL( &ispt, TPtrC(SERVICE_DISABLE_PLAIN_TEXT_AUTH),
       
  3654                            tempbool );
       
  3655     aApItem.WriteBool( EApIspDisablePlainTextAuth, tempbool );
       
  3656 */
       
  3657     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::ReadServiceL" ) ) );
       
  3658     }
   806     }
  3659 
   807 
  3660 
   808 
  3661 // ---------------------------------------------------------
   809 // ---------------------------------------------------------
  3662 // CApDataHandler::ReadServiceIp6L
   810 // CApDataHandler::ReadServiceIp6L
  3663 // ---------------------------------------------------------
   811 // ---------------------------------------------------------
  3664 //
   812 //
  3665 void CApDataHandler::ReadServiceIp6L( CCommsDbTableView& ispt,
   813 void CApDataHandler::ReadServiceIp6L( CCommsDbTableView& ispt,
  3666                                    CApAccessPointItem& aApItem )
   814                                    CApAccessPointItem& aApItem )
  3667     {
   815     {
  3668     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadServiceIp6L" ) ) );
       
  3669 
       
  3670     if ( iExt->iIsIpv6Supported )
       
  3671         {
       
  3672         TBool tempbool( EFalse );
       
  3673         HBufC* buf;
       
  3674 
       
  3675         ApCommons::ReadBoolL( &ispt, TPtrC(SERVICE_IP6_DNS_ADDR_FROM_SERVER),
       
  3676                                tempbool );
       
  3677 
       
  3678         aApItem.WriteBool( EApIP6DNSAddrFromServer, tempbool );
       
  3679 
       
  3680         buf = ApCommons::ReadText16ValueLC( &ispt,
       
  3681                                             TPtrC(SERVICE_IP6_NAME_SERVER1) );
       
  3682 
       
  3683         aApItem.WriteTextL( EApIP6NameServer1, *buf );
       
  3684         CleanupStack::PopAndDestroy( buf );
       
  3685 
       
  3686         buf = ApCommons::ReadText16ValueLC( &ispt,
       
  3687                                             TPtrC(SERVICE_IP6_NAME_SERVER2) );
       
  3688 
       
  3689         aApItem.WriteTextL( EApIP6NameServer2, *buf );
       
  3690         CleanupStack::PopAndDestroy( buf );
       
  3691         }
       
  3692 
       
  3693     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::ReadServiceIp6L" ) ) );
       
  3694     }
   816     }
  3695 
   817 
  3696 
   818 
  3697 
   819 
  3698 
   820 
  3701 // ---------------------------------------------------------
   823 // ---------------------------------------------------------
  3702 //
   824 //
  3703 void CApDataHandler::WriteServiceL( CCommsDbTableView& aTable,
   825 void CApDataHandler::WriteServiceL( CCommsDbTableView& aTable,
  3704                                     CApAccessPointItem& aApItem )
   826                                     CApAccessPointItem& aApItem )
  3705     {
   827     {
  3706     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteServiceL" ) ) );
       
  3707     
       
  3708     aTable.WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iIspName );
       
  3709     
       
  3710 //    aTable.WriteTextL( TPtrC(SERVICE_IF_PARAMS), *aApItem.iIspIfParams );
       
  3711 
       
  3712     aTable.WriteTextL( TPtrC(SERVICE_IF_NETWORKS), *aApItem.iIspIfNetworks );
       
  3713 
       
  3714 //    aTable.WriteBoolL( TPtrC(SERVICE_IF_PROMPT_FOR_AUTH),
       
  3715 //                     aApItem.iIspIfPromptForAuth );
       
  3716 
       
  3717 //    aTable.WriteTextL( TPtrC(SERVICE_IF_AUTH_NAME), 
       
  3718 //                       *aApItem.iIspIfAuthName );
       
  3719 
       
  3720 //    aTable.WriteTextL( TPtrC(SERVICE_IF_AUTH_PASS), 
       
  3721 //                       *aApItem.iIspIfAuthPass );
       
  3722 
       
  3723 //    aTable.WriteUintL( TPtrC(SERVICE_IF_AUTH_RETRIES),
       
  3724 //                     aApItem.iIspIfAuthRetries );
       
  3725 
       
  3726     aTable.WriteTextL( TPtrC(SERVICE_IP_NETMASK), *aApItem.iIspIPNetMask );
       
  3727 
       
  3728     aTable.WriteTextL( TPtrC(SERVICE_IP_GATEWAY), *aApItem.iIspGateway );
       
  3729 
       
  3730     aTable.WriteBoolL( TPtrC(SERVICE_IP_ADDR_FROM_SERVER),
       
  3731                        aApItem.iIspIPAddrFromServer );
       
  3732 
       
  3733     aTable.WriteTextL( TPtrC(SERVICE_IP_ADDR), *aApItem.iIspIPAddr );
       
  3734 
       
  3735     aTable.WriteBoolL( TPtrC(SERVICE_IP_DNS_ADDR_FROM_SERVER),
       
  3736                      aApItem.iGetDNSIPFromServer );
       
  3737 
       
  3738     aTable.WriteTextL( TPtrC(SERVICE_IP_NAME_SERVER1), 
       
  3739                        *aApItem.iPrimaryDNS );
       
  3740 
       
  3741     aTable.WriteTextL( TPtrC(SERVICE_IP_NAME_SERVER2), 
       
  3742                        *aApItem.iSecondaryDNS );
       
  3743 
       
  3744 /*
       
  3745     aTable.WriteBoolL( TPtrC(SERVICE_ENABLE_LCP_EXTENSIONS),
       
  3746                      aApItem.iIspEnableLCPExtensions );
       
  3747 
       
  3748     aTable.WriteBoolL( TPtrC(SERVICE_DISABLE_PLAIN_TEXT_AUTH),
       
  3749                      aApItem.iIsPasswordAuthenticationSecure );
       
  3750 
       
  3751     aTable.WriteBoolL( TPtrC(SERVICE_ENABLE_SW_COMP),
       
  3752                      aApItem.iIspEnableSwCompression );
       
  3753 
       
  3754     aTable.WriteBoolL( TPtrC(SERVICE_ENABLE_IP_HEADER_COMP),
       
  3755                      aApItem.iEnablePPPCompression );
       
  3756         
       
  3757     aTable.WriteBoolL( TPtrC(SERVICE_IF_CALLBACK_ENABLED),
       
  3758                      aApItem.iUseCallBack );
       
  3759 
       
  3760     aTable.WriteUintL( TPtrC(SERVICE_IF_CALLBACK_TYPE),
       
  3761                      aApItem.iCallBackTypeIsServerNum );
       
  3762 
       
  3763     aTable.WriteTextL( TPtrC(SERVICE_IF_CALLBACK_INFO),
       
  3764                      *aApItem.iIspIfCallbackInfo );
       
  3765 
       
  3766     aTable.WriteUintL( TPtrC(SERVICE_CALLBACK_TIMEOUT),
       
  3767                      aApItem.iIspCallbackTimeOut );    
       
  3768 */    
       
  3769 
       
  3770 //    WriteDaemonL( aTable, aApItem ); starts here
       
  3771     if ( aApItem.iIspIPAddrFromServer )
       
  3772         {
       
  3773         aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), 
       
  3774                            KDaemonManagerName );
       
  3775         aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), 
       
  3776                            KConfigDaemonName );
       
  3777         }
       
  3778     else
       
  3779         {
       
  3780         // 3.1 it is changed!!
       
  3781         if ( FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
       
  3782             {
       
  3783             aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), 
       
  3784                                KDaemonManagerName );
       
  3785             aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), 
       
  3786                                KConfigDaemonName );            
       
  3787             }
       
  3788         else
       
  3789             {
       
  3790             aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), KEmpty );
       
  3791             aTable.WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), KEmpty );            
       
  3792             }
       
  3793         }
       
  3794 //    WriteDaemonL() Ends here
       
  3795 
       
  3796 
       
  3797     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::WriteServiceL" ) ) );
       
  3798     }
   828     }
  3799 
   829 
  3800 
   830 
  3801 // ---------------------------------------------------------
   831 // ---------------------------------------------------------
  3802 // CApDataHandler::WriteServiceIp6L
   832 // CApDataHandler::WriteServiceIp6L
  3803 // ---------------------------------------------------------
   833 // ---------------------------------------------------------
  3804 //
   834 //
  3805 void CApDataHandler::WriteServiceIp6L( CCommsDbTableView& ispt,
   835 void CApDataHandler::WriteServiceIp6L( CCommsDbTableView& ispt,
  3806                                        CApAccessPointItem& aApItem )
   836                                        CApAccessPointItem& aApItem )
  3807     {
   837     {
  3808     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteServiceIp6L" ) ) );
       
  3809 
       
  3810     ispt.WriteBoolL( TPtrC(SERVICE_IP6_DNS_ADDR_FROM_SERVER),
       
  3811                      aApItem.iExt->iIpv6GetDNSIPFromServer );
       
  3812 
       
  3813     ispt.WriteTextL( TPtrC(SERVICE_IP6_NAME_SERVER1), 
       
  3814                     *aApItem.iExt->iIpv6PrimaryDNS );
       
  3815 
       
  3816     ispt.WriteTextL( TPtrC(SERVICE_IP6_NAME_SERVER2), 
       
  3817                     *aApItem.iExt->iIpv6SecondaryDNS );
       
  3818         
       
  3819     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::WriteServiceIp6L" ) ) );
       
  3820     }
   838     }
  3821 
   839 
  3822 
   840 
  3823 
   841 
  3824 // ---------------------------------------------------------
   842 // ---------------------------------------------------------
  3826 // ---------------------------------------------------------
   844 // ---------------------------------------------------------
  3827 //
   845 //
  3828 void CApDataHandler::WriteCsdDataL( TBool aIsNew,
   846 void CApDataHandler::WriteCsdDataL( TBool aIsNew,
  3829                                     CApAccessPointItem& aApItem )
   847                                     CApAccessPointItem& aApItem )
  3830     {
   848     {
  3831     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteCsdDataL" ) ) );
       
  3832 
       
  3833     TInt isCsdSupported = 
       
  3834          FeatureManager::FeatureSupported( KFeatureIdAppCsdSupport ); 
       
  3835 #ifdef __TEST_CSD_SUPPORT
       
  3836     isCsdSupported = ETrue;
       
  3837 #endif // __TEST_CSD_SUPPORT
       
  3838    
       
  3839     TCommsDbBearerType bearerType = 
       
  3840                     STATIC_CAST( TCommsDbBearerType, aApItem.iIspBearerType );
       
  3841 
       
  3842     if ( ( ( bearerType == EBearerTypeCSD ) && ( !isCsdSupported ) ) || 
       
  3843          ( ( bearerType == EBearerTypeHSCSD ) && 
       
  3844            ( !isCsdSupported || !iExt->iIsAppHscsdSupport ) ) )
       
  3845         {
       
  3846         User::Leave( KErrNotSupported );
       
  3847         }
       
  3848 
       
  3849     CCommsDbTableView* ispt;
       
  3850 
       
  3851     if ( aIsNew )
       
  3852         {
       
  3853         ispt = iDb->OpenTableLC( *aApItem.iIapServiceType );
       
  3854         User::LeaveIfError( ispt->InsertRecord( aApItem.iIapServiceId ) );
       
  3855         }
       
  3856     else
       
  3857         {
       
  3858         ispt = iDb->OpenViewMatchingUintLC( *aApItem.iIapServiceType,
       
  3859                                            TPtrC(COMMDB_ID),
       
  3860                                            aApItem.iIapServiceId );
       
  3861         User::LeaveIfError( ispt->GotoFirstRecord() );
       
  3862         User::LeaveIfError( ispt->UpdateRecord() );
       
  3863         }
       
  3864     // now write record data
       
  3865     ispt->WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iIspName );
       
  3866 
       
  3867     ispt->WriteTextL( TPtrC(ISP_DESCRIPTION), *aApItem.iIspDescription );
       
  3868 
       
  3869     ispt->WriteUintL( TPtrC(ISP_TYPE), aApItem.iIspType );
       
  3870 
       
  3871     ispt->WriteTextL( TPtrC(ISP_DEFAULT_TEL_NUM),
       
  3872                      *aApItem.iIspDefaultTelNumber );
       
  3873 
       
  3874     ispt->WriteBoolL( TPtrC(ISP_DIAL_RESOLUTION),
       
  3875                      aApItem.iIspDialResolution );
       
  3876 
       
  3877     ispt->WriteBoolL( TPtrC(ISP_USE_LOGIN_SCRIPT),
       
  3878                       aApItem.iUseLoginScript );
       
  3879 
       
  3880     ispt->WriteLongTextL( TPtrC(ISP_LOGIN_SCRIPT), *aApItem.iLoginScript );
       
  3881 
       
  3882     ispt->WriteBoolL( TPtrC(ISP_PROMPT_FOR_LOGIN),
       
  3883                       aApItem.iPromptPassword );
       
  3884 
       
  3885     ispt->WriteTextL( TPtrC(ISP_LOGIN_NAME), *aApItem.iUserName );
       
  3886 
       
  3887     ispt->WriteTextL( TPtrC(ISP_LOGIN_PASS), *aApItem.iPassword );
       
  3888 
       
  3889     ispt->WriteBoolL( TPtrC(ISP_DISPLAY_PCT),
       
  3890                      aApItem.iDisplayTerminalWindow );
       
  3891 
       
  3892     ApSpeed2EtelL( &aApItem );
       
  3893 
       
  3894 /*
       
  3895 // Keep as long as replacing IF_NAME does not works as specified
       
  3896     ispt->WriteTextL( TPtrC(IF_NAME), *aApItem.iIspIfName );
       
  3897 */
       
  3898 
       
  3899     ispt->WriteTextL( TPtrC(ISP_IF_PARAMS), *aApItem.iIspIfParams );
       
  3900 
       
  3901     ispt->WriteTextL( TPtrC(ISP_IF_NETWORKS), *aApItem.iIspIfNetworks );
       
  3902 
       
  3903     ispt->WriteBoolL( TPtrC(ISP_IF_PROMPT_FOR_AUTH),
       
  3904                      aApItem.iIspIfPromptForAuth );
       
  3905 
       
  3906     // as same UserName & Auth_name is required
       
  3907     ispt->WriteTextL( TPtrC(ISP_IF_AUTH_NAME), *aApItem.iUserName );
       
  3908 
       
  3909     // as same login_pass & Auth_password is required
       
  3910     ispt->WriteTextL( TPtrC(ISP_IF_AUTH_PASS), *aApItem.iPassword );
       
  3911 
       
  3912     ispt->WriteUintL( TPtrC(ISP_IF_AUTH_RETRIES),
       
  3913                       aApItem.iIspIfAuthRetries );
       
  3914 
       
  3915     ispt->WriteBoolL( TPtrC(ISP_IF_CALLBACK_ENABLED),
       
  3916                       aApItem.iUseCallBack );
       
  3917 
       
  3918     ispt->WriteUintL( TPtrC(ISP_IF_CALLBACK_TYPE),
       
  3919                      aApItem.iCallBackTypeIsServerNum );
       
  3920 
       
  3921     ispt->WriteTextL( TPtrC(ISP_IF_CALLBACK_INFO),
       
  3922                       *aApItem.iIspIfCallbackInfo );
       
  3923 
       
  3924     ispt->WriteUintL( TPtrC(ISP_CALLBACK_TIMEOUT),
       
  3925                      aApItem.iIspCallbackTimeOut );
       
  3926 
       
  3927     ispt->WriteBoolL( TPtrC(ISP_IP_ADDR_FROM_SERVER),
       
  3928                      aApItem.iIspIPAddrFromServer );
       
  3929 
       
  3930     ispt->WriteTextL( TPtrC(ISP_IP_ADDR), *aApItem.iIspIPAddr );
       
  3931 
       
  3932     ispt->WriteTextL( TPtrC(ISP_IP_NETMASK), *aApItem.iIspIPNetMask );
       
  3933 
       
  3934     ispt->WriteTextL( TPtrC(ISP_IP_GATEWAY), *aApItem.iIspGateway );
       
  3935 
       
  3936     ispt->WriteBoolL( TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),
       
  3937                      aApItem.iGetDNSIPFromServer );
       
  3938 
       
  3939     ispt->WriteTextL( TPtrC(ISP_IP_NAME_SERVER1), *aApItem.iPrimaryDNS );
       
  3940 
       
  3941     ispt->WriteTextL( TPtrC(ISP_IP_NAME_SERVER2), *aApItem.iSecondaryDNS );
       
  3942 
       
  3943     ispt->WriteBoolL( TPtrC(ISP_ENABLE_IP_HEADER_COMP),
       
  3944                      aApItem.iEnablePPPCompression );
       
  3945 
       
  3946     ispt->WriteBoolL( TPtrC(ISP_ENABLE_LCP_EXTENSIONS),
       
  3947                      aApItem.iIspEnableLCPExtensions );
       
  3948 
       
  3949     ispt->WriteBoolL( TPtrC(ISP_DISABLE_PLAIN_TEXT_AUTH),
       
  3950                      aApItem.iIsPasswordAuthenticationSecure );
       
  3951 
       
  3952     ispt->WriteBoolL( TPtrC(ISP_ENABLE_SW_COMP),
       
  3953                      aApItem.iIspEnableSwCompression );
       
  3954 
       
  3955     ispt->WriteUintL( TPtrC(ISP_BEARER_NAME), aApItem.iIspBearerName );
       
  3956 
       
  3957     ispt->WriteUintL( TPtrC(ISP_BEARER_SPEED), aApItem.iExt->iBearerSpeed );
       
  3958     
       
  3959     ispt->WriteUintL( TPtrC(ISP_BEARER_PROTOCOL), 
       
  3960                       aApItem.iExt->iBearerProtocol );
       
  3961 
       
  3962     ispt->WriteUintL( TPtrC(ISP_BEARER_CE), aApItem.iIspBearerCE );
       
  3963 
       
  3964     ispt->WriteUintL( TPtrC(ISP_BEARER_SERVICE), aApItem.iApIapBearerService );
       
  3965 
       
  3966 
       
  3967 
       
  3968     ispt->WriteTextL( TPtrC(ISP_INIT_STRING), *aApItem.iIspInitString );
       
  3969 
       
  3970     ispt->WriteUintL( TPtrC(ISP_BEARER_TYPE), aApItem.iIspBearerType );
       
  3971 
       
  3972     ispt->WriteUintL( TPtrC(ISP_CHANNEL_CODING),
       
  3973                       aApItem.iIspChannelCoding );
       
  3974 
       
  3975     ispt->WriteUintL( TPtrC(ISP_AIUR), aApItem.iIspAIUR );
       
  3976 
       
  3977     ispt->WriteUintL( TPtrC(ISP_REQUESTED_TIME_SLOTS),
       
  3978                      aApItem.iIspRequestedTimeSlots );
       
  3979 
       
  3980     ispt->WriteUintL( TPtrC(ISP_MAXIMUM_TIME_SLOTS),
       
  3981                      aApItem.iIspMaximumTimeSlots );
       
  3982 
       
  3983     if ( iExt->iIsIpv6Supported )
       
  3984         {
       
  3985         WriteServiceIp6L( *ispt, aApItem );
       
  3986         }
       
  3987 
       
  3988     // No DHCP for CSD/HSCSD, so set it empty
       
  3989     ispt->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME), KEmpty );
       
  3990     ispt->WriteTextL( TPtrC(SERVICE_CONFIG_DAEMON_NAME), KEmpty );
       
  3991     
       
  3992     // now put changes
       
  3993     User::LeaveIfError( ispt->PutRecordChanges( EFalse, EFalse ) );
       
  3994 
       
  3995     CleanupStack::PopAndDestroy( ispt );  // ispt
       
  3996 
       
  3997     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::WriteCsdDataL" ) ) );
       
  3998     }
   849     }
  3999 
   850 
  4000 
   851 
  4001 
   852 
  4002 // ---------------------------------------------------------
   853 // ---------------------------------------------------------
  4004 // ---------------------------------------------------------
   855 // ---------------------------------------------------------
  4005 //
   856 //
  4006 void CApDataHandler::ReadWlanL( CCommsDbTableView& lant,
   857 void CApDataHandler::ReadWlanL( CCommsDbTableView& lant,
  4007                                 CApAccessPointItem& aApItem )
   858                                 CApAccessPointItem& aApItem )
  4008     {
   859     {
  4009     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadWlanL" ) ) );
       
  4010 
       
  4011     HBufC* buf = ApCommons::ReadText16ValueLC( &lant, TPtrC(NU_WLAN_SSID) );
       
  4012     aApItem.WriteTextL( EApWlanNetworkName, *buf );
       
  4013     CleanupStack::PopAndDestroy( buf );
       
  4014     
       
  4015     TUint32 tempint( 0 );
       
  4016 
       
  4017     ApCommons::ReadUintL( &lant, TPtrC(COMMDB_ID), tempint );
       
  4018     aApItem.WriteUint( EApWlanSettingsId, tempint );
       
  4019 
       
  4020     ApCommons::ReadUintL( &lant, TPtrC(WLAN_CONNECTION_MODE), tempint );
       
  4021     aApItem.WriteUint( EApWlanNetworkMode, tempint );
       
  4022 
       
  4023     ApCommons::ReadUintL( &lant, TPtrC(WLAN_SECURITY_MODE), tempint );
       
  4024     aApItem.WriteUint( EApWlanSecurityMode, tempint );
       
  4025 
       
  4026     TBool b;
       
  4027     ApCommons::ReadBoolL( &lant, TPtrC(WLAN_SCAN_SSID), b );
       
  4028     aApItem.WriteBool( EApWlanScanSSID, b );
       
  4029 
       
  4030     ApCommons::ReadUintL( &lant, TPtrC(NU_WLAN_CHANNEL_ID), tempint );
       
  4031     aApItem.WriteUint( EApWlanChannelId, tempint );
       
  4032 
       
  4033     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::ReadWlanL" ) ) );
       
  4034     }
   860     }
  4035 
   861 
  4036 
   862 
  4037 
   863 
  4038 // ---------------------------------------------------------
   864 // ---------------------------------------------------------
  4040 // ---------------------------------------------------------
   866 // ---------------------------------------------------------
  4041 //
   867 //
  4042 void CApDataHandler::WriteWlanL( CCommsDbTableView& aTable,
   868 void CApDataHandler::WriteWlanL( CCommsDbTableView& aTable,
  4043                                  CApAccessPointItem& aApItem )
   869                                  CApAccessPointItem& aApItem )
  4044     {
   870     {
  4045     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::WriteWlanL" ) ) );
       
  4046 
       
  4047     aTable.WriteTextL( TPtrC(COMMDB_NAME), *aApItem.iIspName );
       
  4048     aTable.WriteUintL( TPtrC(WLAN_SERVICE_ID), aApItem.iIapServiceId );
       
  4049     aTable.WriteTextL( TPtrC(NU_WLAN_SSID), 
       
  4050                        *aApItem.iExt->iWlanData->iWlanNetworkName );
       
  4051     aTable.WriteUintL( TPtrC(WLAN_CONNECTION_MODE), 
       
  4052                       aApItem.iExt->iWlanData->iWlanNetworkMode );
       
  4053 
       
  4054     aTable.WriteUintL( TPtrC(WLAN_SECURITY_MODE), 
       
  4055                       aApItem.iExt->iWlanData->iWlanSecurityMode );
       
  4056 
       
  4057     aTable.WriteBoolL( TPtrC(WLAN_SCAN_SSID),
       
  4058                      aApItem.iExt->iWlanData->iScanSSID );
       
  4059                      
       
  4060     aTable.WriteUintL( TPtrC(NU_WLAN_CHANNEL_ID), 
       
  4061                       aApItem.iExt->iWlanData->iChannelId );
       
  4062     
       
  4063     CLOG( ( EHandler, 0, _L( "<- CApDataHandler::WriteWlanL" ) ) );
       
  4064     }
   871     }
  4065 
   872 
  4066 
   873 
  4067 
   874 
  4068 
   875 
  4070 // CApDataHandler::CreateLanBearerIfNeededL
   877 // CApDataHandler::CreateLanBearerIfNeededL
  4071 // ---------------------------------------------------------
   878 // ---------------------------------------------------------
  4072 //
   879 //
  4073 TUint32 CApDataHandler::CreateLanBearerIfNeededL()
   880 TUint32 CApDataHandler::CreateLanBearerIfNeededL()
  4074     {
   881     {
  4075     CLOG( ( EApItem, 0, 
   882     return KErrNotFound;
  4076             _L( "-> CApDataHandler::CreateLanBearerIfNeededL" ) ) );
       
  4077     
       
  4078     TUint32 retval( 0 );
       
  4079 
       
  4080     CCommsDbTableView* t = NULL;
       
  4081 
       
  4082     t = iDb->OpenViewMatchingTextLC( TPtrC(LAN_BEARER), 
       
  4083                                      TPtrC(LAN_BEARER_AGENT), 
       
  4084                                      KWlanBearerAgent );
       
  4085     if ( t->GotoFirstRecord() == KErrNotFound )
       
  4086         { // no such yet, create one
       
  4087         TInt err = t->InsertRecord( retval );
       
  4088         if ( err )
       
  4089             {
       
  4090             User::LeaveIfError( err );
       
  4091             }
       
  4092         t->WriteTextL( TPtrC(COMMDB_NAME), KWlanBearerName );
       
  4093         t->WriteTextL( TPtrC(LAN_BEARER_AGENT), KWlanBearerAgent );
       
  4094         t->WriteTextL( TPtrC(LAN_BEARER_NIF_NAME), KWlanBearerNif );
       
  4095 
       
  4096         t->WriteTextL( TPtrC(LAN_BEARER_LDD_NAME), KWlanLDDName );
       
  4097         t->WriteTextL( TPtrC(LAN_BEARER_PDD_NAME), KWlanPDDName );
       
  4098 
       
  4099 
       
  4100 
       
  4101         t->WriteUintL( TPtrC(LAST_SOCKET_ACTIVITY_TIMEOUT), 
       
  4102                        (TUint32)KWlanLastSocketActivityTimeout ); 
       
  4103         t->WriteUintL( TPtrC(LAST_SESSION_CLOSED_TIMEOUT), 
       
  4104                        KWlanLastSessionClosedTimeout ); 
       
  4105         t->WriteUintL( TPtrC(LAST_SOCKET_CLOSED_TIMEOUT), 
       
  4106                        (TUint32)KWlanLastSocketClosedTimeout ); 
       
  4107 
       
  4108         User::LeaveIfError( t->PutRecordChanges( EFalse, EFalse ) );
       
  4109 
       
  4110         }
       
  4111     else
       
  4112         { // there is one, use it
       
  4113         t->ReadUintL( TPtrC(COMMDB_ID), retval );
       
  4114         }
       
  4115 
       
  4116     CleanupStack::PopAndDestroy( t );   // t
       
  4117     
       
  4118     CLOG( ( EApItem, 0, 
       
  4119             _L( "<- CApDataHandler::CreateLanBearerIfNeededL" ) ) );
       
  4120 
       
  4121     return retval;
       
  4122     }
   883     }
  4123 
   884 
  4124 
   885 
  4125 
   886 
  4126 
   887 
  4130 // CApDataHandler::ReadModemBearerNameL
   891 // CApDataHandler::ReadModemBearerNameL
  4131 // ---------------------------------------------------------
   892 // ---------------------------------------------------------
  4132 //
   893 //
  4133 void CApDataHandler::ReadModemBearerNameL( CApAccessPointItem& aApItem )
   894 void CApDataHandler::ReadModemBearerNameL( CApAccessPointItem& aApItem )
  4134     {
   895     {
  4135     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::ReadModemBearerNameL" ) ) );
       
  4136 
       
  4137     // agreed that the modem bearer record having the name 
       
  4138     // 'CSD Modem' is used for (HS)CSD Access Points and
       
  4139     // 'GPRS Modem' is used for GPRS/WCDMA Access Points
       
  4140     // 'CDMA Modem' is used for CDMA Access Points
       
  4141     CCommsDbTableView* view = NULL;
       
  4142 //    TApBearerType bearer = aApItem.BearerTypeL();
       
  4143 
       
  4144     view = iDb->OpenViewMatchingUintLC( *aApItem.iExt->iIapBearerType, 
       
  4145                                        TPtrC(COMMDB_ID), 
       
  4146                                        aApItem.iExt->iIapBearerID );
       
  4147 //                                       0 );
       
  4148     HBufC* buf = NULL;
       
  4149     buf = ApCommons::ReadText16ValueLC( view, TPtrC(COMMDB_NAME) );
       
  4150     aApItem.WriteTextL( EApLanBearerName, *buf );
       
  4151     CleanupStack::PopAndDestroy( buf );
       
  4152 
       
  4153     CleanupStack::PopAndDestroy( view );
       
  4154 
       
  4155 
       
  4156     CLOG( ( EHandler, 1, _L( "<- CApDataHandler::ReadModemBearerNameL" ) ) );
       
  4157     }
   896     }
  4158 
   897 
  4159 //  End of File
   898 //  End of File