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