apengine/apeng/src/APDataHandler.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
    36 #include "ApDataHandler.h"
    36 #include "ApDataHandler.h"
    37 #include "ApAccessPointItem.h"
    37 #include "ApAccessPointItem.h"
    38 #include "ApEngineCommons.h"
    38 #include "ApEngineCommons.h"
    39 #include "ApUtils.h"
    39 #include "ApUtils.h"
    40 #include "ApEngineVer.h"
    40 #include "ApEngineVer.h"
    41 #include "ApEngineLogger.h" 
    41 #include "ApEngineLogger.h"
    42 #include "ApNetworkItem.h"
    42 #include "ApNetworkItem.h"
    43 #include "APItemExtra.h"
    43 #include "APItemExtra.h"
    44 #include "APItemCdmaData.h"
    44 #include "APItemCdmaData.h"
    45 #include "APItemWlanData.h"
    45 #include "APItemWlanData.h"
    46 #include "ApSpeedLookup.h"
    46 #include "ApSpeedLookup.h"
       
    47 
       
    48 #include <WEPSecuritySettingsUI.h>
       
    49 #include <WPASecuritySettingsUI.h>
       
    50 
    47 
    51 
    48 // CONSTANTS
    52 // CONSTANTS
    49 #if defined(_DEBUG)
    53 #if defined(_DEBUG)
    50     _LIT( KErrInvalidIntendedType, "Invalid intended default type" );
    54     _LIT( KErrInvalidIntendedType, "Invalid intended default type" );
    51 #endif // (_DEBUG)
    55 #endif // (_DEBUG)
   250 // CApDataHandler::CreateCopyFromL
   254 // CApDataHandler::CreateCopyFromL
   251 // ---------------------------------------------------------
   255 // ---------------------------------------------------------
   252 //
   256 //
   253 EXPORT_C TUint32 CApDataHandler::CreateCopyFromL( TUint32 aBaseId )
   257 EXPORT_C TUint32 CApDataHandler::CreateCopyFromL( TUint32 aBaseId )
   254     {
   258     {
   255     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::CreateCopyFromL - ERROR: not suported" ) ) );
   259     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::CreateCopyFromL" ) ) );
   256     User::Leave( KErrNotSupported );
   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;
   257     }
   393     }
   258 
   394 
   259 
   395 
   260 
   396 
   261 // ---------------------------------------------------------
   397 // ---------------------------------------------------------
  2392 // CApDataHandler::RemoveWlanL
  2528 // CApDataHandler::RemoveWlanL
  2393 // ---------------------------------------------------------
  2529 // ---------------------------------------------------------
  2394 //
  2530 //
  2395 void CApDataHandler::RemoveWlanL( TUint32 aUid )
  2531 void CApDataHandler::RemoveWlanL( TUint32 aUid )
  2396     {
  2532     {
  2397     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveWlanL - ERROR: not suported" ) ) );
  2533     CLOG( ( EHandler, 0, _L( "-> CApDataHandler::RemoveWlanL" ) ) );
  2398     User::Leave( KErrNotSupported );
  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" ) ) );
  2399     }
  2598     }
  2400 
  2599 
  2401 
  2600 
  2402 
  2601 
  2403 // ---------------------------------------------------------
  2602 // ---------------------------------------------------------