iaupdate/IAD/firmwareupdate/src/iaupdatefwsynchandler.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 0 ba25891c3a9e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 
    18 
    19 
    19 
    20 
    20 
    21 // INCLUDES
    21 // INCLUDES
    22 #include <aknnotewrappers.h>
       
    23 #include <AknWaitDialog.h>
       
    24 #include <StringLoader.h>
    22 #include <StringLoader.h>
    25 #include <e32property.h>
    23 #include <e32property.h>
    26 #include <data_caging_path_literals.hrh>  // for resource and bitmap directories
    24 #include <data_caging_path_literals.hrh>  // for resource and bitmap directories
    27 #include <SyncMLErr.h>      // sync error codes
    25 #include <SyncMLErr.h>      // sync error codes
    28 #include <iaupdate.rsg>
       
    29 #include <AknsUtils.h>
       
    30 #include <DevManInternalCRKeys.h>
    26 #include <DevManInternalCRKeys.h>
    31 #include <centralrepository.h>
    27 #include <centralrepository.h>
    32 #include <rconnmon.h>
    28 #include <rconnmon.h>
    33 #include <es_enum.h>
    29 #include <es_enum.h>
    34 
    30 
    35 #include <cmconnectionmethodext.h>
    31 #include <cmconnectionmethod.h>
    36 #include <cmconnectionmethoddef.h>
    32 #include <cmconnectionmethoddef.h>
    37 #include <cmpluginpacketdatadef.h>
    33 #include <cmpluginpacketdatadef.h>
    38 #include <cmconnectionmethoddef.h>
    34 
    39 #include <cmconnectionmethodext.h>
    35 #include <cmdestination.h>
    40 #include <cmdestinationext.h>
       
    41 #include <cmmanagerdef.h>
    36 #include <cmmanagerdef.h>
       
    37 
       
    38 #include <uikon.hrh>
    42 
    39 
    43 #include "iaupdateconnectionmethod.h"
    40 #include "iaupdateconnectionmethod.h"
    44 #include "iaupdateprivatecrkeys.h"
    41 #include "iaupdateprivatecrkeys.h"
    45 #include "iaupdatefwfotamodel.h"
    42 #include "iaupdatefwfotamodel.h"
    46 #include "iaupdatefwsyncappengine.h"
    43 #include "iaupdatefwsyncappengine.h"
    80 // Destructor.
    77 // Destructor.
    81 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    82 //
    79 //
    83 CIAUpdateFWSyncHandler::~CIAUpdateFWSyncHandler()
    80 CIAUpdateFWSyncHandler::~CIAUpdateFWSyncHandler()
    84     {
    81     {
    85     if ( iWaitDialog )
    82     /*if ( iWaitDialog )
    86         {
    83         {
    87         TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
    84         TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
    88         iWaitDialog = NULL;
    85         iWaitDialog = NULL;
    89         }
    86         }*/
    90     
    87     
    91 	delete iState;
    88 	delete iState;
    92 	delete iActiveCaller;
    89 	delete iActiveCaller;
    93 
    90 
    94 	if ( iSyncRunning )
    91 	if ( iSyncRunning )
   332                     KNSmlDMNoUserInitiatedJob );
   329                     KNSmlDMNoUserInitiatedJob );
   333 	
   330 	
   334 	iSyncRunning = EFalse;
   331 	iSyncRunning = EFalse;
   335 	iSyncError = aError;
   332 	iSyncError = aError;
   336 
   333 
   337     if ( iWaitDialog )
   334     /*if ( iWaitDialog )
   338         {
   335         {
   339         
   336         
   340         iWaitDialog->ProcessFinishedL();
   337         iWaitDialog->ProcessFinishedL();
   341         iWaitDialog = NULL;
   338         iWaitDialog = NULL;
   342         }
   339         }*/
   343 
   340 
   344 	iUseFotaProgressNote = EFalse;
   341 	iUseFotaProgressNote = EFalse;
   345     iSyncJob.Close();
   342     iSyncJob.Close();
   346     FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeCompletedL 13");
   343     FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeCompletedL 13");
   347 	// handle error in HandleActiveCallL (when active caller completes)
   344 	// handle error in HandleActiveCallL (when active caller completes)
   427     User::LeaveIfError(  
   424     User::LeaveIfError(  
   428         cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
   425         cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
   429     CleanupStack::PopAndDestroy( cenrep ); 
   426     CleanupStack::PopAndDestroy( cenrep ); 
   430     cenrep = NULL;
   427     cenrep = NULL;
   431 
   428 
   432     RCmManagerExt cmManagerExt;
   429     RCmManager cmManager;
   433     cmManagerExt.OpenL();
   430     cmManager.OpenL();
   434     CleanupClosePushL( cmManagerExt );
   431     CleanupClosePushL( cmManager );
   435     
   432     
   436     if ( connMethodId == -1 )
   433     if ( connMethodId == -1 )
   437         {
   434         {
   438         //check what is the default connection by users     
   435         //check what is the default connection by users     
   439         
   436         
   440         TCmDefConnValue DCSetting;
   437         TCmDefConnValue DCSetting;
   441         cmManagerExt.ReadDefConnL( DCSetting );
   438         cmManager.ReadDefConnL( DCSetting );
   442        
   439        
   443         
   440         
   444         switch ( DCSetting.iType )
   441         switch ( DCSetting.iType )
   445             {
   442             {
   446             case ECmDefConnAlwaysAsk:
   443             case ECmDefConnAlwaysAsk:
   447             case ECmDefConnAskOnce:
   444             case ECmDefConnAskOnce:
   448                 {
   445                 {
   449                 //go with the best IAP under internet snap
   446                 //go with the best IAP under internet snap
   450                 connectionMethodId = GetBestIAPInInternetSNAPL( cmManagerExt );
   447                 connectionMethodId = GetBestIAPInInternetSNAPL( cmManager );
   451                 break;
   448                 break;
   452                 }
   449                 }
   453             case ECmDefConnDestination:
   450             case ECmDefConnDestination:
   454                 {
   451                 {
   455                 //go with the best IAP under this snap
   452                 //go with the best IAP under this snap
   456                 connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId );
   453                 connectionMethodId = GetBestIAPInThisSNAPL( cmManager, DCSetting.iId );
   457                 break;
   454                 break;
   458                 }
   455                 }
   459             case ECmDefConnConnectionMethod:
   456             case ECmDefConnConnectionMethod:
   460                 {
   457                 {
   461                 //go with the best IAP under this snap
   458                 //go with the best IAP under this snap
   465             }
   462             }
   466         }
   463         }
   467     else if ( connMethodId == 0 )
   464     else if ( connMethodId == 0 )
   468         {
   465         {
   469         //no choice from user, we go with the best IAP under Internent SNAP
   466         //no choice from user, we go with the best IAP under Internent SNAP
   470         connectionMethodId = GetBestIAPInInternetSNAPL( cmManagerExt );
   467         connectionMethodId = GetBestIAPInInternetSNAPL( cmManager );
   471         }
   468         }
   472     else
   469     else
   473         {
   470         {
   474 
   471 
   475         // It was some SNAP value
   472         // It was some SNAP value
   476         connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId );
   473         connectionMethodId = GetBestIAPInThisSNAPL( cmManager, connMethodId );
   477         }
   474         }
   478 
   475 
   479     CleanupStack::PopAndDestroy( &cmManagerExt ); 
   476     CleanupStack::PopAndDestroy( &cmManager ); 
   480     
   477     
   481     return connectionMethodId;
   478     return connectionMethodId;
   482               
   479               
   483     }
   480     }
   484 
   481 
   485 
   482 
   486 // -----------------------------------------------------------------------------
   483 // -----------------------------------------------------------------------------
   487 // CIAUpdateFWSyncHandler::GetBestIAPInInternetSNAPL
   484 // CIAUpdateFWSyncHandler::GetBestIAPInInternetSNAPL
   488 // -----------------------------------------------------------------------------
   485 // -----------------------------------------------------------------------------
   489 //
   486 //
   490 TUint32 CIAUpdateFWSyncHandler::GetBestIAPInInternetSNAPL( RCmManagerExt& aCmManagerExt  )
   487 TUint32 CIAUpdateFWSyncHandler::GetBestIAPInInternetSNAPL( RCmManager& aCmManager )
   491     {
   488     {
   492     //select IAP from Internet SNAP
   489     //select IAP from Internet SNAP
   493     RArray<TUint32> destIdArray;
   490     RArray<TUint32> destIdArray;
   494     aCmManagerExt.AllDestinationsL( destIdArray );
   491     aCmManager.AllDestinationsL( destIdArray );
   495     TUint32 InternetSNAPID = 0;
   492     TUint32 InternetSNAPID = 0;
   496     for ( TInt i = 0; i< destIdArray.Count(); i++ )
   493     for ( TInt i = 0; i< destIdArray.Count(); i++ )
   497         {
   494         {
   498         RCmDestinationExt dest = aCmManagerExt.DestinationL( destIdArray[i] );
   495         RCmDestination dest = aCmManager.DestinationL( destIdArray[i] );
   499         CleanupClosePushL( dest );
   496         CleanupClosePushL( dest );
   500                                      
   497                                      
   501         if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
   498         if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
   502             {
   499             {
   503             InternetSNAPID = destIdArray[i];
   500             InternetSNAPID = destIdArray[i];
   506             }                     
   503             }                     
   507          CleanupStack::PopAndDestroy( &dest ); 
   504          CleanupStack::PopAndDestroy( &dest ); 
   508          }
   505          }
   509     destIdArray.Reset();
   506     destIdArray.Reset();
   510     
   507     
   511     return GetBestIAPInThisSNAPL( aCmManagerExt, InternetSNAPID );
   508     return GetBestIAPInThisSNAPL( aCmManager, InternetSNAPID );
   512     }
   509     }
   513 
   510 
   514 
   511 
   515 
   512 
   516 // -----------------------------------------------------------------------------
   513 // -----------------------------------------------------------------------------
   517 // CIAUpdateFWSyncHandler::GetBestIAPInThisSNAPL
   514 // CIAUpdateFWSyncHandler::GetBestIAPInThisSNAPL
   518 // -----------------------------------------------------------------------------
   515 // -----------------------------------------------------------------------------
   519 //
   516 //
   520 TUint32 CIAUpdateFWSyncHandler::GetBestIAPInThisSNAPL( RCmManagerExt& aCmManagerExt, TUint32 aSNAPID  )
   517 TUint32 CIAUpdateFWSyncHandler::GetBestIAPInThisSNAPL( RCmManager& aCmManager, TUint32 aSNAPID  )
   521     {
   518     {
   522     //get all usable IAPs
   519     //get all usable IAPs
   523     TConnMonIapInfoBuf iapInfo;
   520     TConnMonIapInfoBuf iapInfo;
   524     TRequestStatus status;
   521     TRequestStatus status;
   525                        
   522                        
   531     User::WaitForRequest( status );
   528     User::WaitForRequest( status );
   532     User::LeaveIfError( status.Int() );
   529     User::LeaveIfError( status.Int() );
   533     
   530     
   534     CleanupStack::PopAndDestroy( &connMon ); 
   531     CleanupStack::PopAndDestroy( &connMon ); 
   535     
   532     
   536     RCmDestinationExt dest = aCmManagerExt.DestinationL( aSNAPID );
   533     RCmDestination dest = aCmManager.DestinationL( aSNAPID );
   537     CleanupClosePushL( dest );
   534     CleanupClosePushL( dest );
   538     
   535     
   539     // Check whether the SNAP contains any IAP.
   536     // Check whether the SNAP contains any IAP.
   540     for  (TInt i = 0; i < dest.ConnectionMethodCount(); i++ )
   537     for  (TInt i = 0; i < dest.ConnectionMethodCount(); i++ )
   541         {
   538         {
   542         RCmConnectionMethodExt cm =  dest.ConnectionMethodL( i );
   539         RCmConnectionMethod cm =  dest.ConnectionMethodL( i );
   543         CleanupClosePushL( cm );
   540         CleanupClosePushL( cm );
   544         
   541         
   545         TUint32 iapid= cm.GetIntAttributeL( CMManager::ECmIapId );
   542         TUint32 iapid= cm.GetIntAttributeL( CMManager::ECmIapId );
   546         
   543         
   547         for ( TInt i = 0; i < iapInfo().iCount; i++ )
   544         for ( TInt i = 0; i < iapInfo().iCount; i++ )
   714 // CIAUpdateFWSyncHandler::ShowProgressDialogL
   711 // CIAUpdateFWSyncHandler::ShowProgressDialogL
   715 // -----------------------------------------------------------------------------
   712 // -----------------------------------------------------------------------------
   716 //
   713 //
   717 void CIAUpdateFWSyncHandler::ShowProgressDialogL( )
   714 void CIAUpdateFWSyncHandler::ShowProgressDialogL( )
   718 	{
   715 	{
   719         iWaitDialog = new ( ELeave ) CAknWaitDialog(
   716         //iWaitDialog = new ( ELeave ) CAknWaitDialog(
   720             ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ) );
   717         //    ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ) );
   721         iWaitDialog->ExecuteLD( R_FOTA_CHECK_WAIT_NOTE );
   718         //iWaitDialog->ExecuteLD( R_FOTA_CHECK_WAIT_NOTE );
   722         iWaitDialog->SetCallback( this );
   719         //iWaitDialog->SetCallback( this );
   723 	}
   720 	}
   724 
   721 
   725 // -----------------------------------------------------------------------------
   722 // -----------------------------------------------------------------------------
   726 // CIAUpdateFWSyncHandler::HideProgressDialogL
   723 // CIAUpdateFWSyncHandler::HideProgressDialogL
   727 // -----------------------------------------------------------------------------
   724 // -----------------------------------------------------------------------------
   728 //
   725 //
   729 void CIAUpdateFWSyncHandler::HideProgressDialogL()
   726 void CIAUpdateFWSyncHandler::HideProgressDialogL()
   730     {
   727     {
   731     if ( iWaitDialog )
   728     /*if ( iWaitDialog )
   732         {
   729         {
   733         iWaitDialog->ProcessFinishedL();
   730         iWaitDialog->ProcessFinishedL();
   734         iWaitDialog = NULL;
   731         iWaitDialog = NULL;
   735         }
   732         }*/
   736     }
   733     }
   737 
   734 
   738 // -----------------------------------------------------------------------------
   735 // -----------------------------------------------------------------------------
   739 // CIAUpdateFWSyncHandler::Session
   736 // CIAUpdateFWSyncHandler::Session
   740 // -----------------------------------------------------------------------------
   737 // -----------------------------------------------------------------------------